HiRISE

HiRISE.HiReport.util
Class MapMaker

java.lang.Object
  extended by HiRISE.HiReport.util.MapMaker

public class MapMaker
extends Object

MapMaker is a simple command-line utility that takes a tab-delimited input and plots it up on a lat-lon grid. Each row corresponds to a single plotted point. If the input switch -180 is provided, the map is drawn from -180 to 180, otherwise from 0 to 360. A background map can be provided with the -bg option. Note that the hemispheres must match the type of longitude being drawn as a consequence of providing or not providing the -L180 switch. If the -in option is provided, the input is assumed to be a file in the tab delimited format, otherwise standard input is used. If the -out option is provided, the output will be written in PNG format to the file indicated. The default width and height can be overridden with -W and -H options. If -out is not provided, the output is rendered in a GUI component, which can be rescaled to any desired size (and saved to a file or printed via the menu obtained by right-clicking). [DONE] complete multiple data series support [DONE] options to set the paint for each series, either a color (probably a hex value, but possibly a string?) or paths to files, which would be java.awt.TexturePaint bitmaps [loaded by javax.imageio.ImageIO.read()?] [DONE] switch to show legend [DONE] move everything except the arg parsing and Frame creation from the main method into java instance methods of the MapMaker class, so it can be easily re-used from other code + analyze performance when adding many points. An optimization that may be needed is a custom data series model that bins the data, if the input lat/lon is much more precise than the output resolution (e.g. points just end up on top of each other) [DONE] a small Swing UI interface, possibly to include drag-n-drop


Field Summary
protected  XYSeriesCollection collection
          the collection to which series data will be added
protected  boolean debug
          If true, enable debug output
protected static String DEFAULT_CATEGORY
          Category name for values, if none is provided
protected static int DEFAULT_HEIGHT
          Default output height in pixels
protected static int DEFAULT_WIDTH
          Default output width in pixels
protected  Dimension gridSize
          rows, cols for multiple plots
protected  int height
          Output height in pixels
static String ID
          CVS ID
protected  Image image
          background image to lay the chart over
protected  boolean l180
          should -180 to 180 longitude be used instead of 0 to 360?
protected  boolean legend
          Should a legend be shown?
protected  boolean multiple
          If true, separate plots for each series
protected  String title
          title for the plot, null for none
protected  int width
          Output width in pixels
 
Constructor Summary
MapMaker()
           
 
Method Summary
 JFreeChart createChart()
          Create a chart object, using the data collected and the user's options
 JFreeChart createChart(XYSeriesCollection data, String title, Image image, boolean legend)
          Create a chart for a combined or multiple plot.
 BufferedImage createSeparateCharts()
          Create the grid of plots, rendered into a BufferedImage.
 Dimension getBestGridSize()
          Get the grid size given the number of series in the collection.
 Dimension getGridSize()
          Get the grid-size for multi-map display
static void main(String[] args)
          Command-line interface
 void parseData(File data)
          Parse the data in a file
 void parseText(InputStream in)
          Parses the data the user provides via a specified input stream
 void parseXls(File xls)
          Parse spreadsheet data
 void saveChartToFile(File output)
          Write the plot to a PNG file
 void setDebug(boolean debug)
          Enable debugging.
 void setGridSize(Dimension gridSize)
          Set the grid-size for multi-map display
 void setHeight(int height)
          Set the height for output
 void setImage(Image image)
          Set a background image.
 void setL180(boolean l180)
          If true, show west longitude from -180 to 0, otherwise, show as 180 to 360.
 void setLegend(boolean legend)
          If true, show a legend
 void setMarker(BufferedImage marker)
          Set the marker (plot symbol)
 void setMultiple(boolean multiple)
          If true, show multiple plots.
 void setTitle(String title)
          Set the plot title.
 void setWidth(int width)
          Set the width for output
 
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

DEFAULT_WIDTH

protected static final int DEFAULT_WIDTH
Default output width in pixels

See Also:
Constant Field Values

DEFAULT_HEIGHT

protected static final int DEFAULT_HEIGHT
Default output height in pixels

See Also:
Constant Field Values

DEFAULT_CATEGORY

protected static final String DEFAULT_CATEGORY
Category name for values, if none is provided

See Also:
Constant Field Values

collection

protected XYSeriesCollection collection
the collection to which series data will be added


l180

protected boolean l180
should -180 to 180 longitude be used instead of 0 to 360?


legend

protected boolean legend
Should a legend be shown?


debug

protected boolean debug
If true, enable debug output


multiple

protected boolean multiple
If true, separate plots for each series


width

protected int width
Output width in pixels


height

protected int height
Output height in pixels


image

protected Image image
background image to lay the chart over


title

protected String title
title for the plot, null for none


gridSize

protected Dimension gridSize
rows, cols for multiple plots

Constructor Detail

MapMaker

public MapMaker()
Method Detail

setDebug

public void setDebug(boolean debug)
Enable debugging. This will trigger halting on first data parsing error encountered and print stack traces.

Parameters:
debug - true to debug

setMarker

public void setMarker(BufferedImage marker)
Set the marker (plot symbol)

Parameters:
marker - image data

getBestGridSize

public Dimension getBestGridSize()
Get the grid size given the number of series in the collection.

Returns:
(rows, cols)

setGridSize

public void setGridSize(Dimension gridSize)
Set the grid-size for multi-map display

Parameters:
gridSize - grid rows and cols

getGridSize

public Dimension getGridSize()
Get the grid-size for multi-map display

Returns:
grid rows and cols

setL180

public void setL180(boolean l180)
If true, show west longitude from -180 to 0, otherwise, show as 180 to 360.

Parameters:
l180 - to show west longitude as negative

setLegend

public void setLegend(boolean legend)
If true, show a legend

Parameters:
legend - Enable legend

setMultiple

public void setMultiple(boolean multiple)
If true, show multiple plots.

Parameters:
multiple - Multiple (separate) plots

setImage

public void setImage(Image image)
Set a background image.

Parameters:
image - the image

setWidth

public void setWidth(int width)
Set the width for output

Parameters:
width - pixels

setHeight

public void setHeight(int height)
Set the height for output

Parameters:
height - pPixels

setTitle

public void setTitle(String title)
Set the plot title.

Parameters:
title - text

parseData

public void parseData(File data)
               throws IOException
Parse the data in a file

Parameters:
data - the file
Throws:
IOException - File could not be parsed

parseXls

public void parseXls(File xls)
              throws IOException
Parse spreadsheet data

Parameters:
xls - the spreadsheet
Throws:
IOException - File could not be parsed

parseText

public void parseText(InputStream in)
               throws IOException
Parses the data the user provides via a specified input stream

Parameters:
in - The data stream
Throws:
IOException - Failure to read data

createChart

public JFreeChart createChart()
Create a chart object, using the data collected and the user's options

Returns:
The chart

createChart

public JFreeChart createChart(XYSeriesCollection data,
                              String title,
                              Image image,
                              boolean legend)
Create a chart for a combined or multiple plot.

Parameters:
data - The data collection to use
title - Title for plot
image - Background image
legend - True to show legend
Returns:
The chart

createSeparateCharts

public BufferedImage createSeparateCharts()
Create the grid of plots, rendered into a BufferedImage.

Returns:
Plot grid

saveChartToFile

public void saveChartToFile(File output)
                     throws IOException
Write the plot to a PNG file

Parameters:
output - The file
Throws:
IOException - Failure to write plot

main

public static void main(String[] args)
Command-line interface

Parameters:
args - Input

HiRISE

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