001package com.hfg.graphics; 002 003 004import com.hfg.exception.ProgrammingException; 005import com.hfg.graphics.units.GfxSize; 006import com.hfg.graphics.units.Inches; 007 008//------------------------------------------------------------------------------ 009/** 010 * Container for page margins. 011 * 012 * @author J. Alex Taylor, hairyfatguy.com 013 */ 014//------------------------------------------------------------------------------ 015// com.hfg XML/HTML Coding Library 016// 017// This library is free software; you can redistribute it and/or 018// modify it under the terms of the GNU Lesser General Public 019// License as published by the Free Software Foundation; either 020// version 2.1 of the License, or (at your option) any later version. 021// 022// This library is distributed in the hope that it will be useful, 023// but WITHOUT ANY WARRANTY; without even the implied warranty of 024// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 025// Lesser General Public License for more details. 026// 027// You should have received a copy of the GNU Lesser General Public 028// License along with this library; if not, write to the Free Software 029// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 030// 031// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com 032// jataylor@hairyfatguy.com 033//------------------------------------------------------------------------------ 034 035public class PageMargins implements Cloneable 036{ 037 private GfxSize mTop; 038 private GfxSize mRight; 039 private GfxSize mBottom; 040 private GfxSize mLeft; 041 042 private static GfxSize sDefaultMargin = new Inches(1); 043 044 //########################################################################## 045 // CONSTRUCTORS 046 //########################################################################## 047 048 //--------------------------------------------------------------------------- 049 public PageMargins() 050 { 051 init(); 052 } 053 054 //--------------------------------------------------------------------------- 055 private void init() 056 { 057 mTop = sDefaultMargin; 058 mRight = sDefaultMargin; 059 mBottom = sDefaultMargin; 060 mLeft = sDefaultMargin; 061 } 062 063 //########################################################################## 064 // PUBLIC METHODS 065 //########################################################################## 066 067 //--------------------------------------------------------------------------- 068 @Override 069 public PageMargins clone() 070 { 071 PageMargins cloneObj; 072 try 073 { 074 cloneObj = (PageMargins) super.clone(); 075 } 076 catch (CloneNotSupportedException e) 077 { 078 throw new ProgrammingException(e); 079 } 080 081 return cloneObj; 082 } 083 084 //--------------------------------------------------------------------------- 085 public PageMargins setTop(GfxSize inValue) 086 { 087 mTop = inValue; 088 return this; 089 } 090 091 //--------------------------------------------------------------------------- 092 public GfxSize getTop() 093 { 094 return mTop; 095 } 096 097 098 //--------------------------------------------------------------------------- 099 public PageMargins setRight(GfxSize inValue) 100 { 101 mRight = inValue; 102 return this; 103 } 104 105 //--------------------------------------------------------------------------- 106 public GfxSize getRight() 107 { 108 return mRight; 109 } 110 111 112 //--------------------------------------------------------------------------- 113 public PageMargins setBottom(GfxSize inValue) 114 { 115 mBottom = inValue; 116 return this; 117 } 118 119 //--------------------------------------------------------------------------- 120 public GfxSize getBottom() 121 { 122 return mBottom; 123 } 124 125 126 //--------------------------------------------------------------------------- 127 public PageMargins setLeft(GfxSize inValue) 128 { 129 mLeft = inValue; 130 return this; 131 } 132 133 //--------------------------------------------------------------------------- 134 public GfxSize getLeft() 135 { 136 return mLeft; 137 } 138 139}