1 26 27 package it.stefanochizzolini.clown.documents.interaction; 28 29 import it.stefanochizzolini.clown.documents.Document; 30 import it.stefanochizzolini.clown.files.File; 31 import it.stefanochizzolini.clown.objects.PdfAtomicObject; 32 import it.stefanochizzolini.clown.objects.PdfBoolean; 33 import it.stefanochizzolini.clown.objects.PdfDictionary; 34 import it.stefanochizzolini.clown.objects.PdfDirectObject; 35 import it.stefanochizzolini.clown.objects.PdfIndirectObject; 36 import it.stefanochizzolini.clown.objects.PdfName; 37 import it.stefanochizzolini.clown.objects.PdfObjectWrapper; 38 import it.stefanochizzolini.clown.util.NotImplementedException; 39 40 43 public class ViewerPreferences 44 extends PdfObjectWrapper<PdfDictionary> 45 { 46 public ViewerPreferences( 50 Document context 51 ) 52 { 53 super( 54 context.getFile(), 55 new PdfDictionary() 56 ); 57 } 58 59 63 public ViewerPreferences( 64 PdfDirectObject baseObject, 65 PdfIndirectObject container 66 ) 67 { 68 super( 69 baseObject, 70 container 71 ); 72 } 73 75 public Object clone( 78 Document context 79 ) 80 {throw new NotImplementedException();} 81 82 public boolean getDisplayDocTitle( 83 ) 84 {return this.<Boolean ,PdfBoolean>getEntry(PdfName.DisplayDocTitle);} 85 86 public boolean getHideMenubar( 87 ) 88 {return this.<Boolean ,PdfBoolean>getEntry(PdfName.HideMenubar);} 89 90 public boolean getHideToolbar( 91 ) 92 {return this.<Boolean ,PdfBoolean>getEntry(PdfName.HideToolbar);} 93 94 public boolean getHideWindowUI( 95 ) 96 {return this.<Boolean ,PdfBoolean>getEntry(PdfName.HideWindowUI);} 97 98 public boolean getFitWindow( 99 ) 100 {return this.<Boolean ,PdfBoolean>getEntry(PdfName.FitWindow);} 101 102 public boolean getCenterWindow( 103 ) 104 {return this.<Boolean ,PdfBoolean>getEntry(PdfName.CenterWindow);} 105 106 public void setDisplayDocTitle( 107 boolean value 108 ) 109 {this.<Boolean ,PdfBoolean>setEntry(PdfName.DisplayDocTitle,value,PdfBoolean.class);} 110 111 public void setHideMenubar( 112 boolean value 113 ) 114 {this.<Boolean ,PdfBoolean>setEntry(PdfName.HideMenubar,value,PdfBoolean.class);} 115 116 public void setHideToolbar( 117 boolean value 118 ) 119 {this.<Boolean ,PdfBoolean>setEntry(PdfName.HideToolbar,value,PdfBoolean.class);} 120 121 public void setHideWindowUI( 122 boolean value 123 ) 124 {this.<Boolean ,PdfBoolean>setEntry(PdfName.HideWindowUI,value,PdfBoolean.class);} 125 126 public void setFitWindow( 127 boolean value 128 ) 129 {this.<Boolean ,PdfBoolean>setEntry(PdfName.FitWindow,value,PdfBoolean.class);} 130 131 public void setCenterWindow( 132 boolean value 133 ) 134 {this.<Boolean ,PdfBoolean>setEntry(PdfName.CenterWindow,value,PdfBoolean.class);} 135 137 protected <T,TPdf extends PdfAtomicObject<T>> T getEntry( 139 PdfName key 140 ) 141 { 142 TPdf entry = (TPdf)File.resolve(getBaseDataObject().get(key)); 143 if(entry == null) 144 return null; 145 146 return (T)entry.getValue(); 147 } 148 149 protected <T,TPdf extends PdfAtomicObject<T>> void setEntry( 150 PdfName key, 151 T value, 152 Class <TPdf> entryType ) 154 { 155 TPdf entry = (TPdf)File.resolve(getBaseDataObject().get(key)); 156 if(entry == null) 157 { 158 try 159 { 160 getBaseDataObject().put( 161 key, 162 entry = entryType.newInstance() 163 ); 164 } 165 catch(Exception e) 166 {throw new RuntimeException (e);} 167 } 168 169 entry.setValue(value); 170 } 171 } | Popular Tags |