/* * Geotoolkit - An Open Source Java GIS Toolkit * http://www.geotoolkit.org * * (C) 2007 - 2008, Open Source Geospatial Foundation (OSGeo) * (C) 2008 - 2009, Johann Sorel * * 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.style; import java.awt.Component; import java.awt.Font; import javax.swing.BorderFactory; import javax.swing.GroupLayout; import javax.swing.GroupLayout.Alignment; import javax.swing.JCheckBox; import javax.swing.JLabel; import javax.swing.JTextField; import javax.swing.LayoutStyle.ComponentPlacement; import javax.swing.SwingConstants; import org.geotoolkit.gui.swing.resource.MessageBundle; import org.geotoolkit.map.MapLayer; import org.geotoolkit.style.MutableStyle; import org.jdesktop.swingx.JXTitledPanel; /** * * @author Johann Sorel (Puzzle-GIS) * @module */ public class JStylePane extends StyleElementEditor<MutableStyle>{ private MapLayer layer = null; private MutableStyle style = null; /** Creates new form JRulePanel */ public JStylePane() { super(MutableStyle.class); initComponents(); } /** 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() { jXTitledPanel1 = new JXTitledPanel(); jck_default = new JCheckBox(); guiName = new JLabel(); jtf_name = new JTextField(); guiTitle = new JLabel(); jtf_title = new JTextField(); jtf_abstract = new JTextField(); guiAbstract = new JLabel(); guiLabelDefault = new JLabel(); jXTitledPanel1.setBorder(BorderFactory.createEtchedBorder()); jXTitledPanel1.setTitle(MessageBundle.format("general")); // NOI18N jck_default.setText(" "); guiName.setText(MessageBundle.format("name")); // NOI18N guiTitle.setFont(guiTitle.getFont().deriveFont(guiTitle.getFont().getStyle() | Font.BOLD)); guiTitle.setText(MessageBundle.format("title")); // NOI18N guiAbstract.setText(MessageBundle.format("abstrac")); // NOI18N guiLabelDefault.setText(MessageBundle.format("defaut")); // NOI18N GroupLayout jXTitledPanel1Layout = new GroupLayout(jXTitledPanel1); jXTitledPanel1.setLayout(jXTitledPanel1Layout); jXTitledPanel1Layout.setHorizontalGroup( jXTitledPanel1Layout.createParallelGroup(Alignment.LEADING) .addGroup(jXTitledPanel1Layout.createSequentialGroup() .addGroup(jXTitledPanel1Layout.createParallelGroup(Alignment.LEADING) .addGroup(jXTitledPanel1Layout.createSequentialGroup() .addGap(12, 12, 12) .addComponent(guiName, GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(jtf_name, GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)) .addGroup(jXTitledPanel1Layout.createSequentialGroup() .addContainerGap() .addComponent(guiTitle) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(jtf_title, GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)) .addGroup(jXTitledPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jXTitledPanel1Layout.createParallelGroup(Alignment.LEADING) .addComponent(guiAbstract) .addComponent(guiLabelDefault)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(jXTitledPanel1Layout.createParallelGroup(Alignment.LEADING) .addGroup(jXTitledPanel1Layout.createSequentialGroup() .addComponent(jck_default) .addGap(0, 0, Short.MAX_VALUE)) .addComponent(jtf_abstract, GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)))) .addContainerGap()) ); jXTitledPanel1Layout.linkSize(SwingConstants.HORIZONTAL, new Component[] {guiAbstract, guiName, guiTitle}); jXTitledPanel1Layout.setVerticalGroup( jXTitledPanel1Layout.createParallelGroup(Alignment.LEADING) .addGroup(jXTitledPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jXTitledPanel1Layout.createParallelGroup(Alignment.BASELINE) .addComponent(guiName) .addComponent(jtf_name, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(jXTitledPanel1Layout.createParallelGroup(Alignment.BASELINE) .addComponent(guiTitle) .addComponent(jtf_title, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(jXTitledPanel1Layout.createParallelGroup(Alignment.BASELINE) .addComponent(guiAbstract) .addComponent(jtf_abstract, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(jXTitledPanel1Layout.createParallelGroup(Alignment.BASELINE) .addComponent(jck_default) .addComponent(guiLabelDefault)) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); GroupLayout layout = new GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(Alignment.LEADING) .addComponent(jXTitledPanel1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(Alignment.LEADING) .addComponent(jXTitledPanel1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) ); }// </editor-fold>//GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables private JLabel guiAbstract; private JLabel guiLabelDefault; private JLabel guiName; private JLabel guiTitle; private JXTitledPanel jXTitledPanel1; private JCheckBox jck_default; private JTextField jtf_abstract; private JTextField jtf_name; private JTextField jtf_title; // End of variables declaration//GEN-END:variables @Override public void setLayer(final MapLayer layer) { this.layer = layer; } @Override public MapLayer getLayer() { return layer; } @Override public void parse(final MutableStyle target) { this.style = target; if(style != null){ jtf_name.setText(style.getName()); jtf_title.setText(style.getDescription().getTitle().toString()); jtf_abstract.setText(style.getDescription().getAbstract().toString()); jck_default.setSelected(style.isDefault()); } } @Override public MutableStyle create() { if(style == null){ style = getStyleFactory().style(); } style.setName(jtf_name.getText()); style.setDescription(getStyleFactory().description( jtf_title.getText(), jtf_abstract.getText())); style.setDefault(jck_default.isSelected()); return style; } @Override public void apply() { create(); } @Override protected Object[] getFirstColumnComponents() { return new Object[]{guiTitle,guiName,guiAbstract,guiLabelDefault}; } }