/*
* Copyright (C) 2011-2014 GeoForge Project
*
* This program 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, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.geoforge.guillc.panel;
import java.awt.GridLayout;
import java.awt.geom.Point2D;
import javax.swing.event.DocumentListener;
import org.geoforge.guillc.textfield.GfrTfdTextSmall;
/**
*
* @author Amadeus.Sowerby
*
* email: Amadeus.Sowerby_AT_gmail.com
* ... please remove "_AT_" from the above string to get the right email address
*/
public class GfrPnlLatLon extends GfrPnl
{
private GfrTfdTextSmall _tfdLatitude_ = null;
private GfrTfdTextSmall _tfdLongitude_ = null;
private Point2D.Double _p2d_ = null;
public GfrPnlLatLon(Point2D.Double p2d)
{
super();
this._tfdLatitude_ = new GfrTfdTextSmall((String) null, (DocumentListener) null);
this._tfdLongitude_ = new GfrTfdTextSmall((String) null, (DocumentListener) null);
this._p2d_ = p2d;
super.setLayout(new GridLayout(1, 2, 20, 10));
}
@Override
public boolean init()
{
if (!super.init())
return false;
if (!this._tfdLatitude_.init())
return false;
if (!this._tfdLongitude_.init())
return false;
String strValueLatitude = "";
String strValueLongitude = "";
if (this._p2d_ != null)
{
strValueLongitude = String.valueOf(this._p2d_.x);
strValueLatitude = String.valueOf(this._p2d_.y);
}
this._tfdLatitude_.setText(strValueLatitude);
this._tfdLatitude_.setEditable(false);
this._tfdLatitude_.setToolTipText("Latitude");
this._tfdLongitude_.setText(strValueLongitude);
this._tfdLongitude_.setEditable(false);
this._tfdLongitude_.setToolTipText("Longitude");
super.add(this._tfdLatitude_);
super.add(this._tfdLongitude_);
return true;
}
@Override
public void destroy()
{
super.destroy();
if(this._tfdLatitude_ != null)
{
this._tfdLatitude_.destroy();
this._tfdLatitude_= null;
}
if(this._tfdLongitude_ != null)
{
this._tfdLongitude_.destroy();
this._tfdLongitude_= null;
}
}
}