1 32 33 package it.businesslogic.ireport.undo; 34 import it.businesslogic.ireport.gui.event.*; 35 import it.businesslogic.ireport.*; 36 import it.businesslogic.ireport.gui.*; 37 import it.businesslogic.ireport.util.*; 38 import java.util.*; 39 40 41 45 public class RemoveMarginsOperation implements it.businesslogic.ireport.UndoOperation { 46 47 48 private int oldTop = 0; 49 private int oldLeft = 0; 50 private int oldBottom = 0; 51 private int oldRight = 0; 52 53 private JReportFrame jrf = null; 54 55 56 57 public RemoveMarginsOperation(JReportFrame jrf, int oldTop, int oldBottom, int oldLeft, int oldRight ) { 58 59 this.oldTop = oldTop; 60 this.oldBottom = oldBottom; 61 this.oldLeft = oldLeft; 62 this.oldRight = oldRight; 63 64 this.jrf = jrf; 65 } 66 67 public void redo() 68 { 69 if (jrf == null) return; 70 71 jrf.getReport().setTopMargin( 0 ); 72 jrf.getReport().setBottomMargin( 0 ); 73 jrf.getReport().setLeftMargin( 0 ); 74 jrf.getReport().setRightMargin( 0 ); 75 76 jrf.getReport().setWidth( jrf.getReport().getWidth() - oldLeft - oldRight ); 77 78 if (oldTop != 0 || oldLeft != 0) { 79 Enumeration e = jrf.getReport().getElements().elements(); 80 while (e.hasMoreElements()) { 81 ReportElement re = (ReportElement)e.nextElement(); 82 re.trasform(new java.awt.Point (-oldLeft,-oldTop), TransformationType.TRANSFORMATION_MOVE); 83 } 84 } 85 86 jrf.setIsDocDirty(true); 87 jrf.getReportPanel().repaint(); 88 } 89 90 public void undo() 91 { 92 if (jrf == null) return; 93 94 jrf.getReport().setTopMargin( oldTop ); 95 jrf.getReport().setBottomMargin( oldBottom ); 96 jrf.getReport().setLeftMargin( oldLeft ); 97 jrf.getReport().setRightMargin( oldRight ); 98 99 jrf.getReport().setWidth( jrf.getReport().getWidth() + oldLeft + oldRight ); 100 101 if (oldTop != 0 || oldLeft != 0) { 102 Enumeration e = jrf.getReport().getElements().elements(); 103 while (e.hasMoreElements()) { 104 ReportElement re = (ReportElement)e.nextElement(); 105 re.trasform(new java.awt.Point (oldLeft,oldTop), TransformationType.TRANSFORMATION_MOVE); 106 } 107 } 108 109 jrf.setIsDocDirty(true); 110 jrf.getReportPanel().repaint(); 111 } 112 113 public String toString() 114 { 115 return "remove margins"; 116 } 117 } 118 | Popular Tags |