Xoetrope

 Wiki : XSvgMagnifier

HomePage :: Categories :: PageIndex :: RecentChanges :: RecentlyCommented :: Login/Register
Carousel logo

XSvgMagnifier

class com.xoetrope.svg.XSvgMagnifier

The XSvgMagnifier class combines the XSvgMagnifyingWindow and XSvgMagnifyingGlass classes into one by allow the user to select between both means of magnification during run time.

Magnifier

Web Start

1. Example


import com.kitfox.svg.SVGDiagram;
import com.xoetrope.swing.svg.XSvgImageMap;
import com.xoetrope.swing.svg.XSvgMagnifier;
import java.awt.Color;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.net.URL;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class TestSvgMagnifier implements MouseMotionListener
{
    private static XSvgMagnifier magnifier;

    public TestSvgMagnifier()
    {
        URL file = getClass().getResource ("images/image1.svg");
        XSvgImageMap svgImage = new XSvgImageMap();
        JFrame frame = new JFrame("SVG Test");
        frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
        frame.setBackground (Color.WHITE);
        frame.setSize(800, 600);
        frame.add(svgImage);
        svgImage.setURL (file);
        SVGDiagram diagram = svgImage.display ();
        svgImage.getSvgPanel ().addMouseMotionListener (this);       
        magnifier = new XSvgMagnifier(diagram, frame);
        frame.setVisible(true);
    }
   
    public static void main(String [] args)
    {
        new TestSvgMagnifier();
    }
        
    public void mouseMoved (MouseEvent e)
    {
        magnifier.setZoomPoint(e.getPoint());
    }

    public void mouseDragged (MouseEvent e){}
}


In the above example, a new instance of XSvgMagnifier is created and passed an SVGDiagram instance from the XSvgImageMap class. The JFrame object used to contain the XSvgImageMap object is also passed. The TestSvgMagnifier class implements the MouseMotionListener interface. The mouseMoved method of the interface calls the setZoomPoint method of the XSvgMagnifier class, passing the current mouse location to it. The current mouse location is used to determine the part of the SVG image that is zoomed and displayed in either the window or the magnifying glass.

2. Constructor


public XSvgMagnifier ( JFrame imageFrame, XSvgImageMap svgImage)


The constructor takes a JFrame instance which should point to the frame that contains the XSvgImageMap instance. The glass pane of the frame is needed to display the magnifying glass.

3. Methods


1. setZoomPoint

public void setZoomPoint( Point p )


Used to set which part of the SVG image will be zoomed. This can be added to a mouseMotionListener, there-by utilising the mouse to select the part of the image that is zoomed.

2. setWindowScale

public void setWindowScale(float scale)


Sets the scale factor of the XSvgMagnifyingWindow object used within this class.

3. setGlassScale

public void setGlassScale(float scale)


Sets the scale factor of the XSvgMagnifyingGlass object used within this class.

4. actionPerformed

public void actionPerformed (ActionEvent e)


Provides an action listener for the JRadioButton objects used to select which magnification mode is currently in use.

5. setMagGlassAnimation

public void setMagGlassAnimation (int i)


Used to set whether a fade-out or fade-in animation is to be run on the magnifying glass.

{{image link="http://www.sourceforge.net/projects/xui" url="http://sourceforge.net/sflogo.php?group_id=76693

There are no comments on this page. [Add comment]

Page was generated in 0.5898 seconds