001: /*
002: The contents of this file are subject to the Common Public Attribution License
003: Version 1.0 (the "License"); you may not use this file except in compliance with
004: the License. You may obtain a copy of the License at
005: http://www.projity.com/license . The License is based on the Mozilla Public
006: License Version 1.1 but Sections 14 and 15 have been added to cover use of
007: software over a computer network and provide for limited attribution for the
008: Original Developer. In addition, Exhibit A has been modified to be consistent
009: with Exhibit B.
010:
011: Software distributed under the License is distributed on an "AS IS" basis,
012: WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the
013: specific language governing rights and limitations under the License. The
014: Original Code is OpenProj. The Original Developer is the Initial Developer and
015: is Projity, Inc. All portions of the code written by Projity are Copyright (c)
016: 2006, 2007. All Rights Reserved. Contributors Projity, Inc.
017:
018: Alternatively, the contents of this file may be used under the terms of the
019: Projity End-User License Agreeement (the Projity License), in which case the
020: provisions of the Projity License are applicable instead of those above. If you
021: wish to allow use of your version of this file only under the terms of the
022: Projity License and not to allow others to use your version of this file under
023: the CPAL, indicate your decision by deleting the provisions above and replace
024: them with the notice and other provisions required by the Projity License. If
025: you do not delete the provisions above, a recipient may use your version of this
026: file under either the CPAL or the Projity License.
027:
028: [NOTE: The text of this license may differ slightly from the text of the notices
029: in Exhibits A and B of the license at http://www.projity.com/license. You should
030: use the latest text at http://www.projity.com/license for your modifications.
031: You may not remove this license text from the source files.]
032:
033: Attribution Information: Attribution Copyright Notice: Copyright © 2006, 2007
034: Projity, Inc. Attribution Phrase (not exceeding 10 words): Powered by OpenProj,
035: an open source solution from Projity. Attribution URL: http://www.projity.com
036: Graphic Image as provided in the Covered Code as file: openproj_logo.png with
037: alternatives listed on http://www.projity.com/logo
038:
039: Display of Attribution Information is required in Larger Works which are defined
040: in the CPAL as a work which combines Covered Code or portions thereof with code
041: not governed by the terms of the CPAL. However, in addition to the other notice
042: obligations, all copies of the Covered Code in Executable and Source Code form
043: distributed must, as a form of attribution of the original author, include on
044: each user interface screen the "OpenProj" logo visible to all users. The
045: OpenProj logo should be located horizontally aligned with the menu bar and left
046: justified on the top left of the screen adjacent to the File menu. The logo
047: must be at least 100 x 25 pixels. When users click on the "OpenProj" logo it
048: must direct them back to http://www.projity.com.
049: */
050: package com.projity.graphic.configuration;
051:
052: import org.apache.commons.digester.Digester;
053:
054: import com.projity.configuration.Configuration;
055: import com.projity.configuration.FieldDictionary;
056: import com.projity.configuration.NamedItem;
057: import com.projity.field.Field;
058: import com.projity.functor.ScheduleIntervalGenerator;
059: import com.projity.strings.Messages;
060:
061: /**
062: *
063: */
064: public class BarFormat implements NamedItem {
065: public static final String category = "BarFormatCategory";
066:
067: public BarFormat() {
068: }
069:
070: public String getCategory() {
071: return category;
072: }
073:
074: /**
075: * @return Returns the end.
076: */
077: public TexturedShape getEnd() {
078: return end;
079: }
080:
081: /**
082: * @param end The end to set.
083: */
084: public void setEnd(TexturedShape end) {
085: end.build();
086: this .end = end;
087: }
088:
089: /**
090: * @return Returns the from.
091: */
092: public String getFrom() {
093: return from;
094: }
095:
096: /**
097: * @param from The from to set.
098: */
099: public void setFrom(String from) {
100: this .from = from;
101: fromField = Configuration.getFieldFromId(from);
102: }
103:
104: /**
105: * @return Returns the to.
106: */
107: public String getTo() {
108: return to;
109: }
110:
111: /**
112: * @param to The to to set.
113: */
114: public void setTo(String to) {
115: this .to = to;
116: toField = Configuration.getFieldFromId(to);
117: }
118:
119: /**
120: * @return Returns the line.
121: */
122: public int getRow() {
123: return row;
124: }
125:
126: /**
127: * @param line The line to set.
128: */
129: public void setRow(int line) {
130: this .row = line;
131: }
132:
133: /**
134: * @return Returns the middle.
135: */
136: public TexturedShape getMiddle() {
137: return middle;
138: }
139:
140: /**
141: * @param middle The middle to set.
142: */
143: public void setMiddle(TexturedShape middle) {
144: middle.build();
145: this .middle = middle;
146: }
147:
148: /**
149: * @return Returns the name.
150: */
151: public String getName() {
152: return name;
153: }
154:
155: /**
156: * @param name The name to set.
157: */
158: public void setName(String name) {
159: this .name = name;
160: }
161:
162: public String getId() {
163: return id;
164: }
165:
166: public void setId(String id) {
167: this .id = id;
168: setName(Messages.getString(id));
169: }
170:
171: /**
172: * @return Returns the start.
173: */
174: public TexturedShape getStart() {
175: return start;
176: }
177:
178: /**
179: * @param start The start to set.
180: */
181: public void setStart(TexturedShape start) {
182: start.build();
183: this .start = start;
184: }
185:
186: public int getLayer() {
187: return layer;
188: }
189:
190: public void setLayer(int layer) {
191: this .layer = layer;
192: }
193:
194: public String getIntervalGenerator() {
195: return intervalGenerator;
196: }
197:
198: public void setIntervalGenerator(String intervalGenerator) {
199: this .intervalGenerator = intervalGenerator;
200: }
201:
202: public ScheduleIntervalGenerator getScheduleIntervalGenerator() {
203: if (intervalGenerator != null
204: && scheduleIntervalGenerator == null) {
205: try {
206: scheduleIntervalGenerator = (ScheduleIntervalGenerator) Class
207: .forName(intervalGenerator).newInstance();
208: } catch (InstantiationException e) {
209: e.printStackTrace();
210: } catch (IllegalAccessException e) {
211: e.printStackTrace();
212: } catch (ClassNotFoundException e) {
213: e.printStackTrace();
214: }
215: }
216: return scheduleIntervalGenerator;
217: }
218:
219: public boolean isMain() { //compatibily
220: return main || intervalGenerator != null;
221: }
222:
223: public void setMain(boolean main) {
224: this .main = main;
225: }
226:
227: public FormFormat getForm() {
228: return form;
229: }
230:
231: public void setForm(FormFormat form) {
232: this .form = form;
233: }
234:
235: /**
236: * Add digester events for the bar as well as the three sections.
237: * The XML root is * /bar/shape
238: *
239: */
240: public static void addDigesterEvents(Digester digester) {
241: // main properties of bar
242: digester.addObjectCreate("*/bar/format",
243: "com.projity.graphic.configuration.BarFormat");
244: digester.addSetProperties("*/bar/format");
245: digester.addSetNext("*/bar/format", "add",
246: "com.projity.configuration.NamedItem"); // add to dictionary
247:
248: // start section
249: digester.addObjectCreate("*/bar/format/start",
250: "com.projity.graphic.configuration.TexturedShape");
251: digester.addSetProperties("*/bar/format/start");
252: digester.addSetNext("*/bar/format/start", "setStart",
253: "com.projity.graphic.configuration.TexturedShape");
254:
255: //middle section
256: digester.addObjectCreate("*/bar/format/middle",
257: "com.projity.graphic.configuration.TexturedShape");
258: digester.addSetProperties("*/bar/format/middle");
259: digester.addSetNext("*/bar/format/middle", "setMiddle",
260: "com.projity.graphic.configuration.TexturedShape");
261:
262: //end section
263: digester.addObjectCreate("*/bar/format/end",
264: "com.projity.graphic.configuration.TexturedShape");
265: digester.addSetProperties("*/bar/format/end");
266: digester.addSetNext("*/bar/format/end", "setEnd",
267: "com.projity.graphic.configuration.TexturedShape");
268:
269: //end section
270: digester.addObjectCreate("*/bar/format/form",
271: "com.projity.graphic.configuration.FormFormat");
272: digester.addSetProperties("*/bar/format/form");
273: digester.addSetNext("*/bar/format/form", "setForm",
274: "com.projity.graphic.configuration.FormFormat");
275:
276: FormFormat.addDigesterEvents(digester);
277:
278: }
279:
280: String name = null;
281: String id = null;
282: int row = 0;
283: String intervalGenerator = null;
284: ScheduleIntervalGenerator scheduleIntervalGenerator = null;
285: String from;
286: String to;
287: Field fromField = null;
288: Field toField = null;
289: TexturedShape start = null;
290: TexturedShape middle = null;
291: TexturedShape end = null;
292: FormFormat form = null;
293: boolean main = false;
294: public static final int MIN_FOREGROUND_LAYER = 1;
295: public static final int MAX_FOREGROUND_LAYER = 499;
296: public static final int MIN_LINK_LAYER = 500;
297: public static final int MAX_LINK_LAYER = 999;
298: public static final int MIN_BACKGROUND_LAYER = 1000;
299: public static final int MAX_BACKGROUND_LAYER = 1499;
300: int layer = MIN_BACKGROUND_LAYER;
301: String fieldId = null;
302: Field field = null; //for annotations
303:
304: /**
305: * @return Returns the category.
306: */
307: /**
308: * @return Returns the fromField.
309: */
310: public Field getFromField() {
311: return fromField;
312: }
313:
314: /**
315: * @return Returns the toField.
316: */
317: public Field getToField() {
318: return toField;
319: }
320:
321: public int getNumberOfSections() {
322: int count = 0;
323: if (start != null)
324: count++;
325: if (middle != null)
326: count++;
327: if (end != null)
328: count++;
329: return count;
330: }
331:
332: public String getFieldId() {
333: return fieldId;
334: }
335:
336: public void setFieldId(String fieldId) {
337: this .fieldId = fieldId;
338: getField();
339: }
340:
341: public Field getField() {
342: if (field == null || field.getId() != fieldId) {
343: if (fieldId == null)
344: field = null;
345: field = FieldDictionary.getInstance().getFieldFromId(
346: fieldId);
347: }
348: return field;
349: }
350:
351: }
|