Wednesday, February 17, 2010

SVG format

SVG is a language for describing two-dimensional graphics in XML [XML10]. SVG allows for three types of graphic objects: vector graphic shapes (e.g., paths consisting of straight lines and curves), images and text. Graphical objects can be grouped, styled, transformed and composited into previously rendered objects. The feature set includes nested transformations, clipping paths, alpha masks, filter effects and template objects.[1]
File extension SVG is mostly used in describing two-dimensional vector graphics in XML format. SVG stands for Scalable Vector Graphics. Data can be stored on its own file or can be embedded in a web page. However, not all web browsers are capable of interpreting it. File of this extension can be static or animated images. Since this is in XML format, SVG files can be opened by using text editors. These are images written as text. Vector images use geometrical figures represented by mathematical equations as oppose to raster images that uses pixels represented with different colors to create an image.[2]
With SVG, it can be fill (i.e., paint the interior) or stroke (i.e., paint the outline) of shapes and text using one of the following[3]
• color (using or the 'solidColor' element)
• gradients (linear or radial)
• patterns (vector or image, possibly tiled)


Advantages of using SVG over other image formats (like JPEG and GIF) [4]
• SVG is an open standard
• SVG files are pure XML
• SVG files can be read and modified by a large range of tools (e.g. notepad)
• SVG files are smaller and more compressible than JPEG and GIF images
• SVG images are scalable
• SVG images can be printed with high quality at any resolution
• SVG images are zoomable (and the image can be zoomed without degradation)
• SVG works with Java technology

The biggest advantage SVG has over Flash is the compliance with other standards (e.g. XSL and the DOM). Flash relies on proprietary technology that is not open source.




Security considerations
SVG documents may be transmitted in compressed form using gzip compression. For systems which employ MIME-like mechanisms, such as HTTP, this is indicated by the Content-Transfer-Encoding header; for systems which do not, such as direct file system access, this is indicated by the filename extension and by the Macintosh File Type Codes. In addition, gzip compressed content is readily recognized by the initial byte sequence [5].
Compressed SVG files are typically 50 to 80 percent smaller than SVG files and are automatically decompressed by the Adobe SVG Viewer with no noticeable delay to the user [6].
SVG documents may reference external media such as images, audio, video, style sheets, and scripting languages. Scripting languages are executable content. In this case, the security considerations in the Media Type registrations for those formats shall apply. if the processor follows only the normative semantics of this specification, this content will be outside the SVG namespace and shall be ignored. Only in the case where the processor recognizes and processes the additional content, or where further processing of that content is dispatched to other processors, would security issues potentially arise. And in that case, they would fall outside the domain of this registration document [5].
Simple svg example for Text[7]




It was the best of times


It was the worst of times.



The text element is used to write text at a location. The location is given in absolute terms with the x and y attributes or a relative location with dx and dy attributes.


Simple svg example for Circle(shape)[8]






The SVG element is used to create a circle. The cx and cy attributes define the x and y coordinates of the center of the circle. If cx and cy are omitted, the circle's center is set to (0, 0). The r attribute defines the radius of the circle.
Manipulate SVG Document From XML[9]
To manipulate SVG documents from XML it is needed to Encoding the Parts Catalog into XML.The parts catalog document is an XML document having as its root a element. This element inherits the xlink:extended characteristics by including the xlink:type attribute set to "extended." The root element also contains another attribute, the xml:base, which defines the base document location for all the contained locators. The xml:base attribute value points to the SVG document that encodes the small motor illustration(as an example).
xlink:type="extended"
xml:base="figure.svg"
xlink:title="motor">
... Locators ...

Each part contained in the motor assembly is modeled as an xlink:locator element that refers to a numbered circle pointing to a part in the exploded view illustration. A contained part element (a locator) contains a part description, a link to a more detailed view and quantity. The element points to a more detailed external parts document if a part is composed of other parts (i.e., if it is an assembly itself). That external view is another XML document encoded the same way .


1
Cylinder head



[1]Scalable Vector Graphics (SVG) 1.1 Specification W3C Recommendation 14 January 2003
[2] http://svg.extensionfile.net/
[3] http://www.w3.org/TR/SVG11/pservers.html
[4] http://www.w3schools.com/svg/svg_intro.asp
[5] http://www.w3.org/TR/SVGMobile12/mimereg.html
[6] http://www.adobe.com/svg/illustrator/compressedsvg.html
[7] http://www.svgbasics.com/simple_text.html
[8] http://www.w3schools.com/svg/svg_example.asp
[9] http://www.xml.com/lpt/a/67

Monday, February 8, 2010

Spring MVC framework



From the time that a request is received by Spring until the time that a response is returned to the client, many pieces of the Spring MVC framework are involved. The process starts when a client (typically a web browser) sends a request (1) .The first component to receive the request is Spring’s DispatcherServlet. Like most Java-based MVC frameworks, Spring MVC funnels requests through a single front controller servlet. A front controller is a common web-application pattern where a single servlet delegates responsibility for a request to other components of an application to perform the actual processing. In the case of Spring MVC, DispatcherServlet is the front controller.
The Spring MVC component that is responsible for handling the request is a Controller. To figure out which controller should handle the request, DispatcherServlet starts by querying one or more HandlerMappings (2). A HandlerMapping typically performs its job by mapping URL patterns to Controller objects.
Once the DispatcherServlet has a Controller object, it dispatches the request to the Controller to perform whatever business logic it was designed to do (3) (Actually, a well-designed Controller performs little or no business logic itself and instead delegates responsibility for the business logic to one or more service objects.) Upon completion of business logic, the Controller returns a ModelAndView object (4) to the DispatcherServlet.
The ModelAndView can either contain a View object or a logical name of a View object. If the ModelAndView object contains the logical name of a View, the Dispatcher- Servlet queries a ViewResolver (5) to look up the View object that will render the response. Finally, the DispatcherServlet dispatches the request to the View object (6) indicated by the ModelAndView object. The View object is responsible for rendering a response back to the client.

Spring

Spring is an open-source framework; created by Rod Johnson .It was created to address the complexity of enterprise application development. Spring makes it possible to use plain-vanilla JavaBeans to achieve things that were previously only possible with EJBs. However, spring’s usefulness is not limited to server-side development. Any Java application can benefit from spring in terms of simplicity, testability, and loose coupling. Put simply, spring is a lightweight inversion of control and aspect-oriented container framework.

Key features of Spring

Lightweight—spring is lightweight in terms of both size and overhead. The entire spring framework can be distributed in a single JAR file that weighs in at just over 1 MB. And the processing overhead required by spring is negligible. What’s more, spring is nonintrusive: objects in a Spring-enabled application typically have no dependencies on spring specific classes.

Inversion of control—Spring promotes loose coupling through a technique known as inversion of control (IoC). When IoC is applied, objects are passively given their dependencies instead of creating or looking for dependent objects for themselves. You can think of IoC as JNDI in reverse—instead of an object looking up dependencies from a container, the container gives the dependencies to the object at instantiation without waiting to be asked.

Aspect-oriented—Spring comes with rich support for aspect-oriented programming that enables cohesive development by separating application business logic from system services (such as auditing and transaction management). Application objects do what they’re supposed to do—perform business logic—and nothing more. They are not responsible for (or even aware of) other system concerns, such as logging or transactional support.

Container—spring is a container in the sense that it contains and manages the life cycle and configuration of application objects. It can be configured to how your beans should be created—either creates one single instance of your bean or produce a new instance every time one is needed based on a configurable prototype—and how they should be associated with each other. Spring should not, however, be confused with traditionally heavyweight EJB containers, which are often large and cumbersome to work with.

Framework—spring makes it possible to configure and compose complex applications from simpler components. In Spring, application objects are composed declaratively, typically in an XML file. Spring also provides much infrastructure functionality (transaction management, persistence framework integration, etc.), leaving the development of application logic to you.

All of these attributes of Spring enable to write code that is cleaner, more manageable, and easier to test. They also set the stage for a variety of sub frameworks within the greater spring framework.

Spring modules





The Spring framework is made up of seven well-defined modules (sub frameworks) .When taken as a whole; these modules give you everything you need to develop enterprise-ready applications. But you do not have to base your application fully on the Spring framework. You are free to pick and choose the modules that suit your application and ignore the rest. All of Spring’s modules are built on top of the core container. The container defines how beans are created, configured, and managed—more of the nuts-and-bolts of Spring. .These modules will provide the frameworks with which will build the application’s services, such as AOP and persistence pr MVC.


The core container: Spring’s core container provides the fundamental functionality of the Spring framework. In this module you’ll find Spring’s Bean Factory, the heart of any Spring-based application. A Bean Factory is an implementation of the factory pattern that applies IoC to separate the application’s configuration and dependency specifications from the actual application code.

The Spring MVC framework: Spring comes with a full-featured Model/View/Controller (MVC) framework for building web applications. Although Spring can easily be integrated with other MVC frameworks, such as Struts, Spring’s MVC framework uses IoC to provide for a clean separation of controller logic from business objects. It also allows to declaratively binding request parameters to the business objects.