/* * 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.AnchorPoint; import org.geotools.styling.StyleBuilder; /** * Anchor point edition panel * * @author Johann Sorel * * @source $URL$ */ public class JAnchorPointPane extends javax.swing.JPanel implements StyleElementEditor<AnchorPoint>{ private MapLayer layer = null; private AnchorPoint anchor = null; /** Creates new form JDisplacementPanel */ public JAnchorPointPane() { initComponents(); init(); } private void init(){ guiX.setType(JExpressionPane.EXP_TYPE.NUMBER); guiY.setType(JExpressionPane.EXP_TYPE.NUMBER); } public void setLayer(MapLayer layer){ guiX.setLayer(layer); guiY.setLayer(layer); this.layer = layer; } public MapLayer getLayer(){ return layer; } public void setEdited(AnchorPoint disp) { this.anchor = disp; if(anchor != null){ guiX.setExpression(anchor.getAnchorPointX()); guiY.setExpression(anchor.getAnchorPointY()); } } public AnchorPoint getEdited(){ if(anchor == null){ StyleBuilder sb = new StyleBuilder(); anchor = sb.createAnchorPoint(0,0); } apply(); return anchor; } public void apply(){ if(anchor != null){ anchor.setAnchorPointX(guiX.getExpression()); anchor.setAnchorPointY(guiY.getExpression()); } } /** 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() { jLabel1 = new javax.swing.JLabel(); guiX = new org.geotools.gui.swing.style.sld.JExpressionPane(); jLabel2 = new javax.swing.JLabel(); guiY = new org.geotools.gui.swing.style.sld.JExpressionPane(); jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/geotools/gui/swing/style/sld/Bundle"); // NOI18N jLabel1.setText(bundle.getString("x")); // NOI18N jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); jLabel2.setText(bundle.getString("y")); // 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(jLabel1) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(guiX, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(layout.createSequentialGroup() .add(jLabel2) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(guiY, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) ); layout.linkSize(new java.awt.Component[] {guiX, guiY}, org.jdesktop.layout.GroupLayout.HORIZONTAL); layout.linkSize(new java.awt.Component[] {jLabel1, jLabel2}, org.jdesktop.layout.GroupLayout.HORIZONTAL); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(guiX, 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(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) .add(jLabel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(guiY, 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.JExpressionPane guiX; private org.geotools.gui.swing.style.sld.JExpressionPane guiY; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; // End of variables declaration//GEN-END:variables public Component getComponent() { return this; } }