Ignore:
Timestamp:
06/05/08 10:11:18 (16 years ago)
Author:
ra33
Message:

Added DebugFrame action
Added GetCometStats
Lots of bug fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/actions/Misc.java

    r80 r86  
    1111import java.io.IOException;
    1212import java.lang.reflect.Method;
     13import java.sql.Time;
    1314import java.util.ArrayList;
    1415import java.util.List;
     
    2223import org.expeditee.gui.FrameMouseActions;
    2324import org.expeditee.gui.TimeKeeper;
     25import org.expeditee.io.Logger;
    2426import org.expeditee.items.Item;
    2527import org.expeditee.items.Text;
     
    5456        public static void Restore() {
    5557                FrameIO.Reload();
    56 
    57                 FrameGraphics.DisplayMessage("Restoration complete.");
     58                //FrameGraphics.DisplayMessage("Restoration complete.");
    5859        }
    5960
     
    227228        }
    228229
     230        /**
     231         * Creates a new Text Object containing statistics for the current tree.
     232         */
     233        public static void GetCometStats(Frame frame) {
     234                FrameGraphics.DisplayMessage("Extracting comet stats...");
     235
     236                StringBuffer sb = new StringBuffer();
     237                Time active = frame.getCometActiveTime(true);
     238                Time dark = frame.getCometDarkTime(true);
     239                Time total = new Time(active.getTime() + dark.getTime());
     240                int length = frame.getCometLength();
     241                sb.append("CometName: ").append(frame.getName()).append('\n');
     242                sb.append("Length: ").append(length).append('\n');
     243                sb.append("            Current  Average  Total").append('\n');
     244                Time averageActive = new Time((long) (0.5 + active.getTime()
     245                                / (1.0 * length)));
     246                Time averageDark = new Time((long) (0.5 + dark.getTime()
     247                                / (1.0 * length)));
     248                Time averageTotal = new Time((long) (0.5 + total.getTime()
     249                                / (1.0 * length)));
     250                Time currentActive = SessionStats.getFrameActiveTime();
     251                Time currentDark = SessionStats.getFrameDarkTime();
     252                Time currentTotal = SessionStats.getFrameTotalTime();
     253               
     254                sb.append("ActiveTime: ").append(Logger.EasyTimeFormat(currentActive)).append(
     255                ' ').append(Logger.EasyTimeFormat(averageActive)).append(
     256                                ' ').append(Logger.EasyTimeFormat(active)).append('\n');
     257                sb.append("  DarkTime: ").append(Logger.EasyTimeFormat(currentDark)).append(
     258                ' ').append(Logger.EasyTimeFormat(averageDark)).append(
     259                                ' ').append(Logger.EasyTimeFormat(dark)).append('\n');
     260                sb.append(" TotalTime: ").append(Logger.EasyTimeFormat(currentTotal)).append(
     261                ' ').append(Logger.EasyTimeFormat(averageTotal)).append(
     262                                ' ').append(Logger.EasyTimeFormat(total));
     263                CreateTextItem(sb.toString());
     264
     265                FrameGraphics.OverwriteMessage("Comet stats complete");
     266        }
     267
    229268        public static void CreateTextItem(String itemText) {
    230269                SessionStats.CreatedText();
     
    260299        public static void GetCurrentFrameFile() {
    261300
    262                 String fileContents = FrameIO.SaveFrame(DisplayIO.getCurrentFrame());
    263 
    264                 Text text = DisplayIO.getCurrentFrame().createNewText();
     301                Frame current = DisplayIO.getCurrentFrame();
     302                current.change();
     303                String fileContents = FrameIO.SaveFrame(current);
     304
     305                Text text = current.createNewText();
    265306                // We dont want the stats to wrap at all
    266307                text.setMaxSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
     
    349390        }
    350391
    351         public static String SaveImage(BufferedImage screen, String format, String directory, String fileName){
     392        public static String SaveImage(BufferedImage screen, String format,
     393                        String directory, String fileName) {
    352394                // Check if we need to append the suffix
    353395                if (fileName.indexOf('.') < 0)
    354                         fileName += "." + format.toLowerCase();         
     396                        fileName += "." + format.toLowerCase();
    355397
    356398                try {
     
    370412                return null;
    371413        }
    372        
     414
    373415        public static String ImageFrame(Frame frame, String format, String directory) {
    374416                assert (frame != null);
    375                
     417
    376418                FrameGraphics.UpdateBuffer(frame, false);
    377419
Note: See TracChangeset for help on using the changeset viewer.