[ summary of the invention ]
In view of the above, the present invention provides a method and an apparatus for implementing a drawing tool, so as to help a user conveniently draw on a mobile device.
The specific technical scheme is as follows:
the invention provides a method for realizing a drawing tool, which comprises the following steps:
monitoring gesture operation of a user;
if effective drawing gesture operation is monitored in the drawing mode, position coordinates of all target points corresponding to the drawing gesture operation in a coordinate system adopted by an operating system are obtained;
mapping the position coordinates of the target points in a coordinate system adopted by an operating system to a coordinate system adopted by a graph drawing tool;
and calling the graph drawing tool to draw and display the target points.
According to a preferred embodiment of the invention, the method further comprises:
when the gesture operation of switching the drawing mode is monitored in the non-drawing mode, switching to the drawing mode; or,
when the gesture operation of switching the drawing mode is monitored in the drawing mode, the non-drawing mode is switched.
According to a preferred embodiment of the present invention, the gesture operation for switching the drawing mode includes:
and clicking a function key for switching the drawing mode by the user.
According to a preferred embodiment of the invention, the method further comprises: filtering the monitored drawing gesture operation in the drawing mode, and only keeping effective drawing gesture operation; wherein the filtering comprises:
and filtering out gestures which exceed the drawing range and/or filtering out gestures which do not accord with the preset drawing gesture type.
According to a preferred embodiment of the present invention, the effective drawing gesture operation includes: gesture operation of drawing lines or gesture operation of modifying drawn lines.
According to a preferred embodiment of the present invention, the gesture operation of drawing the line includes: a swipe gesture starting with a short press;
the gesture operation for modifying the drawn line comprises the following steps: a swipe gesture that starts with a long press of a point on a drawn line.
According to a preferred embodiment of the present invention, the target points corresponding to the gesture operation of drawing the line are points on the sliding trajectory corresponding to the sliding gesture starting with the short press;
and the target points corresponding to the gesture operation for modifying the drawn line are the points obtained after the drawn line style or the position is changed due to the sliding gesture started by long pressing the points on the drawn line.
According to a preferred embodiment of the present invention, a slide gesture starting with the end point of a long stroke of a drawn line causes a change in the angle of inclination or length of the drawn line;
a swipe gesture starting with a long press at the middle point of a drawn line causes a change in the position of the drawn line.
According to a preferred embodiment of the invention, the method further comprises:
if effective gesture operation is monitored in a non-drawing mode, carrying out adaptation processing on position coordinates of points on drawn lines in a coordinate system adopted by an operating system according to new service data acquired by the gesture operation;
mapping the position coordinates of the points on the drawn lines after the adaptation processing in a coordinate system adopted by an operating system into a coordinate system adopted by a graphic drawing tool;
and calling the graph drawing tool to draw and display the points on the drawn line after the adaptation processing.
According to a preferred embodiment of the present invention, the effective gesture operation includes: a slide screen operation, a zoom-in or zoom-out operation.
According to a preferred embodiment of the present invention, the adapting the position coordinates of the point on the drawn line in the coordinate system adopted by the operating system includes:
and determining the position coordinates of the drawn lines in the coordinate system adopted by the operating system according to the position coordinates of the service data on the application interface in the coordinate system adopted by the operating system after acquiring the new service data by using the recorded relative position between the drawn lines and the service data.
According to a preferred embodiment of the invention, the method further comprises:
recording the relative position between each target point and the service data displayed on the current application interface;
and carrying out persistent storage on the relative position information of the record.
According to a preferred embodiment of the invention, the method further comprises:
when the application where the drawing tool is located is started, obtaining the relative position information of the persistent storage;
determining the position coordinates of the drawn lines in the current application interface display range according to the service data displayed by the current application interface and the acquired relative position information;
mapping the determined position coordinates into a coordinate system of the graphical drawing tool;
and calling the graphic drawing tool to draw and display the drawn lines in the current application interface display range.
According to a preferred embodiment of the present invention, the drawing tool is applied to the following applications: stock class application.
The invention also provides a drawing tool implementation device, which comprises:
the monitoring unit is used for monitoring gesture operation of a user;
the acquisition unit is used for acquiring the position coordinates of each target point corresponding to the drawing gesture operation in a coordinate system adopted by an operating system if the monitoring unit monitors the effective drawing gesture operation in the drawing mode;
the mapping unit is used for mapping the position coordinates of the target points in a coordinate system adopted by the operating system to a coordinate system adopted by the graph drawing tool;
and the calling unit is used for calling the graph drawing tool to draw and display the target points.
According to a preferred embodiment of the invention, the apparatus further comprises:
the switching unit is used for switching to the drawing mode when the monitoring unit monitors gesture operation for switching the drawing mode in the non-drawing mode; or when the monitoring unit monitors the gesture operation of switching the drawing mode in the drawing mode, the non-drawing mode is switched.
According to a preferred embodiment of the present invention, the gesture operation for switching the drawing mode includes:
and clicking a function key for switching the drawing mode by the user.
According to a preferred embodiment of the invention, the apparatus further comprises:
the filtering unit is used for filtering the drawing gesture operation monitored by the monitoring unit in a drawing mode and only keeping effective drawing gesture operation; wherein the filtering comprises:
and filtering out gestures which exceed the drawing range and/or filtering out gestures which do not accord with the preset drawing gesture type.
According to a preferred embodiment of the present invention, the effective drawing gesture operation includes: gesture operation of drawing lines or gesture operation of modifying drawn lines.
According to a preferred embodiment of the present invention, the gesture operation of drawing the line includes: a swipe gesture starting with a short press;
the gesture operation for modifying the drawn line comprises the following steps: a swipe gesture that starts with a long press of a point on a drawn line.
According to a preferred embodiment of the present invention, the target points corresponding to the gesture operation of drawing the line are points on the sliding trajectory corresponding to the sliding gesture starting with the short press;
and the target points corresponding to the gesture operation for modifying the drawn line are the points obtained after the drawn line style or the position is changed due to the sliding gesture started by long pressing the points on the drawn line.
According to a preferred embodiment of the present invention, a slide gesture starting with the end point of a long stroke of a drawn line causes a change in the angle of inclination or length of the drawn line;
a swipe gesture starting with a long press at the middle point of a drawn line causes a change in the position of the drawn line.
According to a preferred embodiment of the invention, the apparatus further comprises:
the adaptation unit is used for adapting the position coordinates of the points on the drawn lines in the operating system according to the new service data acquired by the gesture operation if the monitoring unit monitors the effective gesture operation in the non-drawing mode;
the mapping unit is further used for mapping the position coordinates of the points on the drawn lines after the adaptation processing in a coordinate system adopted by an operating system into a coordinate system adopted by a graphic drawing tool;
and the calling unit is also used for calling the graphic drawing tool to draw and display the points on the drawn line after the adaptation processing.
According to a preferred embodiment of the present invention, the effective gesture operation includes: a slide screen operation, a zoom-in or zoom-out operation.
According to a preferred embodiment of the present invention, the adapting unit is specifically configured to determine, after the new service data is obtained, a position coordinate of the drawn line in a coordinate system used by the operating system according to a position coordinate of the service data in the coordinate system used by the operating system on the application interface, by using the recorded relative position between the drawn line and the service data.
According to a preferred embodiment of the invention, the apparatus further comprises:
the storage unit is used for recording the relative position between each target point and the service data displayed on the current application interface; and carrying out persistent storage on the relative position information of the record.
According to a preferred embodiment of the invention, the apparatus further comprises:
the starting processing unit is used for acquiring the relative position information stored in a persistent mode when the application where the drawing tool is located is started; determining the position coordinates of the drawn lines in the current application interface display range according to the service data displayed by the current application interface and the acquired relative position information;
the mapping unit is further configured to map the position coordinates determined by the starting processing unit into a coordinate system adopted by the graph drawing tool;
the calling unit is further used for calling the graphic drawing tool to draw and display the drawn lines in the current application interface display range.
According to a preferred embodiment of the present invention, the application of the graphic drawing tool comprises: stock class application.
According to the technical scheme, the position coordinates of all target points corresponding to the drawing gesture operation in the coordinate system adopted by the operation system are mapped into the coordinate system adopted by the graph drawing tool through monitoring the effective drawing gesture operation of the user, and the graph drawing tool is called to draw and display all the target points, so that the user can conveniently draw on the mobile equipment through the gesture operation.
[ detailed description ] embodiments
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in detail with reference to the accompanying drawings and specific embodiments.
The method provided by the invention is mainly applied to mobile terminals with touch screens, including but not limited to smart phones, tablet computers, PDAs (personal digital assistants), and the like.
A mobile terminal architecturally contains basic components such as a bus, a processing system, a memory system, one or more input/output systems, and a communication interface. The bus may include one or more conductors that facilitate communication between the components of the mobile terminal. Processing systems include various types of processors or microprocessors that execute instructions, process processes, or threads. The storage system may include a dynamic memory such as a Random Access Memory (RAM) for storing dynamic information, a static memory such as a Read Only Memory (ROM) for storing static information, and a mass storage including a magnetic or optical recording medium and a corresponding drive. The input system is used for a user to input information to the mobile terminal, such as a handwriting pen, a touch screen, a voice recognition system, a biometric system, or the like. The output system includes a touch screen, a speaker, etc. for outputting information. The communication interface is used to enable the mobile terminal to communicate with other devices. The communication interfaces may be connected to the network by wired, wireless, or optical connections.
In addition, the mobile terminal includes operating system software for managing system resources and controlling the operation of other programs, and application software for implementing specific functional modules.
The method and the device for realizing the drawing tool can be loaded on various application software on the mobile terminal, such as stock ticket application software, weather application software, icon application software and the like. The method and the device for realizing the drawing tool can draw lines on the basis of the data provided by the application software, thereby helping a user to analyze the data. In the embodiment of the present invention, stock application software is taken as an example for description, and the scenes of other application software are similar.
Fig. 1 is a flow chart of a main method provided by an embodiment of the present invention, and as shown in fig. 1, the method may include the following steps:
in 101, gesture operation of a user is monitored.
At 102, if a valid drawing gesture operation is monitored in the drawing mode, position coordinates of each target point corresponding to the drawing gesture operation in a coordinate system adopted by an operating system are obtained.
In the embodiment of the present invention, an application currently used by a user (hereinafter, referred to as a current application for short) may be switched between two modes due to the fact that the application is equipped with the drawing tool provided by the present invention: a drawing mode and a non-drawing mode. In order to ensure that the existing functions of the current application are used as the main functions of the current application, for example, the stock class application software also performs stock information display, the current application is in the non-drawing mode by default, that is, the current application is in the non-drawing mode by default after being started.
The switching from the non-drawing mode to the drawing mode may be triggered by a gesture operation of the user. Namely, in the non-drawing mode, if the gesture operation of switching the drawing mode is monitored, the drawing mode is switched to. And when the gesture operation of switching the drawing mode is monitored in the drawing mode, switching to a non-drawing mode.
The gesture operation for switching the drawing mode can be preset, and only the gesture operation is different from the gesture operation of the current application and the existing functions of the operating system of the mobile terminal. In the embodiment of the present invention, as shown in fig. 2a, when stock data is displayed in a current application, a function button for switching a drawing mode, that is, a button marked with a "draw line" in the drawing, is present on an interface, and when a user needs to perform a drawing operation, the function button is clicked to switch from a non-drawing mode to a drawing mode. When switching to the drawing mode, the above function button becomes "back", and when the user clicks the function button again, as shown in fig. 2b, switches back to the non-drawing mode.
The term "effective" here means that the monitored drawing gesture operation needs to be filtered, and only the effective drawing gesture operation is retained, which will be described in the following embodiments.
Additionally, in embodiments of the present invention, effective drawing gesture operations may include, but are not limited to: the gesture operation of drawing the line, the gesture operation of modifying the drawn line and the gesture operation of deleting the drawn line.
In 103, the position coordinates of the respective target points in the coordinate system employed by the operating system are converted into position coordinates in the coordinate system employed by the graphic drawing tool.
First, position coordinates of each target point corresponding to the drawing gesture operation acquired by 102 in a coordinate system adopted by an operating system are recorded, and taking an upper left corner of a screen as an origin for example, the position of an x coordinate and a y coordinate of a point touched by the user gesture operation on the screen is recorded by taking an Android operating system as an example.
The graphics rendering tool used in the embodiments of the present invention may be, but is not limited to, OpenGL, that is, OpenGL may provide an interface to the graphics rendering tool, so that the graphics rendering tool calls the interface to complete the rendering and displaying of the target point.
Since the coordinate origin of a graphics rendering tool such as OpenGL is different from the coordinate origin of the Android system, for example, the origin of the coordinate system of OpenGL is at the lower left corner, the position coordinates of the target point need to be converted into position coordinates in the coordinate system adopted by the graphics rendering tool such as OpenGL.
At 104, a graphical rendering tool is invoked to render and expose the target points.
Several usage scenarios to which the present invention relates are described in detail below by way of several embodiments.
Fig. 3 is a flowchart of a method for drawing a line according to an embodiment of the present invention, in this embodiment, it is assumed that a user has switched a current application to a drawing mode, and the user is to draw the line in the drawing mode, as shown in fig. 3, the process may specifically include the following steps:
in 301, gesture operations of a user are monitored.
In 302, the gesture operations that are heard are filtered in drawing mode.
In this step, a drawing range in the drawing mode may be preset, that is, a range is preset on the currently applied interface, and only drawing gestures performed within the range are valid, and drawing gestures beyond the range are filtered out.
In addition, some effective drawing gesture types can be preset, the gesture types can be gesture types capable of drawing straight lines, broken lines, curves and the like, and gestures which do not accord with the drawing gesture types are filtered out.
In 303, the position coordinates of the target points corresponding to the gesture operation of the monitored drawing line in the coordinate system of the operating system are converted into the position coordinates in the coordinate system of OpenGL.
In this embodiment, if a swipe gesture starting with a short press is monitored and the swipe gesture is retained after being filtered by 302, it may be determined that the gesture operation for drawing the line is monitored, and each point on the swipe trajectory is the target point.
Taking the Android operating system as an example, since the coordinate system of the operating system is based on the upper left corner as the origin of coordinates and pixels as a unit, and OpenGL is based on the center point as the origin of coordinates and the height of the whole view as a unit, the position coordinates of each target point in the coordinate system of the Android operating system need to be converted into the position coordinates in the coordinate system of OpenGL. If the position coordinate of a certain target point in the coordinate system of the Android operating system is (xPosi, yPosi), the position coordinate (x, y) in the coordinate system of OpenGL obtained after conversion is:
<math>
<mrow>
<mi>X</mi>
<mo>=</mo>
<mfrac>
<mrow>
<mi>x</mi>
<mi>P</mi>
<mi>o</mi>
<mi>s</mi>
<mi>i</mi>
</mrow>
<mrow>
<mfrac>
<mrow>
<mi>o</mi>
<mi>r</mi>
<mi>i</mi>
<mi>C</mi>
<mi>a</mi>
<mi>n</mi>
<mi>v</mi>
<mi>a</mi>
<mi>s</mi>
<mi>W</mi>
<mi>i</mi>
<mi>d</mi>
<mi>t</mi>
<mi>h</mi>
</mrow>
<mn>2</mn>
</mfrac>
<mo>-</mo>
<mn>1</mn>
</mrow>
</mfrac>
<mo>×</mo>
<mi>w</mi>
<mi>i</mi>
<mi>d</mi>
<mi>t</mi>
<mi>h</mi>
<mi>R</mi>
<mi>a</mi>
<mi>t</mi>
<mi>i</mi>
<mi>o</mi>
</mrow>
</math>
<math>
<mrow>
<mi>Y</mi>
<mo>=</mo>
<mrow>
<mo>(</mo>
<mn>1</mn>
<mo>-</mo>
<mfrac>
<mrow>
<mi>y</mi>
<mi>P</mi>
<mi>o</mi>
<mi>s</mi>
<mi>i</mi>
</mrow>
<mfrac>
<mrow>
<mi>o</mi>
<mi>r</mi>
<mi>i</mi>
<mi>C</mi>
<mi>a</mi>
<mi>n</mi>
<mi>v</mi>
<mi>a</mi>
<mi>s</mi>
<mi>H</mi>
<mi>e</mi>
<mi>i</mi>
<mi>g</mi>
<mi>h</mi>
<mi>t</mi>
</mrow>
<mn>2</mn>
</mfrac>
</mfrac>
<mo>)</mo>
</mrow>
<mo>×</mo>
<mi>h</mi>
<mi>e</mi>
<mi>i</mi>
<mi>g</mi>
<mi>h</mi>
<mi>t</mi>
<mi>R</mi>
<mi>a</mi>
<mi>t</mi>
<mi>i</mi>
<mi>o</mi>
</mrow>
</math>
wherein oriCanvasWidth is the view width, oriCanvasHeight is the view height, width ratio is the width coefficient of OpenGL, and height ratio is the height coefficient of OpenGL.
In 304, OpenGL is invoked to render and display the target points.
In 305, the relative position between each target point and the service data displayed on the current application interface is recorded.
Since the position coordinates of each target point in the coordinate system adopted by the Android operating system are absolute position coordinates, and the service data is gradually updated actually, for example, stock software is used, k-line data is usually displayed, and the k-line data is continuously updated in the time axis direction, as shown in fig. 2b, the latest service data displayed on the current interface is k-line data of 12 months and 2 days, but by tomorrow, the displayed latest service data becomes k-line data of 12 months and 3 days, which causes the image to move to the left as a whole. If only the position coordinates (i.e. absolute position coordinates) of each target point in the coordinate system adopted by the Android operating system are recorded, the method is no longer applicable to the updated service data.
In order to overcome the above problem, when the service data is updated, the line drawn by the user can still be correctly displayed, and the relative positions between each target point and the service data displayed on the current application interface need to be recorded.
In 306, the recorded relative position information is persistently stored.
Persistent storage in this step means that the storage remains after the current application is closed, and the content of the persistent storage will always exist unless the user manually deletes the content of the persistent storage.
Through the flow shown in fig. 3, the user may draw a line on the current application interface, and the user may draw a line on the interface shown in fig. 2b, and the result may be as shown in fig. 4 a. The drawing of the line is not limited to the straight line segment shown in fig. 4a, and may be a broken line, a curved line, or the like.
Fig. 5 is a flowchart of a method for modifying a drawn line according to an embodiment of the present invention, in this embodiment, it is assumed that a user has switched a current application to a drawing mode, and the user wants to modify the drawn line in the drawing mode, as shown in fig. 5, the process may include the following steps:
in 501, gesture operation of a user is monitored.
At 502, the gesture operations that are heard are filtered in a drawing mode.
Similar to step 302 in fig. 3, a drawing range and a drawing gesture type may be set in advance, and if the gesture operation range for the user to modify the existing line exceeds the drawing range, or the gesture operation range for modifying the existing line does not conform to the preset drawing gesture type, the gesture operation range and the gesture type are filtered out.
At 503, determining the gesture operation type of the drawn line, if the operation is the operation of deleting the drawn line, executing 504; if the operation is to modify the drawn line, 505 is performed.
In this embodiment, the gesture operation type of the drawn line may be preset, and may include but is not limited to: modify the style or position of the drawn line, delete the drawn line, etc. In addition, the gesture operation for modifying the drawn line can also be preset. For example, a slide gesture starting with a long press on an end point of a drawn line is set to cause a change in the tilt angle or length of the drawn line, i.e., a user may drag the tilt angle or length of the drawn line by pressing on an end point of the drawn line. For another example, a slide gesture starting with a long press on the middle point of a drawn line causes a change in the position of the drawn line, i.e., the user can move the drawn line to a position where the user's finger leaves the screen by pressing on the middle position of the drawn line.
For another example, the long press of the drawn line to call out the submenu and the selection of the delete option on the submenu is set as the gesture operation for deleting the drawn line, or the selection of the drawn line and the click of the delete button on the interface is set as the gesture operation for deleting the drawn line. In the former case, when the user presses the drawn line for a long time, a sub-menu may pop up on the interface, where there is a delete option, and when the user clicks the delete option, the drawn line is deleted. In the latter case, in the drawing mode, there is a delete button on the interface, and when the user selects the drawn line by clicking or the like, the user deletes the drawn line if the delete button is clicked again.
In 504, the drawn line is deleted, and OpenGL may not display the deleted line, and the processing of the gesture operation is ended.
In 505, position coordinates of each target point corresponding to the gesture operation for modifying the drawn line in a coordinate system adopted by the Android operating system are obtained.
The target points corresponding to the gesture operation for modifying the drawn line may be the points obtained after the drawn line style or the position is changed due to the slide gesture started by long pressing the points on the drawn line.
At 506, the position coordinates of the target point in the coordinate system adopted by the Android operating system are converted into the position coordinates in the coordinate system of OpenGL.
In 507, OpenGL is invoked to render and display the target points.
At 508, the relative position between each target point and the service data displayed on the current application interface is recorded.
In 509, the recorded relative position information is stored persistently.
Through the flow shown in fig. 5, the user may operate on the current application interface to draw a line, for example, the user may modify one of the straight line segments shown in fig. 4a as follows:
the first modification: holding down an end point of the straight line segment for dragging changes the angle of inclination and/or length of the straight line segment as shown in fig. 4 b. In fig. 4B, the user's finger slides to the position shown by point B while pressing the end point a of the drawn line, and the angle of inclination and length of the line can be modified by the dragging, the dotted line segment represents the drawn line before modification, the solid line segment represents the drawn line after modification, and the thick arrow represents the sliding trajectory of the user's finger.
The second modification: the middle position of the straight line segment is pressed and dragged to change the position of the straight line segment, as shown in fig. 4 c. In fig. 4C, the user slides the finger from the point C to the point D by pressing the middle of the drawn line, and the position of the straight line segment can be moved by the sliding. The dotted line segment in the figure represents the drawn line before modification, the solid line segment represents the drawn line after modification, and the thick arrow represents the sliding trajectory of the user's finger.
A third modification: and calling up the submenu by pressing the drawn line for a long time and selecting a deletion option on the submenu to delete the drawn line. As shown in fig. 4d, when the user presses the drawn line for a long time, a sub-menu pops up on the interface, the sub-menu includes a delete option, and when the user clicks the delete option, the drawn line can be deleted.
When a user draws a line, the user may encounter the problem that, because the screen is small, the granularity of the service data is often large when the service data is displayed, or the displayed service data is limited, which causes that the user often cannot accurately position the line when drawing the line, and the service data displayed on the screen needs to be zoomed or moved. For this requirement, the user is required to switch to the non-drawing mode. Fig. 6 is a flowchart of a processing method in the non-drawing mode according to an embodiment of the present invention, where it is assumed that a user has switched a current application to the non-drawing mode, as shown in fig. 6, the process may include the following steps:
in 601, gesture operations of a user are monitored.
At 602, gesture operations heard in a non-drawing mode are filtered.
Similarly, the area range and the type of the gesture operation in the non-drawing mode can be preset, gesture operations beyond the area range and not conforming to the type are filtered, and only effective gesture operations are reserved.
In 603, according to the new service data obtained by the monitored gesture operation, the position coordinates of the points on the drawn line in the coordinate system adopted by the operating system are adapted.
Gesture operations monitored herein may include, but are not limited to, a slide screen operation, a zoom-in or zoom-out operation.
If the operation is the sliding screen operation, the current application needs to acquire new service data according to the sliding screen operation, and the acquired service data is determined according to the sliding amplitude. For example, if the user slides to the left on the application interface shown in fig. 4a (different from fig. 4a, the operation is in the non-drawing mode), and the sliding amplitude corresponds to the business data of one week, the business data of the new week, i.e., the k-line data of 12 months 3 to 12 months 9, needs to be acquired, so that the business data on the screen uniformly moves to the left for one week, and the k-line data of 9 months 6 to 12 months 9 is displayed. Since it is possible that the user has drawn a line on the interface, after moving the screen, an adaptation process is also required for the position of the drawn line.
If the operation is the amplification operation, the current application needs to acquire the service data with finer granularity according to the amplitude of the amplification operation. That is, the range of service data displayed on the screen becomes smaller, but the granularity is finer. Also, since it is possible that the user has drawn a line on the interface, after moving the screen, an adaptation process is also required for the position of the drawn line.
If the operation is a zoom-out operation, the current application needs to obtain a larger range of service data according to the magnitude of the zoom-out operation, that is, the range of the service data displayed on the screen is enlarged, but the granularity is coarser. This case also requires an adaptation process of the position of the drawn line.
The service data acquisition caused by the above operations is the prior art and is not described in detail, and the step focuses on the adaptation processing of the position of the drawn line. The adapting process actually determines the position coordinates of the drawn lines according to the position coordinates of the service data after operations such as moving the screen, enlarging or reducing and the like are performed by using the recorded relative positions between the drawn lines and the service data. The position coordinates are those in a coordinate system employed by the operating system.
In 604, the position coordinates of the points on the drawn line after the adaptation processing in the coordinate system adopted by the Android operating system are mapped to the coordinate system of OpenGL.
In 605, OpenGL is invoked to draw and display the point on the drawn line after the adaptation process.
It should be noted that, after the current application interface is operated in the manner shown in fig. 6, the flow shown in fig. 3 or fig. 5 may be further combined. For example, after a user amplifies a screen, a drawn line is modified according to service data with finer granularity; and after the user moves the screen, further drawing lines according to the newly acquired service data, and the like.
As can be seen from the processes shown in fig. 3 and fig. 5, the relative position between the drawn line and the business data is stored persistently, so that when the user starts and displays the interface of the current application next time, the process executed can be as shown in fig. 7, and includes the following steps:
in 701, the relative location information of the persistent storage is obtained.
In 702, according to the service data displayed by the current application interface and the relative position information, the position coordinates of the drawn line within the display range of the current application interface are determined.
Since the relative position between the drawn line and the service data is stored persistently, the position coordinate of the drawn line can be obtained according to the position coordinate (in the coordinate system of the operating system) of the service data displayed by the current application interface, and the obtained position coordinate of the drawn line is only within the display range of the current application interface.
In 703, the position coordinates determined in step 702 are converted into position coordinates in the coordinate system of OpenGL.
In 704, OpenGL is invoked to draw and display the drawn lines within the current application interface display range.
Through the flow shown in fig. 7, after the user finishes drawing the line, if the application software is opened next time, the drawn line can still be displayed.
Fig. 8 is a structural diagram of an apparatus according to an embodiment of the present invention, where the apparatus may be disposed in application software with drawing requirements, and as shown in fig. 8, the apparatus may include: the monitoring unit 01, the obtaining unit 02, the mapping unit 03 and the calling unit 04 may further include a switching unit 05, a filtering unit 06, an adapting unit 07, a storing unit 08 and a starting processing unit 09. The main functions of each constituent unit are as follows:
the monitoring unit 01 is responsible for monitoring gesture operations of a user.
If the monitoring unit 01 monitors an effective drawing gesture operation in the drawing mode, the obtaining unit 02 obtains the position coordinates of each target point corresponding to the drawing gesture operation in the coordinate system adopted by the operating system. Wherein the effective drawing gesture operation may include: a gesture operation of drawing a line, a gesture operation of modifying a drawn line, or a gesture operation of deleting a drawn line. The gesture operation of drawing the line comprises the following steps: a swipe gesture starting with a short press; the gesture operation for modifying the drawn line comprises the following steps: a swipe gesture that starts with a long press of a point on a drawn line. The gesture operation for deleting the drawn line comprises the following steps: and (3) gesture operation of calling out the submenu and selecting a deletion option on the submenu by long-pressing the drawn line, or gesture operation of clicking a deletion button on the interface after the drawn line is selected.
Each target point corresponding to the gesture operation for drawing the line is each point on the sliding track corresponding to the sliding gesture starting with the short press; and each target point corresponding to the gesture operation for modifying the drawn line is each point obtained after the drawn line style or position is changed due to the sliding gesture started by long pressing the point on the drawn line.
A slide gesture starting with the end point of the long-pressed drawn line causes a change in the angle of inclination or length of the drawn line; a swipe gesture starting with a long press at the middle point of a drawn line causes a change in the position of the drawn line.
The mapping unit 03 is responsible for mapping the position coordinates of the target points in the coordinate system used by the operating system into the coordinate system used by the graphical rendering tool. The calling unit 04 is responsible for calling a graphic drawing tool to draw and display each target point. The graphics rendering tool used in the embodiments of the present invention may be, but is not limited to, OpenGL, that is, OpenGL may provide an interface to the graphics rendering tool, so that the graphics rendering tool calls the interface to complete the rendering and displaying of the target point.
The application software on which the present apparatus is mounted can be switched between two modes, i.e., between a drawing mode and a non-drawing mode, and the switching is performed by the switching unit 05. Specifically, when the monitoring unit 01 monitors a gesture operation for switching the drawing mode in the non-drawing mode, the switching unit 05 switches to the drawing mode; alternatively, when the monitoring unit 01 monitors a gesture operation for switching the drawing mode in the drawing mode, the switching unit 05 switches to the non-drawing mode.
The gesture operation for switching the drawing mode can be preset, and only the gesture operation is different from the gesture operation of the current application and the existing functions of the operating system of the mobile terminal. For example, clicking a function button for switching the drawing mode by the user may be used.
The filtering unit 06 is responsible for filtering the drawing gesture operations monitored by the monitoring unit 01 in the drawing mode, and only effective drawing gesture operations are reserved; wherein filtering may include, but is not limited to: and filtering out gestures which exceed the drawing range and/or filtering out gestures which do not accord with the preset drawing gesture type.
If the monitoring unit 01 monitors an effective gesture operation in the non-drawing mode, where the effective gesture operation may include a screen sliding operation, an enlargement or reduction operation, and the like, the adapting unit 07 may adapt the position coordinates of the point on the drawn line in the coordinate system adopted by the operating system according to the new service data acquired by the gesture operation. Accordingly, the mapping unit 03 maps the position coordinates of the points on the drawn line after the adaptation process in the coordinate system adopted by the operating system into the coordinate system of the graphic drawing tool. And the calling unit 04 calls a graphic drawing tool to draw and display the points on the drawn line after the adaptation processing.
Specifically, the adapting unit 07 may determine, after acquiring the new service data, the position coordinates of the drawn line in the coordinate system adopted by the operating system according to the position coordinates of the service data on the application interface in the coordinate system adopted by the operating system, by using the recorded relative position between the drawn line and the service data.
The storage unit 08 is responsible for recording the relative positions of each target point on the drawn line and the service data displayed on the current application interface; and storing the recorded relative position information in a persistent mode.
When the application where the drawing tool is located is started, the start processing unit 09 may obtain the persistently stored relative position information; and determining the position coordinates of the drawn lines in the current application interface display range according to the service data displayed by the current application interface and the acquired relative position information. At this time, the mapping unit 03 maps the position coordinates determined by the start processing unit 09 into the coordinate system employed by the graphic drawing tool. The calling unit 04 calls a graphic drawing tool to draw and display the drawn lines in the current application interface display range.
As can be seen from the above description, the method and apparatus provided by the present invention can have the following advantages:
1) the invention monitors the effective drawing gesture operation of the user in the drawing mode, maps the position coordinates of each target point corresponding to the drawing gesture operation in the coordinate system adopted by the operating system into the coordinate system adopted by the graphic drawing tool, and calls the graphic drawing tool to draw and display each target point, thereby realizing that the user conveniently draws on the mobile equipment through the gesture operation.
2) The user can modify and delete the drawn graph in the drawing mode, so that the graph drawing is more flexible and accurate.
3) In the non-drawing mode, a user can move, enlarge and reduce the current application interface through effective gestures, and drawing and modifying the graph on the basis, so that the graph is drawn more accurately.
4) And the graphic data drawn by the user is stored persistently, so that the drawn graphic can be displayed adaptively according to the latest business data when the user starts the application software again.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described device embodiments are merely illustrative, and for example, the division of the units is only one logical functional division, and other divisions may be realized in practice.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.
The integrated unit implemented in the form of a software functional unit may be stored in a computer readable storage medium. The software functional unit is stored in a storage medium and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network device) or a processor (processor) to execute some steps of the methods according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-only memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.