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