HiRISE

HiRISE.RedMosaic
Class ScaleBar

java.lang.Object
  extended by HiRISE.RedMosaic.ScaleBar

public class ScaleBar
extends Object

Draws a scalebar on an image, saving it as a JPG or PNG (or other supported type). The scalebar will be drawn in the upper right corner, text for the other corners may be passed as input.

Version:
1.9
Author:
guym

Field Summary
static float BEST_COLORBAR_LARGE_PADDING
          This is how far in the colorbar and its annotations will be from the absolute corner of the image.
static float BEST_COLORBAR_PERCENT
          This is the fraction of the image width or height that the colorbar is going to occupy
static float BEST_SCALEBAR_PERCENT
          The best looking scale bars seem to be around 1/11th the image width
static String ID
          CVS ID
static float JPG_COMPRESSION_QUALITY
          A number between zero and one for the jpeg quality
static float MARGIN_PERCENT
          The margin (spacing above and below) will be calculated as this fraction of the width.
static float PADDING_PERCENT
          The padding (space between text and the margin) will be calculated as this fraction of the margin.
static double[] SCALE_MULTIPLIERS
          Fractional scales to try
 
Constructor Summary
ScaleBar()
           
 
Method Summary
static double getBestScaleBar(int pixel_width, double m_per_pixel)
          Get the best scale bar length (in pixels) for an image whose width and scale are specified.
static String getScaleText(double meters)
          Given a length in meters, return a formatted string for that scale in the appropriate units.
static void main(String[] args)
          Process command line arguments
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID

public static final String ID
CVS ID

See Also:
Constant Field Values

JPG_COMPRESSION_QUALITY

public static final float JPG_COMPRESSION_QUALITY
A number between zero and one for the jpeg quality

See Also:
Constant Field Values

BEST_SCALEBAR_PERCENT

public static final float BEST_SCALEBAR_PERCENT
The best looking scale bars seem to be around 1/11th the image width

See Also:
Constant Field Values

MARGIN_PERCENT

public static final float MARGIN_PERCENT
The margin (spacing above and below) will be calculated as this fraction of the width.

See Also:
Constant Field Values

PADDING_PERCENT

public static final float PADDING_PERCENT
The padding (space between text and the margin) will be calculated as this fraction of the margin.

See Also:
Constant Field Values

SCALE_MULTIPLIERS

public static final double[] SCALE_MULTIPLIERS
Fractional scales to try


BEST_COLORBAR_PERCENT

public static final float BEST_COLORBAR_PERCENT
This is the fraction of the image width or height that the colorbar is going to occupy

See Also:
Constant Field Values

BEST_COLORBAR_LARGE_PADDING

public static final float BEST_COLORBAR_LARGE_PADDING
This is how far in the colorbar and its annotations will be from the absolute corner of the image.

See Also:
Constant Field Values
Constructor Detail

ScaleBar

public ScaleBar()
Method Detail

getBestScaleBar

public static double getBestScaleBar(int pixel_width,
                                     double m_per_pixel)
Get the best scale bar length (in pixels) for an image whose width and scale are specified. Try to arrive at a good-sized scale bar for an image. For a 'thumbnail' image 512 pixels wide projected at 10 m/px, this might be a line of 50 pixels = 500 meters. Try different scales, starting at a scalebar length of 1 meter, going up by powers of ten until the scalebar would exceed the image width. Also try half scale to see if that would work better. The function returns the best scale bar length (in pixels) when passed the width in pixels and its scale in meters per pixel.

Parameters:
pixel_width - Width of image in pixels
m_per_pixel - Scale of image, in meters per pixel
Returns:
Best length for a scalebar, in pixels.

getScaleText

public static String getScaleText(double meters)
Given a length in meters, return a formatted string for that scale in the appropriate units.

Parameters:
meters - A scale in meters
Returns:
Text appropriate for the scale

main

public static void main(String[] args)
Process command line arguments

Parameters:
args - -i[nput] file -o[utput] file -s[cale] meters-per-pixel

HiRISE

Copyright (C) Arizona Board of Regents on behalf of the Planetary Image Research Laboratory, Lunar and Planetary Laboratory at the University of Arizona