File: jiuawt.java

package info (click to toggle)
java-imaging-utilities 0.14.2%2B3-4
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 2,304 kB
  • ctags: 3,737
  • sloc: java: 31,190; sh: 238; xml: 30; makefile: 19
file content (127 lines) | stat: -rw-r--r-- 3,869 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
 * jiuawt
 * 
 * Copyright (c) 2000, 2001, 2002, 2003 Marco Schmidt.
 * All rights reserved.
 */

package net.sourceforge.jiu.apps;

import net.sourceforge.jiu.apps.EditorState;
import net.sourceforge.jiu.gui.awt.JiuAwtFrame;
import net.sourceforge.jiu.util.SystemInfo;

/**
 * Graphical user interface application based on the AWT (Abstract
 * Windowing Toolkit, part of Java's standard runtime library since 1.0) 
 * that demonstrates features of JIU.
 * <p>
 * <h3>Memory shortage</h3>
 * One of the errors experienced most frequently with jiuawt is the 
 * 'out of memory' error.
 * Note that only whoever starts jiuawt can give it more memory by
 * giving more memory to the Java virtual machine.
 * Example:
 * <pre>java -mx300m jiu.jar</pre>
 * starts jiuawt and provides it with 300 MB of memory.
 *
 * <h3>Command line switches</h3>
 * <dl>
 * <dt><code>--dir DIRECTORY</code>
 * <dd>set working directory to <code>DIRECTORY</code>
 * <dt><code>--help</code>
 * <dd>print help screen to standard output and exit
 * <dt><code>--lang LANGUAGE</code>
 * <dd>set language to <code>LANGUAGE</code>, where <code>en</code> is English, <code>de</code> is German and <code>es</code> is Spanish
 * <dt><code>--system</code>
 * <dd>print system information to standard output and exit
 * <dt><code>--version</code>
 * <dd>print version information to standard output and exit
 * </dl>
 * @author Marco Schmidt
 */
public class jiuawt
{
	private jiuawt()
	{
	}

	/**
	 * Creates a {@link JiuAwtFrame} object.
	 * @param args program arguments, call jiuawt with <code>--help</code> as single argument to get a help screen
	 */
	public static void main(String[] args)
	{
		EditorState state = new EditorState();
		int index = 0;
		while (index < args.length)
		{
			String s = args[index++];
			if ("--dir".equals(s))
			{
				if (index == args.length)
				{
					throw new IllegalArgumentException("Directory switch must be followed by a directory name.");
				}
				state.setCurrentDirectory(args[index++]);
			}
			else
			if ("--help".equals(s))
			{
				printVersion();
				System.out.println();
				System.out.println("Usage: jiuawt [OPTIONS] [FILE]");
				System.out.println("\tFILE is the name of an image file to be loaded after start-up");
				System.out.println("\t--dir  DIRECTORY  set working directory to DIRECTORY");
				System.out.println("\t--help            print this help screen and exit");
				System.out.println("\t--lang LANGCODE   set language to LANGCODE (de=German, en=English, es=Spanish)");
				System.out.println("\t--system          print system info and exit");
				System.out.println("\t--version         print version information and exit");
				System.exit(0);
			}
			else
			if ("--lang".equals(s))
			{
				if (index == args.length)
				{
					throw new IllegalArgumentException("Language switch must be followed by language code.");
				}
				state.setStrings(args[index++]);
			}
			else
			if ("--system".equals(s))
			{
				String info = SystemInfo.getSystemInfo(state.getStrings());
				System.out.println(info);
				System.exit(0);
			}
			else
			if ("--version".equals(s))
			{
				printVersion();
				System.exit(0);
			}
			else
			{
				if (s.startsWith("-"))
				{
					throw new IllegalArgumentException("Unknown switch: " + s);
				}
				else
				{
					state.setStartupImageName(s);
				}
			}
		}
		state.ensureStringsAvailable();
		new JiuAwtFrame(state);
	}

	private static void printVersion()
	{
		System.out.println("jiuawt " + JiuInfo.JIU_VERSION);
		System.out.println("An image editing program as a demo for the JIU image processing library.");
		System.out.println("Written by Marco Schmidt.");
		System.out.println("Visit the JIU website at <" + JiuInfo.JIU_HOMEPAGE + ">.");
	}
}