Skip to content

Commit

Permalink
bug fixes and improvements
Browse files Browse the repository at this point in the history
Signed-off-by: Mattias Andrée <maandree@operamail.com>
  • Loading branch information
maandree committed Apr 5, 2013
1 parent 20d0139 commit b54b086
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 2 deletions.
40 changes: 39 additions & 1 deletion src/se/kth/maandree/utilsay/Common.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ else if (character == Pony.Cell.PIXELS)
pony.height += 1 + space;
y += 1 + space;
if (y > x)
for (int i = 0, my = y + 1, mw = w + 1, h = pony.height; i <= h; i++)
for (int i = 0, my = y + 1, mw = w + 1, h = pony.height; i < h; i++)
{ System.arraycopy(pony.matrix[i], 0, pony.matrix[i] = new Pony.Cell[y], 0, w);
System.arraycopy(pony.metamatrix[i], 0, pony.metamatrix[i] = new Pony.Meta[my][], 0, mw);
}
Expand Down Expand Up @@ -379,6 +379,25 @@ public static double parseDouble(String value)
}
}

/**
* Parse double value
*
* @param value String representation
* @param defaultValue Default value that will be used if that string starts with a ‘y’ or ‘Y’
* @return Raw representation, -1 if not a number
*/
public static double parseDouble(String value, double defaultValue)
{
if (value.startsWith("y") || value.startsWith("Y"))
return defaultValue;
try
{ return Double.parseDouble(value);
}
catch (Throwable err)
{ return -1.0;
}
}

/**
* Parse integer value
*
Expand All @@ -395,5 +414,24 @@ public static int parseInteger(String value)
}
}

/**
* Parse integer value
*
* @param value String representation
* @param defaultValue Default value that will be used if that string starts with a ‘y’ or ‘Y’
* @return Raw representation, -1 if not an integer
*/
public static int parseInteger(String value, int defaultValue)
{
if (value.startsWith("y") || value.startsWith("Y"))
return defaultValue;
try
{ return Integer.parseInt(value);
}
catch (Throwable err)
{ return -1;
}
}

}

29 changes: 28 additions & 1 deletion util-say.texinfo
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ Fix the number emptying columns at the left side of the pony, if the value
cannot be parsed as a non-negative integer, for example @code{-}, the margin
will not be modified from the original image. This options is import
supported in @option{--export}.
Use a value starting with a @code{y} or @code{Y} make the program use a
default value.

@item @option{--right} (export)
@opindex @option{right}
Expand All @@ -285,6 +287,9 @@ cannot be parsed as a non-negative integer, for example @code{-}, the margin
will not be modified from the original image. This options is import
supported in @option{--export}.

Use a value starting with a @code{y} or @code{Y} make the program use a
default value.

@item @option{--top} (export)
@opindex @option{top}
@cindex margins
Expand All @@ -293,6 +298,9 @@ be parsed as a non-negative integer, for example @code{-}, the margin will
not be modified from the original image. This options is import supported
in @option{--export}.

Use a value starting with a @code{y} or @code{Y} make the program use a
default value.

@item @option{--bottom} (export)
@opindex @option{bottom}
@cindex margins
Expand All @@ -301,11 +309,15 @@ be parsed as a non-negative integer, for example @code{-}, the margin will
not be modified from the original image. This options is import supported
in @option{--export}.

Use a value starting with a @code{y} or @code{Y} make the program use a
default value.

@item @option{--balloon} (export/import)
@opindex @option{balloon}
@cindex balloon, insert
This specifies whether to insert a balloon and its link at the top left of
the image. Use a value starting with a @code{y} or @code{Y} to enable this.
the image. Specift the number of lines between the balloon and the pony or
a value starting with a @code{y} or @code{Y} for a default value.

@item @option{--platform} (export/import)
@opindex @option{platform}
Expand Down Expand Up @@ -501,6 +513,9 @@ cannot be parsed as a non-negative integer, for example @code{-}, the margin
will not be modified from the original image. This options is import supported
in @option{--export}.

Use a value starting with a @code{y} or @code{Y} make the program use a
default value.

@item @option{--right} (export)
@opindex @option{right}
@cindex margins
Expand All @@ -509,6 +524,9 @@ cannot be parsed as a non-negative integer, for example @code{-}, the margin
will not be modified from the original image. This options is import supported
in @option{--export}.

Use a value starting with a @code{y} or @code{Y} make the program use a
default value.

@item @option{--top} (export/import)
@opindex @option{top}
@cindex margins
Expand All @@ -518,6 +536,9 @@ not be modified from the original image. However, in @option{--import}
this value must be a non-negative integer, and is the number of additional
lines between the pony and the balloon. Defaults to 3 in @option{--import}.

Use a value starting with a @code{y} or @code{Y} make the program use a
default value.

@item @option{--bottom} (export)
@opindex @option{bottom}
@cindex margins
Expand All @@ -526,6 +547,9 @@ be parsed as a non-negative integer, for example @code{-}, the margin will
not be modified from the original image. This options is import supported
in @option{--export}.

Use a value starting with a @code{y} or @code{Y} make the program use a
default value.

@item @option{--magnified} (export/import)
@opindex @option{magnified}
@cindex scale up
Expand All @@ -538,6 +562,9 @@ In @option{--import} it means that the imported image has that magnification
and the avarage pixel value will be used for the created pony. The value
must be a positive integer.

Use a value starting with a @code{y} or @code{Y} make the program use a
default value.

@item @option{--encoded} (export/import)
@opindex @option{encoded}
@cindex balloon, encode
Expand Down

0 comments on commit b54b086

Please sign in to comment.