1. Technical Field
Embodiments of the present disclosure relate to computer graphics technology, and particularly to an electronic device and method for controlling movement of images on screen.
2. Description of Related Art
Scalable vector graphics (SVG) is an XML-based vector image format for two-dimensional graphics. SVG images and their behaviors are defined in XML text files. This means that they can be searched, indexed, scripted, and, if need be, compressed. The SVG images can be created and zoomed (zoom in or zoom out) randomly.
However, a position of the SVG image cannot be changed when the SVG image is zoomed in on a display screen, thus if the SVG image is zoomed to be larger than the display screen, a portion of the SVG image cannot be displayed on the display screen. Therefore, a more efficient method for controlling movement of SVG images is desired.
All of the processes described below may be embodied in, and fully automated via, functional code modules executed by one or more general purpose electronic devices or processors. The code modules may be stored in any type of non-transitory computer-readable medium or other storage device. Some or all of the methods may alternatively be embodied in specialized hardware. Depending on the embodiment, the non-transitory computer-readable medium may be a hard disk drive, a compact disc, a digital video disc, a tape drive or other storage medium.
The display device 20 displays scalable vector graphics (SVG) images, and the input device 22 may be a mouse or a keyboard for data input. The storage device 23 may be a non-volatile computer storage chip that can be electrically erased and reprogrammed, such as a hard disk or a flash memory card.
In one embodiment, the image controlling system 24 is used to control movements of the SVG image by assigning the occurrence of specified events in relation to a mouse (mouse events), such as a on-click event, a move event, and a mouse release event (e.g., release the left button of the mouse), to an event detection area of the SVG image, and updating a position of the SVG image on the display device 20 in response to receiving a specified event (e.g., a moving operation of the mouse) in the event detection area of the SVG image. The image controlling system 24 may include computerized instructions in the form of one or more programs that are executed by the at least one processor 25 and stored in the storage device 23 (or memory). A detailed description of the image controlling system 24 is given in the following paragraphs.
In step S10, the setting module 240 determines an image display area 31 and an event detection area 32 for an SVG image 30 on the display device 20. For example, as shown in
The image display area 31 is used to display the SVG image 30. The event detection area 32 is used to detect specified mouse events, such as an on-click event (e.g., an onmousedown event), a move event (e.g. an onmousemove event), and a mouse release event (e.g., an onmouseup event). In one embodiment, the boundaries of the image display area 31 and the event detection area 32 are virtual areas on the display device 20, which are not visible to a user.
The setting module 240 further determines an element parameter (or also known as an element variable or a node variable) for storing specified elements of the image display area 31. The specified elements of the image display area 31 may include properties (or attributes) and operating methods of the SVG image 30. For example, the properties of the SVG image 30 may include a width and a height of the SVG image 30. The operating methods of the SVG image 30 may include a drawing method for drawing the SVG image 30 based on the properties of the SVG image 30, and a display method for displaying the SVG image 30 in the image display area 31 of the display device 20. The properties of the SVG image 30 are changed when the SVG image 30 is zoomed in or zoomed out.
In step S11, the first detecting module 241 detects a mouse event in the event detection area 32, and determines an updated position of the image display area 31 according to a current position of the mouse event. The current position of the mouse event is determined as being current coordinates of a cursor (or a pointer) of a mouse on the display device 20. In detail, the first detecting module 241 calculates a translation vector according to the current coordinates of the cursor of the mouse and previous coordinates of the cursor of the mouse at a previous time point, and determines the updated position of the image display area 31 by moving the image display area 31 according to the translation vector (moving the image display area 31 to the current coordinates of the cursor of the mouse). The SVG image 30 is moved synchronously with the image display area 31. For example, if P1(x1, y1) represents the previous coordinates of the cursor, and P2(x2, y2) represents the current coordinates of the cursor, the translation vector is calculated according to a formula of 11 {right arrow over (A)}=((x2−x1), (y2−y1)). The coordinate “(x2−x1)” represents an X-axis value of the translation vector, and the coordinate “(y2−y1)” represents a Y-axis value of the translation vector.
The first detecting module 241 assigns the specified elements of the image display area 31 to the element parameter when an on-click event is detected in the event detection area 32, and adds the specified elements in the element parameter to a sub-node of a parent element of the image display area 31. After adding the specified elements in the element parameter to the sub-node of the parent element of the image display area 31, the operations performed on the element parameter are repeated in operations being performed on the image display area 31.
Furthermore, the first detecting module 241 may set a property of a pointer event of the element parameter as none. If the property of the pointer event is set as none, the first detecting module 241 does not detect an on-click event. If the property of the pointer event is set as all, the first detecting module 241 starts to detect the on-click event.
The first detecting module 241 determines whether the element parameter is existed when a move event is detected in the event detection area 32. If the element parameter is existed, the first detecting module 241 determines that the move event happens after the on-click event, that is, the user first clicks the mouse then drags the mouse. The first detecting module 241 assigns the current coordinates of the cursor of the mouse to the element parameter, calculates a translation vector according to the current coordinates of the cursor of the mouse and the previous coordinates of the cursor of the mouse, and determines an updated position of the image display area 31 by moving the image display area 31 according to the translation vector. The SVG image 30 is moved with the image display area 31.
In step S12, the displaying module 242 displays the SVG image 30 at the updated position of the image display area 31 (i.e., a refresh operation), to generate a drag operation of the SVG image 30 on the display device 20.
In step S13, the second detecting module 243 stops the drag operation of the SVG image 30 on the display device 20 when a mouse release event is detected in the event detection area 32. In detail, the second detecting module 243 determines whether the element parameter is existed when the mouse release event is detected in the event detection area 32. If the element parameter is existed, the second detecting module 243 determines that the mouse release event happens after the on-click event. Then, the second detecting module 243 sets the property of the pointer event of the element parameter as all, and deletes the element parameter by assigning a null value to the element parameter.
In other embodiments, the image controlling system 24 may be used to control movements of other images which have features similar to those of SVG images 30, such as raster graphics.
It should be emphasized that the above-described embodiments of the present disclosure, particularly, any embodiments, are merely possible examples of implementations, merely set forth for a clear understanding of the principles of the disclosure. Many variations and modifications may be made to the above-described embodiment(s) of the disclosure without departing substantially from the spirit and principles of the disclosure. All such modifications and variations are intended to be included herein within the scope of this disclosure and the present disclosure and protected by the following claims.
Number | Date | Country | Kind |
---|---|---|---|
2012103100549 | Aug 2012 | CN | national |