View Javadoc

1   /*
2   
3       dsh-iconbundle-tools  Command line icon bundle tools.
4       Copyright (c) 2003-2013 held jointly by the individual authors.
5   
6       This library is free software; you can redistribute it and/or modify it
7       under the terms of the GNU Lesser General Public License as published
8       by the Free Software Foundation; either version 3 of the License, or (at
9       your option) any later version.
10  
11      This library is distributed in the hope that it will be useful, but WITHOUT
12      ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
13      FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14      License for more details.
15  
16      You should have received a copy of the GNU Lesser General Public License
17      along with this library;  if not, write to the Free Software Foundation,
18      Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA.
19  
20      > http://www.fsf.org/licensing/licenses/lgpl.html
21      > http://www.opensource.org/licenses/lgpl-license.php
22  
23  */
24  package org.dishevelled.iconbundle.tools;
25  
26  import java.io.File;
27  
28  import org.dishevelled.commandline.Usage;
29  import org.dishevelled.commandline.Switch;
30  import org.dishevelled.commandline.Argument;
31  import org.dishevelled.commandline.ArgumentList;
32  import org.dishevelled.commandline.CommandLine;
33  import org.dishevelled.commandline.CommandLineParser;
34  import org.dishevelled.commandline.CommandLineParseException;
35  
36  import org.dishevelled.commandline.argument.FileArgument;
37  import org.dishevelled.commandline.argument.StringArgument;
38  
39  import org.dishevelled.iconbundle.IconBundle;
40  
41  import org.dishevelled.iconbundle.impl.svg.SVGIconBundle;
42  
43  /**
44   * SVG variants.
45   *
46   * @author  Michael Heuer
47   */
48  public final class SVGVariants
49  {
50  
51      /**
52       * Main.
53       *
54       * @param args command line arguments
55       */
56      public static final void main(final String[] args)
57      {
58          CommandLine commandLine = null;
59          ArgumentList arguments = null;
60          try
61          {
62              commandLine = new CommandLine(args);
63  
64              Argument<File> i = new FileArgument("i", "input", "input file", true);
65              Argument<String> o = new StringArgument("o", "output", "output file name", true);
66              Argument<Boolean> b = new Switch("b", "draw-borders", "true to draw borders");
67  
68              arguments = new ArgumentList(new Argument[] { i, o, b });
69  
70              CommandLineParser.parse(commandLine, arguments);
71  
72              IconBundle iconBundle = new SVGIconBundle(i.getValue());
73  
74              Runnable sav = new ShowAllVariants(iconBundle, o.getValue(), b.getValue());
75              sav.run();
76          }
77          catch (CommandLineParseException e)
78          {
79              Usage.usage("java -jar svg-variants.jar [args]\n\nSVG Variants", e, commandLine, arguments, System.err);
80          }
81          catch (IllegalArgumentException e)
82          {
83              Usage.usage("java -jar svg-variants.jar [args]\n\nSVG Variants", e, commandLine, arguments, System.err);
84          }
85      }
86  }