001/*
002 * Copyright 2010-2015 Institut Pasteur.
003 * 
004 * This file is part of Icy.
005 * 
006 * Icy is free software: you can redistribute it and/or modify
007 * it under the terms of the GNU General Public License as published by
008 * the Free Software Foundation, either version 3 of the License, or
009 * (at your option) any later version.
010 * 
011 * Icy is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014 * GNU General Public License for more details.
015 * 
016 * You should have received a copy of the GNU General Public License
017 * along with Icy. If not, see <http://www.gnu.org/licenses/>.
018 */
019package icy.preferences;
020
021/**
022 * @author Stephane
023 */
024public class CanvasPreferences
025{
026    /**
027     * preferences id
028     */
029    private static final String PREF_ID = "canvas";
030
031    /**
032     * id
033     */
034    private static final String ID_FILTERING = "filtering";
035    private static final String ID_INVERT_MOUSEWHEEL_AXIS = "invertMouseWheelAxis";
036    private static final String ID_MOUSEWHEEL_SENSIBILITY = "mouseWheelSensibility";
037
038    /**
039     * preferences
040     */
041    private static XMLPreferences preferences;
042
043    public static void load()
044    {
045        // load preferences
046        preferences = ApplicationPreferences.getPreferences().node(PREF_ID);
047    }
048
049    /**
050     * @return the preferences
051     */
052    public static XMLPreferences getPreferences()
053    {
054        return preferences;
055    }
056
057    public static boolean getFiltering()
058    {
059        return preferences.getBoolean(ID_FILTERING, false);
060    }
061
062    public static void setFiltering(boolean value)
063    {
064        preferences.putBoolean(ID_FILTERING, value);
065    }
066
067    public static boolean getInvertMouseWheelAxis()
068    {
069        return preferences.getBoolean(ID_INVERT_MOUSEWHEEL_AXIS, false);
070    }
071
072    public static void setInvertMouseWheelAxis(boolean value)
073    {
074        preferences.putBoolean(ID_INVERT_MOUSEWHEEL_AXIS, value);
075    }
076
077    /**
078     * Mouse wheel sensitivity (1-10)
079     */
080    public static double getMouseWheelSensitivity()
081    {
082        return preferences.getDouble(ID_MOUSEWHEEL_SENSIBILITY, 5d);
083    }
084
085    public static void setMouseWheelSensitivity(double value)
086    {
087        preferences.putDouble(ID_MOUSEWHEEL_SENSIBILITY, value);
088    }
089
090}