Wednesday, July 23, 2008

Model-View-Controller

The Struts framework was created by Craig R. McClanahan and donated to Apache Software Foundation (ASF) in 2000. A framework provides generic, cooperative components that your application extends to deliver a particular set of functions. So it is also referred as an "upside-down" library. The Struts framework provides three key components for the implementation of the MVC structure.
  • A "request" handler provided by the application developer that is mapped to a standard URI.
  • A "response" handler that transfers control to another resource which completes the response.
  • A tag library that helps developers create interactive form-based applications with server pages.
Others
Cocoon project founded by Stefano Mazzocchi in January 1999 is an open source project the ASF. Cocoon leverages XML, XSLT, and Simple API for XML (SAX) to help create, deploy, and maintain XML server applications.

Velocity is a Jakarta project like Struts. It is a Java-based template engine that can generate SQL, PostScript, and XML form templates.

JavaServer Faces (JSF) project is to provide a standard set of JSP Tags and classes to aid in the management of complicated HTML forms, event handling, and presentation state.

Jakarta Turbine is a servlet-based framework. A large set of components is included with the framework, including those for using relational databases, security, and scheduling, etc.

WebWork is a web application framework that uses the Pull Hierarchical Model View Controller (HMVC) design. With a standard MVC design, changes made to the model are pushed to the view. In the case of WebWork, the views pull the data when they need it.

Spring is a J2EE application framework developed by Rod Johnson. Spring is not just a web framework. It can integrated with other disparate components.

Apache Struts 2 was originally known as WebWork 2. After working independently for several years, the WebWork and Struts communities joined forces to create Struts2.

Controller - MVC
The controller portion of the web tier MVC design generally is a Java Servlet. The Front Controller pattern, which is part of the J2EE Design Patterns, describes how a web tier controller should be implemented. Code that would normally need to put in every JSP page can be put in the controller servlet, which processes all the request.

In the Struts framework, the controller responsibilities are implemented by several different components, one of which is an instance of the org.apache.struts.action.ActionServlet class. The ActionServlet extends the javax.servlet.http.HttpServlet class and its responsible for packaging and routing HTTP traffic to the appropriate handler in the framework.

An org.apache.struts.action.Action class in the Struts framework is an extension of the controller component. It decouples the client request from the business model. This allows for more than a one-to-one mapping between the user request and an Action. The Action class can perform other functions, such as authorization, logging, and session validation, before invoking the business operation.
Note: In Struts 2, POJO Actions - use any class as an Action class - even the interface is optional. We can inject dependencies into Actions using Spring without glue code or red tap.

Model - MVC
In an enterprise application, the model portion of MVC pattern will be Enterprise JavaBeans. The Struts framework does not have a great deal of support in the way of model components. This is better left for EJB, CORBA, or some other type of component framework.

The EJB 2.0 made performance improvements through the use of local interfaces. However, due to the overhead of making remote calls, there still can be a significant performance impact if the web tier attempt to use entity beans directly as the model portion of the application. Therefore, JavaBeans are returned from session beans and used within the web tier. These JavaBeans are referred to as data transfer object (DTO) and are used within the views to build the dynamic contents. In a distributed application, usage of DTOs reduces the network bandwidth and improve response.

In Struts, application data is encapsulated in Java objects. User input is used to populate an action form upon form submission, business methods accept transfer objects as arguments, and custom tags are designed to manipulate JavaBeans. You can keep business logic out of the Action classes to protect against change. The Action is free to put the object in the request or session and then forward it to a JSP, where the data can be extracted and presented to the user.

View - MVC
The views within the web tier MVC pattern typically consist of HTML and JSP pages. The view components employed in a Struts application are:
  • HTML
  • DTO
  • Struts ActionForms
  • JSP
  • Custom tags
  • Java resource bundles
The Struts framework (ActionForm objects) automatically collects the input from the request and passes the data to an Action using a form bean. To keep the presentation layer decoupled from the business layer, DTO was created by using the data from the ActionForm.
Note: In Struts 2, no more ActionForms. POJO forms - use any JavaBean to capture form input or put properties directly on an Action class. Use both binary and String properties!

JSP pages make up the majority of what has to be built for the Struts view components. Combined with custom tag libraries and HTML, JSP makes it easy to provide a set of views for an application.

The Struts framework provides six core tag libraries. We may extend the Struts tags or create our own custom tags. The custom tag libraries that are included with the framework are: HTML, Bean, Logic, Template, Nested, and Tiles tag libraries.

Note: The Struts 2 adds interactivity and flexibility with AJAX tags that look and feel just like standard Struts tags.

Monday, July 21, 2008

Strike Pegger

There is a Wall Street axiom that says "90% of all the options that are bought and held to expiration will expire worthless". The Strike Pegger computes the stock price where the sum of the amount to be paid by all call and put writers is the smallest. This computed price changes as the ratio of open interest for calls and puts changes.

The Max Pain effect is the tendency for a stock’s price to gravitate towards this number as we approach the expiration date. Options officially expire the day after the third Friday of the month. Apple (AAPL) July 2008 options expired on July 18 after the closing bell. The calculated Max Pain value for AAPL is 160.



Update: AAPL closed at 165.15 on July 18.

Note: The strike pegger is more accurate for most major indexes and stocks which have large option volume, relatively low float, and have not experienced a significant and abrupt price move. The Volatility Skew, the Put/Call Ratio, and the Strike Peg should all be evaluated. Correct interpretation of the Volatility Skew is most valuable, since it effects the accuracy of the Put/Call Ratio and the Strike Peg.

Ref: http://www.optionistics.com/i/strike_pegger

Tuesday, June 3, 2008

Plasma Effects on Polymers

The interactions between polymers and plasmas and UV radiation taking places in both vacuum coating processes and hardening of sol-gels (wet-chemical coating). Reactions on polymer surfaces can be caused by high-energy electrons, ions, and neutrals, as well as by electromagnetic radiation in the deep ultra-violet (VUV, wavelength < 180 nm). The treatments cause chain scission, ablation, cross-linking, and oxidation to a depth of 5-50 nm. Important plasma parameters for a treatment are the plasma excitation frequency, the gas pressure and composition, and the treatment time.

Plasma treatments are able to introduce polar oxygen groups even if carried out in inert gases. The polymer radicals formed during the treatments are long-lived and typically react with water or oxygen from the gas background. An adhesion improvement by plasma treatments has been attributed variously to improved wettability, to surface cross-linking, or to interfacial diffusion.

The degradation of polymers caused by environmental UV radiation is the cause of yellowing of many polymer materials. In particular, polycarbonates are prone to yellowing, whereas polyacrylates are more stable to environmental radiation. The discoloration is due to photo-oxidation reactions.
Polycarbonate


Electromagnetic radiation at wavelength below 200 nm has enough energy to break polymer bond, and the photon energy of wavelength below 120 nm is sufficient to ionize most organic materials. Important for coating processes is VUV radiation at wavelength below 180 nm. Argon in a plasma shows primarily VUV emissions below 160 nm due to energy transfer from excited-state argon metastables to hydrogen from water and organic materials. Studies show that cross-linking reactions during low-pressure plasma treatments are mainly initiated by VUV radiation. Cross-linking reactions dominate on polymers containing at least one hydrogen atom bonded to adjoining carbon atoms. This is find in the thermoplastics like polyethylene, polypropylene, polystyrene, and polyamide. For PMMA and other acrylics, scission of bonds and the formation of weakly bonded layers is found after different plasma treatments.
Acrylate polymer - PMMA


Antireflective (AR) coating design for plastics
Special requirements have to be taken into account in the design of AR coatings for plastics:
  • The layer materials have to be selected in order to achieve radiation protection of interfaces or of the bulk polymer dependent on the polymer substrate type.
  • The layer materials and thicknesses have to be adjusted considering the mechanical and thermal film stresses and the total heat development during the deposition process.
  • Designs should be suitable for integrating additional functions like improved scratch resistance, barrier function, antistatic function, or hydrophobic properties.
  • Sometimes changed optical properties of interfacial zones due to plasma treatments have to be taken into account for design calculations.

Plastic eyeglasses have to be pass rigorous environmental and abrasion tests. AR layers which is preferred in quarter-half-quarter design, and hydrophobic top coatings are arranged on top of hard coatings several micrometers thick. Usually, the hard coatings are lacquers based on silanols, or organic-modified silica layers applied by vacuum deposition processes. These hard coated surfaces act as the substrate so that the vacuum deposition of the AR coating does not have to be done on the more sensitive polymer itself. AR coatings produced using wet-chemical processes comprise mainly single-layer and two-layer systems.

Friday, May 23, 2008

Laser Optics

Two-Lens Beam Expander
To change the diameter of a collimated laser beam, a simple type of Galilean telescope is used. Although a laser beam expander is nominally used on-axis, however if coma can be corrected, the system will be relatively insensitive to errors in alignment. For two-lens beam expander, two design parameters (i.e. the shapes of the two lenses) are available once the powers have been chosen. We might expect to be able to correct both the spherical aberration coefficient and coma coefficient.

Three-Lens Beam Expander
If a beam expander is composed of a plus-plus positive group. Then the coma is reduced. It can do better if the positive group is made from a plus-minus combination, in which the spherical aberration is correctable. To reduce the coma still further, we can split the two positive lenses, with a significant separation between them. It might be possible for the positive spherical aberration of the middle lens to correct the marginal ray height at the final lens.

F-Theta Lenses
Laser-printing systems generally require lenses with the property that the image size is proportional to the angle of the input beam, rather than to the tangent of this angle (which is common case when designing photographic lenses). These lenses are known as F-theta lenses. They always have an external pupil (the scanning mirror).

F-theta lenses often resemble one half of a double-Guass lens. In practice, a doublet does not provide enough parameters for an adequate F-theta lens, but a triplet would.

Lenses for Optical Disks
In optical disk players, a high-resolution lens is needed in order to read the data encoded on the disk. This lens must accurately follow the track that is recorded on the disk and therefore must be very lightweight. In practice the lenses are quite thick, and a useful improvement is obtained by the use of two aspherics.

Examples, the three-glass design by Sugiyama has a numerical aperture (NA) of 0.22 and the single aspheric lens by Arai et al has aspherics on both surfaces and a NA of 0.50. In laser physics, numerical aperture is defined slightly different, NA = n sinθ, where n is the index of refraction of the medium in which the lens is working (1.0 for air, 1.33 for pure water, and up to 1.56 for oils) and θ is the divergence of the beam. A Gaussian beam is formed as the lowest-order transverse mode in a stable laser resonator with spherical mirrors. The parameter of Gaussian beams are usually given at the 1/e fraction of maximum amplitude. The divergence of the beam is the far-field angle between the propagation direction and the distance from the beam axis for which the irradiance drops to 1/e^2 times the wavefront total irradiance.

Note: in most areas of optics, especially in microscope, θ is the half-angle of the maximum cone of light that can enter or exit the lens. In general, this is the angle of the real marginal ray in the system. In photography, instead of NA, angular acceptance of a lens is used. f/# = f/D, is the ratio of the focal length to the diameter of the entrance pupil. For small NA, f/# ~= 1 / 2NA. The f/# describes the light-gathering ability of the lens in the case where the marginal ray before (or after) the lens is collimated.

Sugiyama optical disk lens

Arai optical disk lens

Laser Diode Collimators
Since laser diodes produce a diverging beam, it is always necessary for the beam to be collimated. Collimators for laser diodes need to operate at high numerical apertures (about 0.60) to be compatible with the laser diode itself. In addition to the basic lens design (spherical aberration and coma), it is necessary to correct for the unequal divergence of the laser beam in the planes parallel and perpendicular to the emitting junction. Typically the beam widths in the two perpendicular directions are in the ration of about 2:1. Often this has to corrected so that the output beam from the collimator has a circular cross section rather than an elliptical cross section. This is commonly achieved by means of prisms arranged so that the beam diameter is increased in one direction.

Tuesday, May 13, 2008

High Dynamic Range Digital Pictures

Fujifilm F100fd - Auto mode, Multi-photometry, ISO 800


Fujifilm F100fd - Manual mode, Multi-photometry, ISO 800, Dynamic Range 400%


Hydra HDR software, using 4x pictures: [+2, +1, 0, -1], Fujifilm F100fd - Auto mode, Multi-photometry, ISO 800


Wednesday, May 7, 2008

Plastic Optics

Acrylic is known for its very good clarity and excellent transmission properties throughout the visible portion of the spectrum. This material is very hard and has very good mechanical stability. It has an index @588nm of 1.49, and an Abbe number of 55.3. A acrylic lens, when paired with an appropriate styrene lens offers an effective achromatic solution.

Polystyrene is generally less expensive than acrylic. It has a higher index @588nm of 1.59 and lower Abbe number (30.87) than acrylic. The material also tends to absorb somewhat in the deep blue spectrum. Polystyrene has a lower resistance to UV than acrylic and is more easily scratched than acrylic.

Polycarbonate is similar to polystyrene in index (@588nm, 1.586) and Abbe number (29.9). It is known for its very high impact resistance and for the ability to perform over a wide range of temperatures (-137 to +124 C). Because of its high ductility, polycarbonate is not easily machine than acrylic.



Saturday, May 3, 2008

Four- and above component Lenses

Wide-angle lenses for rangefinder camera (Biogon)
Early wide-angle lenses were often derived from standard 50mm lenses. Biogon designed for Contax at Zeiss was derived from Sonnar. Because it was for rangefinder camera. Therefore the back focus is very small.

Split Triple
Splitting an element into two elements allows the aberrations of the two to be substantially reduced from that of the original element. In the Cooke triplet, the outer crowns (rear) are often split in order to reduce the zonal spherical aberration and to thus allow the speed of the lens to be increased. Note that, as the speed is increased, the angular field coverage is reduced. The split rear-crown form is often used in camera lenses for 8mm, 16mm, small format TV, and CCD cameras, typically at the speed of about f/2.

Double-Guass (Biotar)
The Biotar or double-Guass type is a descendant of the double-meniscus anastigmat lenses. One of the many variants of the double-meniscus form consisted of outer positive singlets and inner connected negative doublets, in a symmetrical construction. These lenses had the speed and angular coverage typical of their genre, i.e., good angular coverage at a quite modest aperture. A departure from symmetry allowed the speed of the lens to be increased to f/2, and a tremendously useful and powerful design form was born. It can be made into a moderately wide-angle lens, an enlarger lens, a high-resolution objective, or a lens of extremely high speed.

The basic six-element version with the positive front element is meniscus in shape, usually of a lanthanum flint glass with an index of about 1.7 and a V value of about 48. The second element tends to be meniscus, although a plano-convex or a mild biconvex form is not unusual; its index is typically a bit lower and its V value higher than the first element. The third element usually has an index close to that of the second element, and it is a dense flint from along the glass line. The fourth element is usually biconcave and made of a glass-line flint with a slightly higher index than the third element. The fifth and sixth elements are ordinarily both biconvex and of lanthanum flint glass.

Splitting the rear singlet (seven-element) of the Biotar is an excellent way to improve on the basic configuration. It is a commonly used technique to allow an increased speed, and is often seen in faster 35mm camera lenses. For eight-element Biotar, both outer elements are split and the capability for a reasonable state of correction is achieved using only medium-high-index glass.

Double-Guass (planar)
The first double-Guass lenses were quite thin, but in 1896, Paul Rudolph described the Zeiss planar, which used thick meniscus components, with an aperture of f/4.5. The planar also uses buried surfaces, in which there is a difference of dispersion (to correct chromatic aberration) but no significant difference in refractive index. Although it is not desirable in itself, it does provide a simple way of correcting chromatic aberration without affecting the monochromatic aberrations. The planar was not immediately developed into a high-aperture lens. H.W.Lee of Taylor Hobson designed the first high-aperture double-Guass in 1920. This lens has near front-back symmetry. It uses much thicker meniscus components, which are helpful in reducing the Petzval sum and the oblique spherical aberration. At f/2 it has aberrations that are not much worse than the planar at f/4.

These lenses performed very well as normal and medium-long focus lenses for small and medium format cameras. A classic Planar design is the 105mm f2.5 Nikkor produced from 1971 to 2006.

Lenses for compact point-and-shoot camera
Modern compact 35mm cameras use lenses with focal length of 35mm. It is basically a triplet with a meniscus field flattener.