App
GaussianSharpenFilterLayer.java
Go to the documentation of this file.
1 package mhr.appcore.image.layers.filter;
2 
3 import org.w3c.dom.Document;
4 import org.w3c.dom.Element;
5 
6 import mhr.appcore.bitmap.exceptions.BitmapAllocationException;
7 import mhr.appcore.bitmap.exceptions.UnsupportedBitmapException;
8 import mhr.appcore.filters.Filter;
9 import mhr.appcore.image.Image;
10 import mhr.appcore.image.exceptions.InvalidLayerSpecificPresentationSuppliedException;
11 import mhr.appcore.image.exceptions.LayerCreationException;
12 import mhr.appcore.image.layers.Layer;
13 import mhr.appcore.image.layers.LayerPDInfo;
14 import mhr.appcore.image.layers.LayerType;
15 import mhr.appcore.interfaces.ImageFile;
16 import mhr.appcore.pointops.LUT;
17 import mhr.appcore.pointops.LUTAllocationException;
18 
23 
24  //===== INTERFACES, CLASSES, ENUMS ==========================================================================================================//
25  //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
26  //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
27 
28  //===== FIELDS ==============================================================================================================================//
29  //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
30  protected double sigma = 0;
31  protected double force = -1;
32  //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
33 
34  //===== CONSTRUCTORS, DESTRUCTORS, RELATED METHODS ==========================================================================================//
35  //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
36  @Override
37  protected void finalize() throws Throwable {
38  dispose();
39  super.finalize();
40  }
41 
43  super(l, newId);
44  this.sigma = l.sigma;
45  this.force = l.force;
46  filter = new Filter();
49  }
50 
51  //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
61  super(owner, id);
62  filter = new Filter();
63  }
64 
66  super(owner, i, f);
67  try {
68  sigma = Double.parseDouble(i.getElementsByTagName("Sigma").item(0).getTextContent());
69  force = Double.parseDouble(i.getElementsByTagName("Force").item(0).getTextContent());
70  } catch (Exception e) {
71  throw new LayerCreationException(e);
72  }
73 
74  filter = new Filter();
76  }
77 
78  @Override
79  public synchronized int dispose() {
80  super.dispose();
81  return 0;
82  }
83 
84  //===== METHODS =============================================================================================================================//
85  //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
86 
87  protected void fillSpecificElement(Document d, ImageFile f, Element e) {
88  appendLeafElement(d, e, "Sigma", Double.toString(sigma));
89  appendLeafElement(d, e, "Force", Double.toString(force));
90  }
91 
92  //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
93  @Override
94  public LayerType getType() {
96  }
97 
98 
99 //----- Pole --------------------------------------------------------------------------------------------------------------------------------//
100 
101 //----- Accessory a primitivní metody -------------------------------------------------------------------------------------------------------//
102 
103 //----- Pomocné metody ----------------------------------------------------------------------------------------------------------------------//
104 //----- Konstruktory ------------------------------------------------------------------------------------------------------------------------//
105 
106 //----- Destruktory -------------------------------------------------------------------------------------------------------------------------//
107 
108 //----- Metody ------------------------------------------------------------------------------------------------------------------------------//
109  @Override
110  public Layer duplicate(int newId) {
111  return new GaussianSharpenFilterLayer(this, newId);
112  }
113 
114 
115 
116  @Override
117  protected void updateSpecificData(LayerPDInfo info) {
119  info.extra = p;
120  }
121 
122  @Override
123  public void updateFromSpecificPresentation(LayerPDInfo presentation) {
124  if (!(presentation.extra instanceof GaussianSharpenFilterLayerSpecificPresentation)) {
125  throw new InvalidLayerSpecificPresentationSuppliedException("Invalid specific data supplied");
126  }
127  GaussianSharpenFilterLayerSpecificPresentation p = (GaussianSharpenFilterLayerSpecificPresentation) presentation.extra;
128  sigma = p.sigma;
129  force = p.force;
132  presentation.isChanged = true;
134  }
135 }