/*
 * Copyright (C) 2013 Snowsun <http://wyrez.org> and contributors
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.wyrez.shootingstars.helper;

import java.awt.DisplayMode;
import java.awt.GraphicsEnvironment;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 *
 * @author Snowsun
 */
public class DisplayHelper {

    public static List<String> getResolutions() {
        List<String> resolutions = new ArrayList<String>();

        for (DisplayMode mode : GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayModes()) {
            String resolution = mode.getWidth() + " x " + mode.getHeight();
            if (!resolutions.contains(resolution)) {
                resolutions.add(resolution);
            }
        }
        Collections.sort(resolutions);
        return resolutions;
    }

    public static List<String> getFrequencys() {
        List<String> frequencys = new ArrayList<String>();
        
        for (DisplayMode mode : GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayModes()) {
            if (!frequencys.contains(String.valueOf(mode.getRefreshRate()))) {
                frequencys.add(String.valueOf(mode.getRefreshRate()));
            }
        }
        Collections.sort(frequencys);
        return frequencys;
    }

    public static List<String> getDepthBits() {
        List<String> bitRates = new ArrayList<String>();
        for (DisplayMode mode : GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayModes()) {
            if (!bitRates.contains(String.valueOf(mode.getBitDepth()))) {
                bitRates.add(String.valueOf(mode.getBitDepth()));
            }
        }
        Collections.sort(bitRates);
        return bitRates;
    }
}
