1 /*
2 * This file is a part of CAST project.
3 * (c) Copyright 2007, AGH University of Science & Technology
4 * https://caribou.iisg.agh.edu.pl/trac/cast
5 *
6 * Licensed under the Eclipse Public License, Version 1.0 (the "License").
7 * You may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 * http://www.eclipse.org/legal/epl-v10.html
10 */
11 /*
12 * File: NodeIcon.java
13 * Created: 2008-11-11
14 * Author: tmilos
15 * $Id: NodeIcon.java 3054 2009-07-27 10:23:07Z kpietak $
16 */
17
18 package pl.edu.agh.cast.backward.figure.icons;
19
20 import org.eclipse.jface.resource.ImageDescriptor;
21
22 /**
23 * Representation of diagram icon specific for given node type. For each node type there may be only one default
24 * NodeIcon.
25 *
26 * @author AGH CAST Team
27 */
28 public final class NodeIcon {
29
30 /**
31 * Node type - should be globally unique.
32 */
33 private String nodeType;
34
35 /**
36 * Icon group this icon belongs to. May be related to domain.
37 */
38 private String group;
39
40 /**
41 * Display (user friendly) name.
42 */
43 private String name;
44
45 /**
46 * Large icon descriptor.
47 */
48 private ImageDescriptor iconDescriptor;
49
50 /**
51 * Small icon descriptor.
52 */
53 private ImageDescriptor smallIconDescriptor;
54
55 /**
56 * Large icon unique ID. Used as a key in ImageRegistry.
57 */
58 private String iconId;
59
60 /**
61 * Small icon unique ID. Used as a key in ImageRegistry.
62 */
63 private String smallIconId;
64
65 /**
66 * Constructor.
67 *
68 * @param nodeType
69 * type of node this icon is for (by default). Should be unique for each NodeIcon.
70 * @param name
71 * localized icon display name
72 * @param icon
73 * descriptor of icon's large image
74 * @param smallIcon
75 * descriptor of icon's small image
76 * @param group
77 * localized name of the group this icon is in (ex. Billing)
78 */
79 public NodeIcon(String nodeType, String name, ImageDescriptor icon, ImageDescriptor smallIcon, String group) {
80 this.nodeType = nodeType;
81 this.name = name;
82 this.iconDescriptor = icon;
83 this.smallIconDescriptor = smallIcon;
84 this.group = group;
85
86 // if multiple icons for single node type are to be allowed
87 // the following icon IDs should be generated in a different way
88 iconId = String.format("%s:large", nodeType); //$NON-NLS-1$
89 smallIconId = String.format("%s:small", nodeType); //$NON-NLS-1$
90 }
91
92 /**
93 * Returns icon's display name.
94 *
95 * @return the name
96 */
97 public String getName() {
98 return name;
99 }
100
101 /**
102 * Returns the type of node this icon is for (by default).
103 *
104 * @return the nodeType
105 */
106 public String getNodeType() {
107 return nodeType;
108 }
109
110 /**
111 * Returns the large icon descriptor.
112 *
113 * @return the iconDescriptor
114 */
115 public ImageDescriptor getIconDescriptor() {
116 return iconDescriptor;
117 }
118
119 /**
120 * Returns the small icon descriptor.
121 *
122 * @return the smallIconDescriptor
123 */
124 public ImageDescriptor getSmallIconDescriptor() {
125 return smallIconDescriptor;
126 }
127
128 /**
129 * Returns the large icon unique ID. This ID may be used as a key in ImageRegistry.
130 *
131 * @return the iconId
132 */
133 public String getIconId() {
134 return iconId;
135 }
136
137 /**
138 * Returns the small icon unique ID. This ID may be used as a key in ImageRegistry.
139 *
140 * @return the smallIconId
141 */
142 public String getSmallIconId() {
143 return smallIconId;
144 }
145
146 /**
147 * Returns the name of the group this icon belongs to. This may be used for palette grouping.
148 *
149 * @return the group
150 */
151 public String getGroup() {
152 return group;
153 }
154
155 }