App
DifferenceOfGaussianSharpenFilterLayer.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 k = 1.6;
32  protected double force = 0;
33  protected boolean area;
34  //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
35 
36  //===== CONSTRUCTORS, DESTRUCTORS, RELATED METHODS ==========================================================================================//
37  //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
38  @Override
39  protected void finalize() throws Throwable {
40  dispose();
41  super.finalize();
42  }
43 
44 
46  super(l, newId);
47  this.sigma = l.sigma;
48  this.force = l.force;
49  this.k = l.k;
50  this.area = l.area;
51  filter = new Filter();
54  }
55  //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
65  super(owner, id);
66  filter = new Filter();
67  }
68 
70  super(owner, i, f);
71  try {
72  sigma = Double.parseDouble(i.getElementsByTagName("Sigma").item(0).getTextContent());
73  k = Double.parseDouble(i.getElementsByTagName("K").item(0).getTextContent());
74  force = Double.parseDouble(i.getElementsByTagName("Force").item(0).getTextContent());
75  area = Boolean.parseBoolean(i.getElementsByTagName("Area").item(0).getTextContent());
76  } catch (Exception e) {
77  throw new LayerCreationException(e);
78  }
79 
80  filter = new Filter();
82  }
83 
84  @Override
85  public synchronized int dispose() {
86  super.dispose();
87  return 0;
88  }
89 
90  //===== METHODS =============================================================================================================================//
91  //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
92 
93  protected void fillSpecificElement(Document d, ImageFile f, Element e) {
94  appendLeafElement(d, e, "Sigma", Double.toString(sigma));
95  appendLeafElement(d, e, "K", Double.toString(k));
96  appendLeafElement(d, e, "Force", Double.toString(force));
97  appendLeafElement(d, e, "Area", Boolean.toString(area));
98  }
99 
100  //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
101  @Override
102  public Layer duplicate(int newId) {
103  return new DifferenceOfGaussianSharpenFilterLayer(this, newId);
104  }
105 
106 
107  @Override
108  public LayerType getType() {
110  }
111 
112 
113 //----- Pole --------------------------------------------------------------------------------------------------------------------------------//
114 
115 //----- Accessory a primitivní metody -------------------------------------------------------------------------------------------------------//
116 
117 //----- Pomocné metody ----------------------------------------------------------------------------------------------------------------------//
118 //----- Konstruktory ------------------------------------------------------------------------------------------------------------------------//
119 
120 //----- Destruktory -------------------------------------------------------------------------------------------------------------------------//
121 
122 //----- Metody ------------------------------------------------------------------------------------------------------------------------------//
123 
124  @Override
125  protected void updateSpecificData(LayerPDInfo info) {
127  info.extra = p;
128  }
129 
130  @Override
131  public void updateFromSpecificPresentation(LayerPDInfo presentation) {
132  if (!(presentation.extra instanceof DifferenceOfGaussianSharpenFilterLayerSpecificPresentation)) {
133  throw new InvalidLayerSpecificPresentationSuppliedException("Invalid specific data supplied");
134  }
135  DifferenceOfGaussianSharpenFilterLayerSpecificPresentation p = (DifferenceOfGaussianSharpenFilterLayerSpecificPresentation) presentation.extra;
136  sigma = p.sigma;
137  k = p.k;
138  force = p.force;
139  area = p.area;
142  presentation.isChanged = true;
144  }
145 }