Java Pixel Convert To pixelsToYears(double dim, int chartWidth, int firstChartYear, int lastChartYear)

Here you can find the source of pixelsToYears(double dim, int chartWidth, int firstChartYear, int lastChartYear)

Description

Performs the inverse of yearsToPixels.

License

Open Source License

Parameter

Parameter Description
dim a parameter
chartWidth a parameter
firstChartYear a parameter
lastChartYear a parameter

Return

a converted value

Declaration

protected static double pixelsToYears(double dim, int chartWidth,
        int firstChartYear, int lastChartYear) 

Method Source Code

//package com.java2s;
/**************************************************************************************************
 * Fire History Analysis and Exploration System (FHAES), Copyright (C) 2015
 * //from   w  w  w. j  a  v a  2s  . c  o m
 * Contributors: Joshua Brogan and Peter Brewer
 * 
 *       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/>.
 * 
 *************************************************************************************************/

public class Main {
    /**
     * Performs the inverse of yearsToPixels.
     * 
     * @param dim
     * @param chartWidth
     * @param firstChartYear
     * @param lastChartYear
     * @return a converted value
     */
    protected static double pixelsToYears(double dim, int chartWidth,
            int firstChartYear, int lastChartYear) {

        return dim * 1
                / yearsToPixels(chartWidth, firstChartYear, lastChartYear);
    }

    /**
     * Convenience function to get the scaling factor.
     * 
     * @param chartWidth
     * @param firstChartYear
     * @param lastChartYear
     * @return a converted value
     */
    protected static double pixelsToYears(int chartWidth,
            int firstChartYear, int lastChartYear) {

        return pixelsToYears(1.0, chartWidth, firstChartYear, lastChartYear);
    }

    /**
     * Converts dim from years to pixels based off of the chart width and how many years are in the reader.
     * 
     * @param dim
     * @param chartWidth
     * @param firstChartYear
     * @param lastChartYear
     * @return a converted value
     */
    protected static double yearsToPixels(double dim, int chartWidth,
            int firstChartYear, int lastChartYear) {

        return dim * chartWidth / (lastChartYear - firstChartYear);
    }

    /**
     * Convenience function to get the scaling factor.
     * 
     * @param chartWidth
     * @param firstChartYear
     * @param lastChartYear
     * @return a converted value
     */
    protected static double yearsToPixels(int chartWidth,
            int firstChartYear, int lastChartYear) {

        return yearsToPixels(1.0, chartWidth, firstChartYear, lastChartYear);
    }
}

Related

  1. pixels2Molecules(float[] pixels, int width, int height)
  2. pixelsToCm(float pixels)
  3. pixelsToInches(int sizeInPixels, int dpi)
  4. pixelsToPoint(int pixels, int dpi)
  5. PixelsToPoints(float value, int dpi)
  6. pixelToEmu(int pixels, int dpi)
  7. pixelToRGB(int pixel, int[] prgb)
  8. pixelXYToTileXY(int pixelX, int pixelY)