View Javadoc

1   // Copyright 2004-2005, FreeHEP.
2   package hep.wired.edit;
3   
4   import java.awt.*;
5   
6   import org.freehep.swing.undo.AnimatedEdit;
7   import org.freehep.util.ScientificFormat;
8   
9   import hep.wired.services.RecordPlot;
10  import hep.wired.services.Edit;
11  
12  /***
13   * Base class for a non-animated single edit.
14   * This class keeps the plot when the edit is posted to the plot.
15   *
16   * @author Mark Donszelmann
17   * @version $Id: WiredEdit.java 689 2005-03-16 09:06:57Z duns $
18   */
19  public abstract class WiredEdit extends AnimatedEdit implements Edit {
20  
21      protected static ScientificFormat format = new ScientificFormat(2, 8, false);
22      private RecordPlot recordPlot;
23  
24      /***
25       * Creates an Edit with zero frames.
26       */
27      public WiredEdit() {
28          this(0);
29      }
30  
31      /***
32       * Creates and edit with given frames.
33       */
34      public WiredEdit(int frames) {
35          super(frames);
36      }
37      
38      public String toString() {
39          return getPresentationName();
40      }
41  
42      public String getID() {
43          String[] names = getClass().getName().split(".");
44          return names[names.length-1];
45      }
46  
47      /***
48       * Returns the record plot to which this edit was sent. Returns null if the 
49       * edit was not (yet) sent to a plot.
50       */
51      protected RecordPlot getRecordPlot() { 
52          return recordPlot;
53      }
54      
55      /***
56       * To be called as part of the copy procedure to set the recordPlot variable.
57       */
58      public void setRecordPlot(RecordPlot recordPlot) {
59          this.recordPlot = recordPlot;
60      }
61      
62      /***
63       * Creates a copy of the edit which is attached to the plot,
64       * and thus can be (re/un)done.
65       */
66      public abstract WiredEdit copy(RecordPlot plot);
67  
68  // Should be imlemented by all ProjectionEdits    
69  //    public abstract Shape createTransformedShape(Component component, Shape shape);
70  
71      /***
72       * Called when an animation is started. Redo is set when the animation is to run
73       * forward, e.g. the edit is (re-)done. 
74       * Default implementation is a null method.
75       */    
76      protected void startAnimation(boolean redo) {};
77      
78      /***
79       * Called when the given frameNo is to be shown.
80       * Default implementation is a null method.
81       */
82      protected void showAnimation(int frameNo) {};
83      
84      /***
85       * Called when the animation is to be ended.
86       * Default implementation is a null method.
87       */
88      protected void endAnimation() {};
89      
90  }