File: WpIconLibrary.java

package info (click to toggle)
gpsprune 26.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,824 kB
  • sloc: java: 52,154; sh: 25; makefile: 21; python: 15
file content (101 lines) | stat: -rw-r--r-- 2,791 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
package tim.prune.gui.map;

import javax.swing.ImageIcon;

import tim.prune.gui.IconManager;

/**
 * Class to provide a library of waypoint icon definitions
 */
public abstract class WpIconLibrary
{
	/** Types of waypoint */
	public static final int WAYPT_DEFAULT = 0;
	public static final int WAYPT_RING_POINT = 1;
	public static final int WAYPT_PLECTRUM = 2;
	public static final int WAYPT_CIRCLE = 3;
	public static final int WAYPT_PIN = 4;
	public static final int WAYPT_FLAG = 5;
	public static final int WAYPT_NUMBER_OF_ICONS = WAYPT_FLAG + 1;

	/** Sizes of icon */
	private enum Size
	{
		SMALL("_s"), MEDIUM("_m"), LARGE("_l"), FIXED("_f");
		final String _suffix;
		Size(String inSuffix) {
			_suffix = inSuffix;
		}
		String getSuffix() {
			return _suffix;
		}
		static Size fromInt(int inIndex)
		{
			switch (inIndex) {
				case 0: return SMALL;
				default:
				case 1: return MEDIUM;
				case 2: return LARGE;
			}
		}
	}


	/** @return array of Integers representing waypoint types */
	public static Integer[] getWaypointTypes()
	{
		return new Integer[] {WAYPT_DEFAULT, WAYPT_RING_POINT, WAYPT_PLECTRUM,
				WAYPT_CIRCLE, WAYPT_PIN, WAYPT_FLAG};
	}

	/**
	 * @param inType icon type
	 * @return the name of the specified icon, used for settings dialog
	 */
	public static String getIconName(int inType)
	{
		switch (inType)
		{
			case WAYPT_RING_POINT: return "ringpt";
			case WAYPT_PLECTRUM:   return "plectrum";
			case WAYPT_CIRCLE:     return "ring";
			case WAYPT_PIN:        return "pin";
			case WAYPT_FLAG:       return "flag";
			case WAYPT_DEFAULT:
			default:               return "default";
		}
	}

	/**
	 * @param inType icon type
	 * @param inSize icon size (small/medium/large)
	 * @param inIconManager icon manager to use
	 * @return icon definition for the specified icon
	 */
	public static WpIconDefinition getIconDefinition(int inType, int inSize, IconManager inIconManager) {
		return getIconDefinition(inType, Size.fromInt(inSize), inIconManager);
	}

	/**
	 * @param inType icon type
	 * @param inIconManager icon manager to use
	 * @return icon definition for the specified fixed icon
	 */
	public static WpIconDefinition getFixedIconDefinition(int inType, IconManager inIconManager) {
		return getIconDefinition(inType, Size.FIXED, inIconManager);
	}

	/**
	 * @param inType icon type
	 * @param inSize icon size (small/medium/large)
	 * @param inIconManager icon manager to use
	 * @return icon definition for the specified icon
	 */
	private static WpIconDefinition getIconDefinition(int inType, Size inSize, IconManager inIconManager)
	{
		final String iconName = getIconName(inType);
		ImageIcon icon = inIconManager.getImageIcon(IconManager.WAYPOINT_ICON_PREFIX
			+ iconName + inSize.getSuffix());
		return new WpIconDefinition(icon);
	}
}