|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectus.zuercher.gpx2map.MainArgumentParser
public class MainArgumentParser
MainArgumentParser uses "argslib" to configure and parse Gpx2Map's command line arguments.
Nested Class Summary | |
---|---|
private static class |
MainArgumentParser.Exit
|
class |
MainArgumentParser.HelperTarget
HelperTarget accepts MapSource name information from an
ArgumentParser . |
Field Summary | |
---|---|
private static String |
BOUNDING_ARG
Argument name. |
private us.zuercher.argslib.Argument |
boundingArg
Argument. |
(package private) static us.zuercher.argslib.ArgumentChoice |
boundingByAll
Argument choice. |
(package private) static us.zuercher.argslib.ArgumentChoice |
boundingByCoords
Argument choice. |
(package private) static us.zuercher.argslib.ArgumentChoice |
boundingByRoutes
Argument choice. |
(package private) static us.zuercher.argslib.ArgumentChoice |
boundingByTracks
Argument choice. |
(package private) static us.zuercher.argslib.ArgumentChoice |
boundingByWayPoints
Argument choice. |
private static String |
CACHE_DIR_ARG
Argument name. |
private us.zuercher.argslib.Argument |
cacheDirArg
Argument. |
private static List<us.zuercher.argslib.ArgumentChoice> |
colorChoices
Available color choices. |
static Color |
DEFAULT_COLOR
Default color. |
static boolean |
DEFAULT_JOIN_TRACK_SEGMENTS
Default join track segments flag. |
static String |
DEFAULT_MAP_SOURCE
Default map source name. |
static String |
DEFAULT_OUTPUT
Default output file. |
static boolean |
DEFAULT_ROUTE_LABELING
Default route labeling flag. |
static MarkerStyle |
DEFAULT_STYLE
Default marker style. |
static int |
DEFAULT_STYLE_RADIUS
Default marker style radius. |
static boolean |
DEFAULT_TRACK_LABELING
Default track labeling flag. |
private static String |
FONT_NAME_ARG
Argument name. |
private static String |
FONT_SIZE_ARG
Argument name. |
private us.zuercher.argslib.Argument |
fontNameArg
Argument. |
private us.zuercher.argslib.Argument |
fontSizeArg
Argument. |
private static String |
GPSDATA_ARG
Argument name. |
private static String |
HELP_ARG
Argument name. |
private static String |
HELP_USAGE
Help usage detail. |
private us.zuercher.argslib.Argument |
helpArg
Argument. |
private static String |
IGNORE_ROUTES_ARG
Argument name. |
private static String |
IGNORE_TRACKS_ARG
Argument name. |
private static String |
IGNORE_WAYPOINTS_ARG
Argument name. |
private us.zuercher.argslib.Argument |
ignoreRoutesArg
Argument. |
private us.zuercher.argslib.Argument |
ignoreTracksArg
Argument. |
private us.zuercher.argslib.Argument |
ignoreWayPointsArg
Argument. |
private static String |
JOIN_TRACK_SEGMENTS_ARG
Argument name. |
private us.zuercher.argslib.Argument |
joinTrackSegmentsArg
Argument. |
private String |
locale
If set, the GUI locale to display. |
private static String |
LOCALE_ARG
Argument name. |
private us.zuercher.argslib.Argument |
localeArg
Argument. |
private Gpx2Map |
main
Map plotter object. |
(package private) static String |
MAP_PROPERTY_ARG_PREFIX
Prefix for map source property arguments. |
private static String |
MAP_SOURCE_ARG
Argument name. |
private static String |
MAP_SOURCE_DESC
Map source description. |
private static String |
MAP_SOURCE_USAGE
Map source usage detail. |
private static String |
MARGIN_ARG
Argument name. |
private us.zuercher.argslib.Argument |
marginArg
Argument. |
(package private) static us.zuercher.argslib.ArgumentChoice |
marginMetersChoice
Argument choice. |
(package private) static us.zuercher.argslib.ArgumentChoice |
marginPixelsChoice
Argument choice. |
private static String |
OUTPUT_ARG
Argument name. |
private us.zuercher.argslib.Argument |
outputArg
Argument. |
private static String |
PRINT_COLORS_ARG
Argument name. |
private static String |
PRINT_STYLES_ARG
Argument name. |
private boolean |
printColors
If true, print colors. |
private us.zuercher.argslib.Argument |
printColorsArg
Argument. |
private boolean |
printHelp
If true, print help. |
private boolean |
printStyles
If true, print styles. |
private us.zuercher.argslib.Argument |
printStylesArg
Argument. |
private static String |
ROUTE_COLOR_ARG
Argument name. |
private static String |
ROUTE_LABEL_ARG
Argument name. |
private us.zuercher.argslib.Argument |
routeColorArg
Argument. |
private us.zuercher.argslib.Argument |
routeLabelArg
Argument. |
private static String |
ROUTEPOINT_RADIUS_ARG
Argument name. |
private static String |
ROUTEPOINT_STYLE_ARG
Argument name. |
private us.zuercher.argslib.Argument |
routePointRadiusArg
Argument. |
private us.zuercher.argslib.Argument |
routePointStyleArg
Argument. |
private static List<us.zuercher.argslib.ArgumentChoice> |
sourceChoices
Available map source choices. |
private static String |
STYLE_VALUE_FILE
Prefix for "file" marker style arguments. |
private static List<us.zuercher.argslib.ArgumentChoice> |
styleChoices
Available marker style choices. |
private static String |
TRACK_COLOR_ARG
Argument name. |
private static String |
TRACK_LABEL_ARG
Argument name. |
private us.zuercher.argslib.Argument |
trackColorArg
Argument. |
private us.zuercher.argslib.Argument |
trackLabelArg
Argument. |
private static String |
TRACKPOINT_RADIUS_ARG
Argument name. |
private static String |
TRACKPOINT_STYLE_ARG
Argument name. |
private us.zuercher.argslib.Argument |
trackPointRadiusArg
Argument. |
private us.zuercher.argslib.Argument |
trackPointStyleArg
Argument. |
private static String |
WAYPOINT_COLOR_ARG
Argument name. |
private static String |
WAYPOINT_RADIUS_ARG
Argument name. |
private static String |
WAYPOINT_STYLE_ARG
Argument name. |
private us.zuercher.argslib.Argument |
wayPointColorArg
Argument. |
private us.zuercher.argslib.Argument |
wayPointRadiusArg
Argument. |
private us.zuercher.argslib.Argument |
wayPointStyleArg
Argument. |
Constructor Summary | |
---|---|
MainArgumentParser(Gpx2Map main)
Constructs a new MainArgumentParser with the given Gpx2Map . |
Method Summary | |
---|---|
void |
addGpsdata(String gpsDataArg)
Mutator called by ArgumentParser for the GPX data file
Argument . |
private us.zuercher.argslib.ArgumentSetParser |
configureArgumentParser(String... args)
Configure an ArgumentSetParser for the given arguments. |
private Color |
getColor(String colorName,
int error)
Look up the given color name. |
private static List<us.zuercher.argslib.ArgumentChoice> |
getColorChoices()
Creates a List or ArgumentChoice objects for use in
initializing Color -based Arguments . |
private static List<us.zuercher.argslib.ArgumentChoice> |
getSourceChoices()
Creates a List or ArgumentChoice objects for use in
initializing the MapSource selection Argument . |
private MarkerStyle |
getStyle(String styleName,
int errorStyle)
Look up the given style name. |
private static List<us.zuercher.argslib.ArgumentChoice> |
getStyleChoices()
Creates a List or ArgumentChoice objects for use in
initializing style -based Arguments . |
int |
parseArgs(String... args)
Parse the given arguments and apply them to the Gpx2Map object
given in the constructor for this instance. |
private void |
printColors()
Prints the available Colors to System.out . |
void |
printHelp(String... args)
Output help information for the given arguments. |
private void |
printStyles()
Prints the available styles to System.out . |
private void |
quit(int resultCode)
Force parseArgs(String[]) to return with the given
result code. |
void |
set(String mapSourceProperty,
String value)
Mutator called by ArgumentParser for the MapSource
properties Arguments . |
void |
setBounding(String choice)
Mutator called by ArgumentParser for the
boundingArg Argument . |
void |
setCacheDir(String cacheDir)
Mutator called by ArgumentParser for the cacheDirArg
Argument . |
void |
setFontName(String fontName)
Mutator call by ArgumentParser for the fontNameArg
Argument . |
void |
setFontSize(float size)
Mutator call by ArgumentParser for the fontSizeArg
Argument . |
void |
setHelp()
Mutator called by ArgumentParser via helpArg . |
void |
setIgnoreRoutes()
Mutator called by ArgumentParser for the
ignoreRoutesArg Argument . |
void |
setIgnoreTracks()
Mutator called by ArgumentParser for the
ignoreTracksArg Argument . |
void |
setIgnoreWaypoints()
Mutator called by ArgumentParser for the
ignoreWayPointsArg Argument . |
void |
setJoinTrackSegments(boolean join)
Mutator call by ArgumentParser for the
joinTrackSegmentsArg Argument . |
void |
setLocale(String locale)
Mutator called by ArgumentSetParser via localeArg . |
void |
setMapSource(String mapSourceName)
Mutator called by ArgumentParser for the MapSource name
Argument . |
void |
setMargin(String margin)
Mutator called by ArgumentParser for the marginArg
Argument . |
void |
setOutput(String output)
Mutator called by ArgumentParser for the outputArg
Argument . |
void |
setPrintColors()
Mutator called by ArgumentParser via printColorsArg . |
void |
setPrintStyles()
Mutator called by ArgumentParser via printStylesArg . |
void |
setRouteColor(String color)
Mutator called by ArgumentParser for the routeColorArg
Argument . |
void |
setRouteLabel(boolean label)
Mutator called by ArgumentParser for the routeLabelArg
Argument . |
void |
setRoutepointRadius(int radius)
Mutator call by ArgumentParser for the
routePointRadiusArg Argument . |
void |
setRoutepointStyle(String style)
Mutator called by ArgumentParser for the
routePointStyleArg Argument . |
void |
setTrackColor(String color)
Mutator called by ArgumentParser for the trackColorArg
Argument . |
void |
setTrackLabel(boolean label)
Mutator called by ArgumentParser for the trackLabelArg
Argument . |
void |
setTrackpointRadius(int radius)
Mutator call by ArgumentParser for the
trackPointRadiusArg Argument . |
void |
setTrackpointStyle(String style)
Mutator called by ArgumentParser for the
trackPointStyleArg Argument . |
void |
setWaypointColor(String color)
Mutator called by ArgumentParser for the
wayPointColorArg Argument . |
void |
setWaypointRadius(int radius)
Mutator call by ArgumentParser for the
wayPointRadiusArg Argument . |
void |
setWaypointStyle(String style)
Mutator called by ArgumentParser for the
wayPointStyleArg Argument . |
private String |
toHexString(int value,
int minDigits)
Helper method that converts an integer to a hexadecimal string with at least the given number of digits. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String DEFAULT_MAP_SOURCE
public static final Color DEFAULT_COLOR
public static final MarkerStyle DEFAULT_STYLE
public static final String DEFAULT_OUTPUT
public static final boolean DEFAULT_TRACK_LABELING
public static final boolean DEFAULT_ROUTE_LABELING
public static final int DEFAULT_STYLE_RADIUS
public static final boolean DEFAULT_JOIN_TRACK_SEGMENTS
private static final String STYLE_VALUE_FILE
private static final String HELP_ARG
private static final String PRINT_STYLES_ARG
private static final String PRINT_COLORS_ARG
private static final String LOCALE_ARG
private static final String MAP_SOURCE_ARG
private static final String CACHE_DIR_ARG
static final String MAP_PROPERTY_ARG_PREFIX
private static final String OUTPUT_ARG
private static final String GPSDATA_ARG
private static final String IGNORE_TRACKS_ARG
private static final String IGNORE_WAYPOINTS_ARG
private static final String IGNORE_ROUTES_ARG
private static final String TRACK_COLOR_ARG
private static final String WAYPOINT_COLOR_ARG
private static final String ROUTE_COLOR_ARG
private static final String TRACKPOINT_STYLE_ARG
private static final String TRACKPOINT_RADIUS_ARG
private static final String WAYPOINT_STYLE_ARG
private static final String WAYPOINT_RADIUS_ARG
private static final String ROUTEPOINT_STYLE_ARG
private static final String ROUTEPOINT_RADIUS_ARG
private static final String TRACK_LABEL_ARG
private static final String ROUTE_LABEL_ARG
private static final String FONT_SIZE_ARG
private static final String FONT_NAME_ARG
private static final String BOUNDING_ARG
private static final String MARGIN_ARG
private static final String JOIN_TRACK_SEGMENTS_ARG
private static final String MAP_SOURCE_USAGE
private static final String MAP_SOURCE_DESC
private static final String HELP_USAGE
private static List<us.zuercher.argslib.ArgumentChoice> colorChoices
private static List<us.zuercher.argslib.ArgumentChoice> styleChoices
private static List<us.zuercher.argslib.ArgumentChoice> sourceChoices
private us.zuercher.argslib.Argument helpArg
private us.zuercher.argslib.Argument printStylesArg
private us.zuercher.argslib.Argument printColorsArg
private us.zuercher.argslib.Argument localeArg
private us.zuercher.argslib.Argument outputArg
private us.zuercher.argslib.Argument ignoreWayPointsArg
private us.zuercher.argslib.Argument ignoreTracksArg
private us.zuercher.argslib.Argument ignoreRoutesArg
private us.zuercher.argslib.Argument cacheDirArg
static us.zuercher.argslib.ArgumentChoice boundingByTracks
static us.zuercher.argslib.ArgumentChoice boundingByWayPoints
static us.zuercher.argslib.ArgumentChoice boundingByRoutes
static us.zuercher.argslib.ArgumentChoice boundingByCoords
static us.zuercher.argslib.ArgumentChoice boundingByAll
private us.zuercher.argslib.Argument boundingArg
static us.zuercher.argslib.ArgumentChoice marginMetersChoice
static us.zuercher.argslib.ArgumentChoice marginPixelsChoice
private us.zuercher.argslib.Argument marginArg
private us.zuercher.argslib.Argument trackColorArg
private us.zuercher.argslib.Argument trackLabelArg
private us.zuercher.argslib.Argument trackPointStyleArg
private us.zuercher.argslib.Argument trackPointRadiusArg
private us.zuercher.argslib.Argument wayPointColorArg
private us.zuercher.argslib.Argument wayPointStyleArg
private us.zuercher.argslib.Argument wayPointRadiusArg
private us.zuercher.argslib.Argument routeColorArg
private us.zuercher.argslib.Argument routeLabelArg
private us.zuercher.argslib.Argument routePointStyleArg
private us.zuercher.argslib.Argument routePointRadiusArg
private us.zuercher.argslib.Argument fontNameArg
private us.zuercher.argslib.Argument fontSizeArg
private us.zuercher.argslib.Argument joinTrackSegmentsArg
private final Gpx2Map main
private boolean printHelp
private boolean printColors
private boolean printStyles
private String locale
Constructor Detail |
---|
public MainArgumentParser(Gpx2Map main)
Gpx2Map
.
main
- a Gpx2MapMethod Detail |
---|
public int parseArgs(String... args)
Gpx2Map
object
given in the constructor for this instance. Arguments may be parsed
multiple times. See configureArgumentParser(String[])
and
know that this method itself parses arguments twice. First, arguments
are parsed with a this class as a target to determine if the user
requested help information, the printing of styles, or the printing of
colors. If none of those is true, arguments are parsed again with the
Gpx2Map
object given in the constructor as the argument parser
target.
args
- command-line arguments
public void printHelp(String... args)
MapSource
in order to provide information about map source
properties.
args
- command-line arguments.private us.zuercher.argslib.ArgumentSetParser configureArgumentParser(String... args)
ArgumentSetParser
for the given arguments. This
method parses arguments the given arguments. It uses a
dummy target
to determine the requested map source
name, configures that MapSource
and then queries it for
property information. Then it uses that information to construct
another ArgumentSetParser will all available arguments.
args
- command-line arguments
private void printColors()
Colors
to System.out
.
private void printStyles()
styles
to System.out
.
private String toHexString(int value, int minDigits)
minDigits
digits.
value
- integer to convertminDigits
- minimum number of hex digits
value
with at least
minDigits
digits.private static List<us.zuercher.argslib.ArgumentChoice> getStyleChoices()
List
or ArgumentChoice
objects for use in
initializing style
-based Arguments
.
List
or ArgumentChoice
objectsprivate static List<us.zuercher.argslib.ArgumentChoice> getColorChoices()
List
or ArgumentChoice
objects for use in
initializing Color
-based Arguments
.
List
or ArgumentChoice
objectsprivate static List<us.zuercher.argslib.ArgumentChoice> getSourceChoices()
List
or ArgumentChoice
objects for use in
initializing the MapSource
selection Argument
.
List
or ArgumentChoice
objectsprivate void quit(int resultCode)
parseArgs(String[])
to return with the given
result code.
resultCode
- error result codeprivate Color getColor(String colorName, int error)
quits
with the given result code.
colorName
- color nameerror
- error result code
colorName
MainArgumentParser.Exit
- if there's an error.private MarkerStyle getStyle(String styleName, int errorStyle)
Style
cannot be found,
quits
with the given result code.
styleName
- color nameerrorStyle
- error result code
MarkerStyle
specified by styleName
MainArgumentParser.Exit
- if there's an error.
RuntimeException
- if the given style name is not in
Style.values()
(meaning you probably
added a non-Style MakerStyle implementation,
provided an ArgumentChoice for it, but aren't
detecting it here.)public void setLocale(String locale)
ArgumentSetParser
via localeArg
.
locale
- the locale to display in the GUIpublic void setHelp()
ArgumentParser
via helpArg
.
public void setPrintColors()
ArgumentParser
via printColorsArg
.
public void setPrintStyles()
ArgumentParser
via printStylesArg
.
public void setMapSource(String mapSourceName)
ArgumentParser
for the MapSource
name
Argument
.
mapSourceName
- the requested map source namepublic void set(String mapSourceProperty, String value)
ArgumentParser
for the MapSource
properties Arguments
.
mapSourceProperty
- the requested map source propertyvalue
- the value of the propertypublic void addGpsdata(String gpsDataArg)
ArgumentParser
for the GPX data file
Argument
.
gpsDataArg
- the requested GPX filenamepublic void setOutput(String output)
ArgumentParser
for the outputArg
Argument
.
output
- the requested output filenamepublic void setCacheDir(String cacheDir)
ArgumentParser
for the cacheDirArg
Argument
.
cacheDir
- the requested cache directory's namepublic void setIgnoreTracks()
ArgumentParser
for the
ignoreTracksArg
Argument
.
public void setIgnoreWaypoints()
ArgumentParser
for the
ignoreWayPointsArg
Argument
.
public void setIgnoreRoutes()
ArgumentParser
for the
ignoreRoutesArg
Argument
.
public void setBounding(String choice)
ArgumentParser
for the
boundingArg
Argument
.
choice
- the user's bounding choice
MainArgumentParser.Exit
- if bounding coordinates for boundingByCoords
are invalid
RuntimeException
- if there's an internal error (meaning that
ArgumentParser felt the given choice was
valid, but this method doesn't understand it:
e.g., you added a choice and left it out of
this method's implementation.)public void setMargin(String margin)
ArgumentParser
for the marginArg
Argument
.
margin
- the margin choicepublic void setTrackColor(String color)
ArgumentParser
for the trackColorArg
Argument
.
color
- the track color name
MainArgumentParser.Exit
- if the color name cannot be converted to a Color
.public void setTrackLabel(boolean label)
ArgumentParser
for the trackLabelArg
Argument
.
label
- the value of the argumentpublic void setTrackpointStyle(String style)
ArgumentParser
for the
trackPointStyleArg
Argument
.
style
- the name of the style
MainArgumentParser.Exit
- if the style name cannot be converted to a
MarkerStyle
.
RuntimeException
- see getStyle(String, int)
public void setTrackpointRadius(int radius)
ArgumentParser
for the
trackPointRadiusArg
Argument
.
radius
- the style radius (size)public void setJoinTrackSegments(boolean join)
ArgumentParser
for the
joinTrackSegmentsArg
Argument
.
join
- the join track segments flag valuepublic void setWaypointColor(String color)
ArgumentParser
for the
wayPointColorArg
Argument
.
color
- the way-point color name
MainArgumentParser.Exit
- if the color name cannot be converted to a Color
.public void setWaypointStyle(String style)
ArgumentParser
for the
wayPointStyleArg
Argument
.
style
- the name of the style
MainArgumentParser.Exit
- if the style name cannot be converted to a
MarkerStyle
.
RuntimeException
- see getStyle(String, int)
public void setWaypointRadius(int radius)
ArgumentParser
for the
wayPointRadiusArg
Argument
.
radius
- the style radius (size)public void setRouteColor(String color)
ArgumentParser
for the routeColorArg
Argument
.
color
- the route color name
MainArgumentParser.Exit
- if the color name cannot be converted to a Color
.public void setRouteLabel(boolean label)
ArgumentParser
for the routeLabelArg
Argument
.
label
- the value of the argumentpublic void setRoutepointStyle(String style)
ArgumentParser
for the
routePointStyleArg
Argument
.
style
- the name of the style
MainArgumentParser.Exit
- if the style name cannot be converted to a
MarkerStyle
.
RuntimeException
- see getStyle(String, int)
public void setRoutepointRadius(int radius)
ArgumentParser
for the
routePointRadiusArg
Argument
.
radius
- the style radius (size)public void setFontName(String fontName)
ArgumentParser
for the fontNameArg
Argument
.
fontName
- the font name to usepublic void setFontSize(float size)
ArgumentParser
for the fontSizeArg
Argument
.
size
- the font size, in points
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |