/* ===========================================================
 * JFreeChart : a free chart library for the Java(tm) platform
 * ===========================================================
 *
 * (C) Copyright 2000-2011, by Object Refinery Limited and Contributors.
 *
 * Project Info:  http://www.jfree.org/jfreechart/index.html
 *
 * 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; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * 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.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
 * USA.
 *
 * [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
 * Other names may be trademarks of their respective owners.]
 *
 * ----------------------
 * DefaultLogAxisEditor.java
 * ----------------------
 * (C) Copyright 2005-2011, by Object Refinery Limited and Contributors.
 *
 * Original Author:  Martin Hoeller;
 * Contributor(s):   -;
 *
 * Changes
 * -------
 * 03-Nov-2011 : Version 1 (MH);
 *
 */

package org.jfree.chart.editor;

import java.awt.event.ActionEvent;
import java.awt.event.FocusEvent;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import org.jfree.chart.axis.Axis;
import org.jfree.chart.axis.LogAxis;
import org.jfree.chart.axis.NumberTickUnit;

/**
 * A panel for editing properties of a {@link LogAxis}.
 */
public class DefaultLogAxisEditor extends DefaultValueAxisEditor {

    private double manualTickUnitValue;

    private JTextField manualTickUnit;


    /**
     * Standard constructor: builds a property panel for the specified axis.
     *
     * @param axis  the axis, which should be changed.
     */
    public DefaultLogAxisEditor(LogAxis axis)
    {
        super(axis);
        this.manualTickUnitValue = axis.getTickUnit().getSize();
        manualTickUnit.setText(Double.toString(this.manualTickUnitValue));
    }
    
    protected JPanel createTickUnitPanel()
    {
        JPanel tickUnitPanel = super.createTickUnitPanel();

        tickUnitPanel.add(new JLabel(localizationResources.getString(
                "Manual_TickUnit_value")));
        this.manualTickUnit = new JTextField(Double.toString(
                this.manualTickUnitValue));
        this.manualTickUnit.setEnabled(!isAutoTickUnitSelection());
        this.manualTickUnit.setActionCommand("TickUnitValue");
        this.manualTickUnit.addActionListener(this);
        this.manualTickUnit.addFocusListener(this);
        tickUnitPanel.add(this.manualTickUnit);
        tickUnitPanel.add(new JPanel());

        return tickUnitPanel;
    }

    /**
     * Handles actions from within the property panel.
     * @param event an event.
     */
    public void actionPerformed(ActionEvent event) {
        String command = event.getActionCommand();
        if (command.equals("TickUnitValue")) {
            validateTickUnit();
        }
        else {
            // pass to the super-class for handling
            super.actionPerformed(event);
        }
    }

    public void focusLost(FocusEvent event) {
        super.focusLost(event);
        if (event.getSource() == this.manualTickUnit) {
            validateTickUnit();
        }
    }

    public void toggleAutoTick() {
        super.toggleAutoTick();
        if (isAutoTickUnitSelection()) {
            this.manualTickUnit.setText(Double.toString(this.manualTickUnitValue));
            this.manualTickUnit.setEnabled(false);
        }
        else {
            this.manualTickUnit.setEnabled(true);
        }
    }

    public void validateTickUnit() {
        double newTickUnit;
        try {
            newTickUnit = Double.parseDouble(this.manualTickUnit.getText());
        }
        catch (NumberFormatException e) {
            newTickUnit = this.manualTickUnitValue;
        }

        if (newTickUnit > 0.0) {
            this.manualTickUnitValue = newTickUnit;
        }
        this.manualTickUnit.setText(Double.toString(this.manualTickUnitValue));
    }

    /**
     * Sets the properties of the specified axis to match the properties
     * defined on this panel.
     *
     * @param axis  the axis.
     */
    public void setAxisProperties(Axis axis) {
        super.setAxisProperties(axis);
        LogAxis logAxis = (LogAxis) axis;
        if (!isAutoTickUnitSelection()) {
            logAxis.setTickUnit(new NumberTickUnit(manualTickUnitValue));
        }
    }
}

@@ -206,25 +206,25 @@
 ght 2000-201
-1
+3
 , by Object 
@@ -1237,24 +1237,27 @@
 ------------
+---
 %0A * DefaultL
@@ -1295,24 +1295,27 @@
 ------------
+---
 %0A * (C) Copy
@@ -1328,17 +1328,17 @@
 2005-201
-1
+3
 , by Obj
@@ -2024,17 +2024,16 @@
 kUnit;%0A%0A
-%0A
     /**%0A
@@ -2224,20 +2224,16 @@
 is axis)
-%0A   
  %7B%0A     
@@ -2399,16 +2399,114 @@
  %7D%0A    %0A
+    /**%0A     * Creates a panel for editing the tick unit.%0A     * %0A     * @return A panel.%0A     */%0A
     prot
@@ -2539,20 +2539,16 @@
 tPanel()
-%0A   
  %7B%0A     
@@ -3245,24 +3245,32 @@
 erty panel.%0A
+     * %0A
      * @para
@@ -3789,32 +3789,91 @@
        %7D%0A    %7D%0A%0A
+    /**%0A     * Toggles the auto-tick-unit setting.%0A     */%0A
     public void 
@@ -4183,32 +4183,88 @@
        %7D%0A    %7D%0A%0A
+    /**%0A     * Validates the tick unit entered.%0A     */%0A
     public void 

Add missing Javadocs.