<commit_before>/*
 *
 * Copyright (c) 2000-2008 by <NAME>, <NAME>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License (LGPL) as published by the Free Software Foundation.
 *
 * 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, copies are available
 * at http://www.opensource.org.
 */
package VASSAL.build.module.map;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;

import javax.swing.AbstractListModel;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JScrollPane;
import javax.swing.JSpinner;
import javax.swing.JSplitPane;
import javax.swing.JTextField;
import javax.swing.ListModel;
import javax.swing.ListSelectionModel;
import javax.swing.SpinnerNumberModel;
import javax.swing.SwingUtilities;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;

import VASSAL.build.AbstractConfigurable;
import VASSAL.build.AutoConfigurable;
import VASSAL.build.Buildable;
import VASSAL.build.GameModule;
import VASSAL.build.module.GameComponent;
import VASSAL.build.module.Map;
import VASSAL.build.module.documentation.HelpFile;
import VASSAL.command.Command;
import VASSAL.configure.Configurer;
import VASSAL.configure.ConfigurerFactory;
import VASSAL.configure.IconConfigurer;
import VASSAL.configure.NamedHotKeyConfigurer;
import VASSAL.configure.SingleChildInstance;
import VASSAL.configure.StringArrayConfigurer;
import VASSAL.i18n.Resources;
import VASSAL.tools.ErrorDialog;
import VASSAL.tools.LaunchButton;
import VASSAL.tools.NamedKeyStroke;
import VASSAL.tools.swing.SwingUtils;

/**
 * Controls the zooming in/out of a {@link Map} window.
 *
 * @author <NAME>
 */
public class Zoomer extends AbstractConfigurable implements GameComponent {
  protected Map map;

  @Deprecated(since = "2020-08-06", forRemoval = true) protected double zoom = 1.0;
  @Deprecated(since = "2020-08-06", forRemoval = true) protected int zoomLevel = 0;
  @Deprecated(since = "2020-08-06", forRemoval = true) protected int zoomStart = 1;
  @Deprecated(since = "2020-08-06", forRemoval = true) protected double[] zoomFactor;
  @Deprecated(since = "2020-08-06", forRemoval = true) protected int maxZoom = 4;

  protected LaunchButton zoomInButton;
  protected LaunchButton zoomPickButton;
  protected LaunchButton zoomOutButton;
  protected ZoomMenu zoomMenu;

  protected MouseWheelListener listener;

  protected State state;

  // the default zoom levels are powers of 1.6
  protected static final double[] defaultZoomLevels = {
    1.0 / 1.6 / 1.6,
    1.0 / 1.6,
    1.0,
    1.6
  };

  protected static final int defaultInitialZoomLevel = 2;

  /**
   * Stores the state information for the {@link Zoomer}. This class
   * exists to keep the <code>Zoomer</code> data separate from the
   * <code>Zoomer</code> GUI.
   *
   * <p>Predefined zoom levels are stored in <code>levels</code>. If we are
   * in a predefined zoom level, then <code>custom == -1</code> and
   * <code>levels[cur]</code> is the current zoom factor. If we are in
   * a user-defined zoom level, then <code>custom</code> is the current
   * zoom factor and <code>cur</code> is the greatest value such that
   * {@code custom < level[cur]}}.</p>
   *
   * @author <NAME>
   * @since 3.1.0
   */<commit_msg>Increased # of default zoom levels per http://www.vassalengine.org/forum/viewtopic.php?f=4&t=13014<commit_after>/*
 *
 * Copyright (c) 2000-2008 by <NAME>, <NAME>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License (LGPL) as published by the Free Software Foundation.
 *
 * 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, copies are available
 * at http://www.opensource.org.
 */
package VASSAL.build.module.map;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;

import javax.swing.AbstractListModel;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JScrollPane;
import javax.swing.JSpinner;
import javax.swing.JSplitPane;
import javax.swing.JTextField;
import javax.swing.ListModel;
import javax.swing.ListSelectionModel;
import javax.swing.SpinnerNumberModel;
import javax.swing.SwingUtilities;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;

import VASSAL.build.AbstractConfigurable;
import VASSAL.build.AutoConfigurable;
import VASSAL.build.Buildable;
import VASSAL.build.GameModule;
import VASSAL.build.module.GameComponent;
import VASSAL.build.module.Map;
import VASSAL.build.module.documentation.HelpFile;
import VASSAL.command.Command;
import VASSAL.configure.Configurer;
import VASSAL.configure.ConfigurerFactory;
import VASSAL.configure.IconConfigurer;
import VASSAL.configure.NamedHotKeyConfigurer;
import VASSAL.configure.SingleChildInstance;
import VASSAL.configure.StringArrayConfigurer;
import VASSAL.i18n.Resources;
import VASSAL.tools.ErrorDialog;
import VASSAL.tools.LaunchButton;
import VASSAL.tools.NamedKeyStroke;
import VASSAL.tools.swing.SwingUtils;

/**
 * Controls the zooming in/out of a {@link Map} window.
 *
 * @author <NAME>
 */
public class Zoomer extends AbstractConfigurable implements GameComponent {
  protected Map map;

  @Deprecated(since = "2020-08-06", forRemoval = true) protected double zoom = 1.0;
  @Deprecated(since = "2020-08-06", forRemoval = true) protected int zoomLevel = 0;
  @Deprecated(since = "2020-08-06", forRemoval = true) protected int zoomStart = 1;
  @Deprecated(since = "2020-08-06", forRemoval = true) protected double[] zoomFactor;
  @Deprecated(since = "2020-08-06", forRemoval = true) protected int maxZoom = 4;

  protected LaunchButton zoomInButton;
  protected LaunchButton zoomPickButton;
  protected LaunchButton zoomOutButton;
  protected ZoomMenu zoomMenu;

  protected MouseWheelListener listener;

  protected State state;

  protected static final double[] defaultZoomLevels = {
    0.2,
    0.25,
    0.333,
    0.4,
    0.5,
    0.555,
    0.625,
    0.75,
    1.0,
    1.25,
    1.6
  };

  protected static final int defaultInitialZoomLevel = 8;

  /**
   * Stores the state information for the {@link Zoomer}. This class
   * exists to keep the <code>Zoomer</code> data separate from the
   * <code>Zoomer</code> GUI.
   *
   * <p>Predefined zoom levels are stored in <code>levels</code>. If we are
   * in a predefined zoom level, then <code>custom == -1</code> and
   * <code>levels[cur]</code> is the current zoom factor. If we are in
   * a user-defined zoom level, then <code>custom</code> is the current
   * zoom factor and <code>cur</code> is the greatest value such that
   * {@code custom < level[cur]}}.</p>
   *
   * @author <NAME>
   * @since 3.1.0
   */
{'fraction_non_alphanumeric': 0.10055986218776916, 'fraction_numerical': 0.018626184323858742, 'mean_word_length': 4.674404398289554, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4738736', 'n_tokens_mistral': 2941, 'n_tokens_neox': 2804, 'n_words': 826}