CN111857703A - Matching method and device for layers in interface and electronic equipment - Google Patents

Matching method and device for layers in interface and electronic equipment Download PDF

Info

Publication number
CN111857703A
CN111857703A CN202010761354.3A CN202010761354A CN111857703A CN 111857703 A CN111857703 A CN 111857703A CN 202010761354 A CN202010761354 A CN 202010761354A CN 111857703 A CN111857703 A CN 111857703A
Authority
CN
China
Prior art keywords
layer
checked
standard
layers
accepted
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010761354.3A
Other languages
Chinese (zh)
Inventor
蔡宇
吴瑞卿
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing IQIYI Science and Technology Co Ltd
Original Assignee
Beijing IQIYI Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing IQIYI Science and Technology Co Ltd filed Critical Beijing IQIYI Science and Technology Co Ltd
Priority to CN202010761354.3A priority Critical patent/CN111857703A/en
Publication of CN111857703A publication Critical patent/CN111857703A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/34Graphical or visual programming
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/22Matching criteria, e.g. proximity measures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/38Creation or generation of source code for implementing user interfaces

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Evolutionary Computation (AREA)
  • Evolutionary Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Artificial Intelligence (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Human Computer Interaction (AREA)
  • Image Analysis (AREA)

Abstract

The embodiment of the invention provides a method and a device for matching layers in an interface and electronic equipment, wherein the method comprises the following steps: acquiring attribute information of each layer to be checked in an interface to be checked, and acquiring attribute information of each standard layer in a standard interface; sequencing the image layers to be checked according to the positions of the image layers to be checked and accepted and a preset sequencing rule; traversing each layer to be checked and accepted according to the sequencing result, and calculating the matching degree between the currently traversed layer to be checked and accepted and each unmatched standard layer according to the type and the position of each layer to be checked and each standard layer when one layer to be checked and accepted is traversed; determining a standard layer matched with a currently traversed layer to be checked; and continuously traversing the next layer to be checked until all the layers to be checked are completely traversed. Because the corresponding relation of the layers in the application program interface and the corresponding interface of the design draft does not need to be identified manually, the determining efficiency of the corresponding relation between the layer to be checked and the standard layer can be greatly improved.

Description

Matching method and device for layers in interface and electronic equipment
Technical Field
The invention relates to the technical field of application program development, in particular to a method and a device for matching layers in an interface and electronic equipment.
Background
In the process of developing the application program interface, interface development is carried out according to the requirements of the design draft completed in advance, and after the development is completed, in order to detect whether the application program interface meets the requirements of the design draft, the application program interface needs to be checked and accepted.
The current way of accepting an application program interface is dependent on manual work. Specifically, after acquiring the interfaces corresponding to the application program interface and the design draft, the acceptance staff manually identifies the corresponding relationship between the application program interface and the layers in the interface corresponding to the design draft, and then compares the pattern of the layers and the distance between the layers of the application program interface with the pattern of the corresponding layers and the distance between the layers in the design draft according to the corresponding relationship, marks out the layers with wrong patterns and/or distances, and obtains the acceptance result.
Therefore, in the current acceptance mode, the corresponding relation between the application program interface and the layer in the interface corresponding to the design draft needs to be manually identified, so that the determining efficiency of the corresponding relation is very low.
Disclosure of Invention
The embodiment of the invention aims to provide a method and a device for matching layers in an interface and electronic equipment, so as to improve the determining efficiency of the corresponding relation of the layers in the interface. The specific technical scheme is as follows:
in a first aspect, an embodiment of the present invention provides a method for matching layers in an interface, where the method includes:
acquiring attribute information of each layer to be checked and accepted in an interface to be checked and acquiring attribute information of each standard layer in a standard interface, wherein the standard interface is an interface defined by a design draft corresponding to the interface to be checked and accepted, and the attribute information comprises size, position and type;
sequencing the layers to be checked according to the positions of the layers to be checked and accepted and a preset sequencing rule to obtain a sequencing result;
traversing each layer to be checked and accepted according to the sequencing result, and calculating the matching degree between the currently traversed layer to be checked and accepted and each unmatched standard layer according to the types and the positions of each layer to be checked and accepted and each standard layer when one layer to be checked and accepted is traversed;
determining a standard layer matched with the currently traversed to-be-checked image layer based on the matching degree, recording the corresponding relation between the currently traversed to-be-checked image layer and the standard layer, and determining that the standard layer is matched;
and continuously traversing the next layer to be checked and accepted, and returning to the step of calculating the matching degree between the currently traversed layer to be checked and accepted and each unmatched standard layer according to the types and the positions of the layers to be checked and accepted and the standard layers until all the layers to be checked and accepted are traversed, so as to obtain the corresponding relation between the layers to be checked and the standard layers.
Optionally, before the step of traversing the layers to be checked and accepted according to the sorting result, the method further includes:
determining an adjacent layer of each standard layer according to the position of each standard layer;
the step of calculating the matching degree between the currently traversed to-be-checked image layer and each currently unmatched standard image layer according to the types and the positions of the to-be-checked image layers and the standard image layers comprises the following steps:
determining adjacent layers of the currently traversed layer to be checked according to the positions of the layers to be checked;
and respectively calculating the matching degree between the currently traversed layer to be checked and accepted and each currently unmatched standard layer based on the types of the currently traversed layer to be checked and the adjacent layer thereof and the types of each currently unmatched standard layer and the adjacent layer thereof.
Optionally, the step of calculating, based on the currently traversed layer to be checked and the type of the layer adjacent to the currently traversed layer, and the type of each currently unmatched standard layer and the type of each layer adjacent to the currently unmatched standard layer, a matching degree between the currently traversed layer to be checked and each currently unmatched standard layer respectively includes:
determining whether the type of the currently traversed graph layer to be checked is the same as the type of each currently unmatched standard graph layer;
if the current traversed graph layer to be checked is different from the unmatched standard graph layer of the different types, determining that the matching degree between the currently traversed graph layer to be checked and the unmatched standard graph layer of the different types is a first matching degree;
if the type of the adjacent layer of the currently traversed layer to be checked is the same as that of the adjacent layer of each unmatched target standard layer, determining whether the type of the adjacent layer of the currently traversed layer to be checked is the same as that of the adjacent layer of each unmatched target standard layer, wherein the target standard layer is a standard layer with the same type as that of the currently traversed layer to be checked;
if the types of the adjacent layers of the currently traversed to-be-checked graph layer are the same as those of the adjacent layers of the target standard graph layer, determining that the matching degree between the currently traversed to-be-checked graph layer and the target standard graph layer is a second matching degree;
if the types of the adjacent layers of the currently traversed to-be-checked image layer are different from the types of the adjacent layers of the target standard image layer, determining that the matching degree between the currently traversed to-be-checked image layer and the target standard image layer is a third matching degree;
and if the type of the adjacent layer of the currently traversed to-be-checked graph layer is not completely the same as that of the adjacent layer of the target standard graph layer, determining the matching degree between the currently traversed to-be-checked graph layer and the target standard graph layer based on the number of the layers with the same type.
Optionally, the attribute information further includes a transparency;
before the step of sequencing the image layers to be checked and accepted according to the positions of the image layers to be checked and accepted and a preset sequencing rule to obtain a sequencing result, the method further comprises the following steps:
and removing the layers to be checked and accepted and the layers with the transparency of 100% in the standard layers.
Optionally, the attribute information further includes a color;
before the step of sequencing the image layers to be checked and accepted according to the positions of the image layers to be checked and accepted and a preset sequencing rule to obtain a sequencing result, the method further comprises the following steps:
screening out layers only including background colors from the layers to be checked and accepted and the standard layers to serve as target layers;
for each target layer, determining whether the layer comprising the target layer exists or not according to the size and the position of each layer to be checked and accepted or each standard layer;
and if so, removing the target layer under the condition that the background color of the layer with the minimum area in the layers including the target layer is the same as the background color of the target layer.
Optionally, the step of obtaining attribute information of each layer to be checked and accepted in the interface to be checked and obtaining attribute information of each standard layer in the standard interface includes:
calling a preset view interface, and extracting attribute information of each layer to be checked and accepted in the interface to be checked and accepted;
analyzing each standard layer in the standard interface to obtain attribute information of each standard layer in the standard interface.
Optionally, the analyzing each standard layer in the standard interface to obtain the attribute information of each standard layer in the standard interface includes:
analyzing a standard interface, and determining whether each layer in the standard interface has a mask and is a composite layer;
cutting a layer with a mask according to the size of the mask to obtain a corresponding standard layer, and determining attribute information of the standard layer;
and decomposing the composite layer aiming at the composite layer to obtain each standard layer forming the composite layer, and determining the attribute information of each standard layer.
In a second aspect, an embodiment of the present invention provides an apparatus for matching layers in an interface, where the apparatus includes:
the attribute information acquisition module is used for acquiring attribute information of each layer to be checked in an interface to be checked and accepted and acquiring attribute information of each standard layer in a standard interface, wherein the standard interface is an interface defined by a design draft corresponding to the interface to be checked and accepted, and the attribute information comprises size, position and type;
the layer sequencing module is used for sequencing the layers to be checked and accepted according to the positions of the layers to be checked and accepted and a preset sequencing rule to obtain a sequencing result;
the matching degree calculation module is used for traversing each layer to be checked and accepted according to the sorting result, and calculating the matching degree between the currently traversed layer to be checked and each unmatched standard layer according to the types and the positions of each layer to be checked and accepted and each standard layer when one layer to be checked and accepted is traversed;
the corresponding relation determining module is used for determining a standard layer matched with the currently traversed image layer to be checked based on the matching degree, recording the corresponding relation between the currently traversed image layer to be checked and the standard layer, and determining that the standard layer is matched; and continuously traversing the next layer to be checked and accepted, and returning to the step of calculating the matching degree between the currently traversed layer to be checked and accepted and each unmatched standard layer according to the types and the positions of the layers to be checked and accepted and the standard layers until all the layers to be checked and accepted are traversed, so as to obtain the corresponding relation between the layers to be checked and the standard layers.
Optionally, the apparatus further comprises:
an adjacent layer determining module, configured to determine, according to the position of each standard layer, an adjacent layer of each standard layer before the step of traversing each layer to be checked according to the sorting result;
the matching degree calculation module includes:
the adjacent layer determining unit is used for determining adjacent layers of the currently traversed layer to be checked according to the positions of the layers to be checked;
and the matching degree determining unit is used for respectively calculating the matching degree between the currently traversed layer to be checked and each currently unmatched standard layer based on the types of the currently traversed layer to be checked and the adjacent layers thereof and the types of each currently unmatched standard layer and the adjacent layers thereof.
Optionally, the matching degree determining unit includes:
the first type determining subunit is used for determining whether the type of the currently traversed graph layer to be checked is the same as the type of each currently unmatched standard graph layer;
a first matching degree determining subunit, configured to determine, if the two layers are different, that a matching degree between the currently traversed to-be-checked graph layer and an unmatched standard graph layer of a different type is a first matching degree;
a second type determining subunit, configured to determine, if the types of the adjacent layers of the currently traversed layer to be checked are the same as the types of the adjacent layers of each unmatched target standard layer, where the target standard layer is a standard layer with the same type as the currently traversed layer to be checked;
a second matching degree determining subunit, configured to determine, if the type of the adjacent layer of the currently traversed to-be-checked image layer is the same as the type of the adjacent layer of the target standard image layer, that the matching degree between the currently traversed to-be-checked image layer and the target standard image layer is a second matching degree;
a third matching degree determining subunit, configured to determine, if the types of adjacent layers of the currently traversed to-be-checked image layer are both different from the types of adjacent layers of the target standard image layer, that the matching degree between the currently traversed to-be-checked image layer and the target standard image layer is a third matching degree;
and the fourth matching degree determining subunit is configured to determine, based on the number of layers of the same type, the matching degree between the currently traversed to-be-checked map layer and the target standard map layer if the type of the adjacent layer of the currently traversed to-be-checked map layer is not completely the same as the type of the adjacent layer of the target standard map layer.
In a third aspect, an embodiment of the present invention provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor and the communication interface complete communication between the memory and the processor through the communication bus;
a memory for storing a computer program;
and the processor is configured to implement the steps of the method for matching layers in an interface according to any one of the first aspect when executing a program stored in the memory.
In a fourth aspect, an embodiment of the present invention provides a computer-readable cache medium, where a computer program is cached in the computer-readable cache medium, and when being executed by a processor, the computer program implements the steps of the method for matching layers in an interface according to any one of the first aspect.
In a fifth aspect, an embodiment of the present invention provides a computer program product including instructions, which when run on a computer, cause the computer to perform the steps of the method for matching layers in an interface according to any one of the first aspect.
In the scheme provided by the embodiment of the invention, the electronic equipment can acquire attribute information of each layer to be checked and accepted in an interface to be checked and accepted and acquire attribute information of each standard layer in a standard interface, wherein the standard interface is an interface defined by a design draft corresponding to the interface to be checked and accepted, and the attribute information comprises size, position and type; sequencing the layers to be checked according to the positions of the layers to be checked and accepted and a preset sequencing rule to obtain a sequencing result; traversing each layer to be checked and accepted according to the sequencing result, and calculating the matching degree between the currently traversed layer to be checked and accepted and each unmatched standard layer according to the types and the positions of each layer to be checked and accepted and each standard layer when one layer to be checked and accepted is traversed; determining a standard layer matched with the currently traversed to-be-checked image layer based on the matching degree, recording the corresponding relation between the currently traversed to-be-checked image layer and the standard layer, and determining that the standard layer is matched; and continuously traversing the next layer to be checked and accepted, and returning to the step of calculating the matching degree between the currently traversed layer to be checked and accepted and each unmatched standard layer according to the type and the position of each layer to be checked and each standard layer until all the layers to be checked and accepted are traversed, so as to obtain the corresponding relation between each layer to be checked and each standard layer. Because the corresponding relation of the layers in the application program interface and the corresponding interface of the design draft does not need to be identified manually, the determining efficiency of the corresponding relation between the layer to be checked and the standard layer can be greatly improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below.
Fig. 1 is a flowchart of a method for matching layers in an interface according to an embodiment of the present invention;
fig. 2(a) is a schematic diagram of an interface to be checked according to an embodiment of the present invention;
FIG. 2(b) is a schematic diagram of a standard interface provided by an embodiment of the present invention;
FIG. 3 is a flow chart of a matching degree determination method according to the embodiment shown in FIG. 1;
FIG. 4 is a flowchart illustrating a layer cleaning method according to the embodiment shown in FIG. 1;
FIG. 5 is a flow chart illustrating a method of parsing a standard interface according to the embodiment shown in FIG. 1;
fig. 6 is a schematic structural diagram of a matching apparatus for a layer in an interface according to an embodiment of the present invention;
FIG. 7 is a diagram illustrating a specific structure of the matching degree calculating module 630 in the embodiment shown in FIG. 6;
fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be described below with reference to the drawings in the embodiments of the present invention.
In order to improve the determination efficiency of the corresponding relation between the layer to be checked and the standard layer when the application program interface is checked, embodiments of the present invention provide a method and an apparatus for matching layers in an interface, an electronic device, a computer-readable storage medium, and a computer program product. The following describes a method for matching layers in an interface according to an embodiment of the present invention.
The method for matching the layers in the interface provided by the embodiment of the invention can be used for determining the corresponding relation between the layer to be checked and the standard layer at will. The electronic device may be a mobile phone, a computer, a tablet computer, or other electronic devices, and is not limited herein. For clarity of description, hereinafter referred to as electronic device.
As shown in fig. 1, a method for matching layers in an interface includes:
s101, acquiring attribute information of each layer to be checked and accepted in an interface to be checked and accepted, and acquiring attribute information of each standard layer in a standard interface;
the standard interface is an interface defined by a design draft corresponding to the interface to be checked and accepted, and the attribute information comprises size, position and type.
S102, sequencing the image layers to be checked according to the positions of the image layers to be checked and a preset sequencing rule to obtain a sequencing result;
s103, traversing each layer to be checked and accepted according to the sequencing result, and calculating the matching degree between the currently traversed layer to be checked and accepted and each unmatched standard layer according to the type and the position of each layer to be checked and accepted and each standard layer when one layer to be checked and accepted is traversed;
s104, determining a standard layer matched with the currently traversed image layer to be checked based on the matching degree, recording the corresponding relation between the currently traversed image layer to be checked and the standard layer, and determining that the standard layer is matched;
and S105, continuously traversing the next layer to be checked, and returning to the step of calculating the matching degree between the currently traversed layer to be checked and each unmatched standard layer according to the types and the positions of the layers to be checked and the standard layers until the traversal of all the layers to be checked is finished, so as to obtain the corresponding relation between the layers to be checked and the standard layers.
Therefore, in the scheme provided by the embodiment of the invention, the electronic device can acquire the attribute information of each layer to be checked in the interface to be checked, and acquire the attribute information of each standard layer in the standard interface, wherein the standard interface is an interface defined by a design draft corresponding to the interface to be checked, and the attribute information includes a size, a position and a type; sequencing the layers to be checked according to the positions of the layers to be checked and accepted and a preset sequencing rule to obtain a sequencing result; traversing each layer to be checked and accepted according to the sequencing result, and calculating the matching degree between the currently traversed layer to be checked and accepted and each unmatched standard layer according to the types and the positions of each layer to be checked and accepted and each standard layer when one layer to be checked and accepted is traversed; determining a standard layer matched with the currently traversed to-be-checked image layer based on the matching degree, recording the corresponding relation between the currently traversed to-be-checked image layer and the standard layer, and determining that the standard layer is matched; and continuously traversing the next layer to be checked and accepted, and returning to the step of calculating the matching degree between the currently traversed layer to be checked and accepted and each unmatched standard layer according to the type and the position of each layer to be checked and each standard layer until all the layers to be checked and accepted are traversed, so as to obtain the corresponding relation between each layer to be checked and each standard layer. Because the corresponding relation of the layers in the application program interface and the corresponding interface of the design draft does not need to be identified manually, the determining efficiency of the corresponding relation between the layer to be checked and the standard layer can be greatly improved.
When the corresponding relationship between the layers to be checked and the standard layers needs to be determined, the electronic device may execute step S101, that is, obtain attribute information of each layer to be checked in the interface to be checked, and obtain attribute information of each standard layer in the standard interface, where the standard interface is an interface defined by the design draft corresponding to the interface to be checked. The attribute information of the layer may include size, position, type, style, and the like of the layer, and the style may include information such as font, font size, border shape, color, and the like. The types of layers may include text types and picture types.
The graph layer to be checked is a graph layer in the interface to be checked, the standard graph layer is a graph layer in the standard interface defined by the design draft, and the graph layers in the two interfaces are distinguished conveniently without other limiting meanings.
After obtaining the attribute information, the electronic device may determine a corresponding relationship between each to-be-checked image layer and each standard image layer based on the size, the position, and the type of each to-be-checked image layer and each standard image layer, and specifically, the electronic device may sort each to-be-checked image layer according to the position of each to-be-checked image layer and a preset sorting rule to obtain a sorting result, that is, execute the step S102.
In order to facilitate subsequent traversal, the electronic device may sort the layers to be checked according to a preset sorting rule and the positions of the layers to be checked, so as to obtain a sorting result. The preset ordering rule may be ordering according to positions in the interface from top to bottom, from left to right, and the like, which are all reasonable.
After the sorting result is obtained, the electronic device may traverse each layer to be checked and accepted according to the sorting result, that is, the sorting result traverses from the first layer to be checked and accepted to the last layer to be checked and accepted. When traversing each layer to be checked and accepted, the electronic device can calculate the matching degree between the currently traversed layer to be checked and accepted and each unmatched standard layer according to the type and the position of each layer to be checked and each standard layer.
For the first traversed layer to be checked, the standard layers that are not matched currently are all the standard layers, that is, for the first traversed layer to be checked, the matching degree between the layer to be checked and all the standard layers needs to be calculated. For the non-first traversed graph layer to be checked, the currently unmatched standard graph layer is the currently remaining standard graph layer of which the corresponding relation is not determined yet in all the standard graph layers. That is to say, for the to-be-checked image layer which is not the first traversal, the matching degree between the to-be-checked image layer and each currently remaining standard image layer for which the corresponding relationship has not been determined needs to be calculated.
In an embodiment, the electronic device may determine, according to the position of each layer to be checked, a to-be-checked image layer around the currently traversed to-be-checked image layer, and similarly, may also determine, according to the position of each standard image layer, a standard image layer around each standard image layer. Furthermore, whether the type of the currently traversed to-be-checked graph layer is the same as the type of each currently unmatched standard graph layer or not can be compared, whether the type of the standard graph layer around the currently traversed to-be-checked graph layer is the same as the type of the standard graph layer around each unmatched standard graph layer or not can be compared, and the matching degree is determined according to the two comparison results.
Next, in step S104, the electronic device may determine a standard layer matching the currently traversed to-be-checked image layer based on the matching degree, record a corresponding relationship between the currently traversed to-be-checked image layer and the standard layer, and determine that the standard layer is matched. After the matching degree is determined, the electronic device can determine the standard layer matched with the currently traversed layer to be checked and accepted, and record a matching result, namely the corresponding relation between the currently traversed layer to be checked and accepted and the standard layer.
As an implementation manner, the electronic device may determine the standard layer with the highest matching degree as the standard layer corresponding to the currently traversed layer to be checked. At this time, the standard layer, that is, the matched standard layer, may not be calculated again when traversing the next layer to be checked, so as to reduce the calculation amount and improve the matching efficiency.
And then, the electronic equipment can continuously traverse the next layer to be checked and returns to the step of calculating the matching degree between the currently traversed layer to be checked and each unmatched standard layer according to the types and the positions of the layers to be checked and the standard layers until all the layers to be checked and accepted are traversed, so that the corresponding relation between each layer to be checked and each standard layer can be obtained.
As an implementation manner of the embodiment of the present invention, before the step of traversing the layers to be checked according to the sorting result, the method may further include:
and determining the adjacent layer of each standard layer according to the position of each standard layer.
Since the matching degree between adjacent layers needs to be calculated when calculating the matching degree between the layers, in order to improve the traversal efficiency, the electronic device may determine the adjacent layer of each standard layer according to the position of each standard layer before traversing each to-be-checked layer according to the sorting result. The adjacent layer may be a layer adjacent to the standard layer in 4 directions, i.e., up, down, left, and right directions, in the interface, or 2 or 3 of the four directions may be selected as the adjacent layer.
Correspondingly, the step of calculating the matching degree between the currently traversed to-be-checked image layer and each currently unmatched standard image layer according to the types and the positions of each to-be-checked image layer and each standard image layer may include:
determining an adjacent layer of the current layer to be checked according to the position of each layer to be checked; and respectively calculating the matching degree between the currently traversed layer to be checked and accepted and each currently unmatched standard layer based on the types of the currently traversed layer to be checked and the adjacent layer thereof and the types of each currently unmatched standard layer and the adjacent layer thereof.
The electronic device may determine, according to the position of each layer to be checked, an adjacent layer of the currently traversed layer to be checked, where the adjacent layer may be a layer that is adjacent to the currently traversed layer to be checked in 4 directions, i.e., up, down, left, and right, in the interface, and may also select, as the adjacent layer, 2 or 3 layers that are adjacent to each other in the four directions. In order to facilitate the determination of the matching degree, the number of the adjacent layers of the currently traversed to-be-checked graph layer and the adjacent layers of the standard graph layer and the corresponding direction in the interface may be kept consistent.
After determining the adjacent layer of the currently traversed to-be-checked image layer, the electronic device may respectively calculate a matching degree between the currently traversed to-be-checked image layer and each currently unmatched standard image layer based on the currently traversed to-be-checked image layer and the type of the adjacent layer thereof, and the type of each currently unmatched standard image layer and the type of the adjacent layer thereof.
For example, in the interface 200 to be checked and accepted shown in fig. 2(a), the adjacent layers of the currently traversed map layer 210 to be checked and accepted include an adjacent layer 211, an adjacent layer 212, and an adjacent layer 213. In the standard interface 201 shown in fig. 2(b), the unmatched standard layers include a standard layer 220, a standard layer 221, a standard layer 222, and a standard layer 223. The electronic device may determine matching degrees between the currently traversed to-be-checked graph layer 210 and the standard graph layer 220, the standard graph layer 221, the standard graph layer 222, and the standard graph layer 223, respectively.
When the matching degree between the currently traversed to-be-checked graph layer 210 and the standard graph layer 220 is calculated, it may be determined whether the type of the currently traversed to-be-checked graph layer 210 is the same as the type of the standard graph layer 220, and whether the types of the adjacent graph layer 211, the adjacent graph layer 212, and the adjacent graph layer 213 are the same as the types of the standard graph layer 221, the standard graph layer 222, and the standard graph layer 223, respectively, so as to obtain the matching degree.
It can be seen that, in this embodiment, the electronic device may determine, according to the position of each layer to be checked, an adjacent layer of the currently traversed layer to be checked, and calculate the matching degree between the currently traversed layer to be checked and each currently unmatched standard layer based on the type of the currently traversed layer to be checked and the adjacent layer thereof, and the type of each currently unmatched standard layer and the adjacent layer thereof, so that the currently traversed layer to be checked and the adjacent layer thereof may be considered at the same time, and the accuracy of the matching degree calculation is ensured.
As an implementation manner of the embodiment of the present invention, as shown in fig. 3, the step of calculating, based on the types of the currently traversed layer to be checked and the adjacent layer thereof, and the types of each currently unmatched standard layer and the adjacent layer thereof, a matching degree between the currently traversed layer to be checked and each currently unmatched standard layer may include:
s301, determining whether the type of the currently traversed image layer to be checked is the same as that of each currently unmatched standard image layer, and if so, executing the step S302; if the two are the same, executing step S303;
whether the type of the currently traversed to-be-checked graph layer is the same as the type of each currently unmatched standard graph layer directly determines whether the currently traversed to-be-checked graph layer and each currently unmatched standard graph layer can be matched, for example, if the type of the currently traversed to-be-checked graph layer is a text graph layer and the type of a certain unmatched standard graph layer is a picture graph layer, the two are obviously unmatched.
The electronic device may first determine whether the type of the currently traversed to-be-checked map layer is the same as the type of each currently unmatched standard map layer, and if so, execute step S302. If the two types of pre-layers are the same, the step S303 is continuously performed to determine whether the types of the adjacent pre-layers are the same.
S302, determining the matching degree between the currently traversed image layer to be checked and received and unmatched standard image layers with different types as a first matching degree;
if the type of the currently traversed layer to be checked is different from the type of the standard layer, it is indicated that the matching degree between the currently traversed layer to be checked and the standard layer is the lowest, and it may be determined that the matching degree is the first matching degree, for example, the first matching degree may be 0.
S303, determining whether the type of the currently traversed adjacent layer of the to-be-checked graph layer is the same as the type of the adjacent layer of each unmatched target standard graph layer, and if the type of the currently traversed adjacent layer of the to-be-checked graph layer is the same as the type of the adjacent layer of the target standard graph layer, executing step S304; if the type of the currently traversed adjacent layer of the to-be-checked graph layer is different from the type of the adjacent layer of the target standard graph layer, executing step S305; if the type of the adjacent layer of the currently traversed to-be-checked image layer is not completely the same as the type of the adjacent layer of the target standard image layer, executing step S306;
if the type of the currently traversed layer to be checked is the same as that of a certain unmatched standard layer, for convenience of description, the standard layer is called a target standard layer, that is, the target standard layer is a standard layer with the same type as that of the currently traversed layer to be checked.
At this time, the electronic device may continue to determine whether the type of the currently traversed adjacent layer of the to-be-checked layer is the same as the type of the adjacent layer of each unmatched target standard layer. For example, there are 3 target standard layers, which are target standard layer 1, target standard layer 2, and target standard layer 3. The electronic device may respectively determine whether the type of the adjacent layer of the currently traversed layer to be checked is the same as the type of the adjacent layer of the target standard layer 1; judging whether the type of the adjacent layer of the currently traversed to-be-checked image layer is the same as that of the adjacent layer of the target standard image layer 2; and judging whether the type of the adjacent layer of the currently traversed layer to be checked is the same as that of the adjacent layer of the target standard layer 3.
When the type of the adjacent layer is judged, in order to ensure the accuracy of the result, the position of the currently traversed adjacent layer of the layer to be checked may be consistent with the position of the adjacent layer of the target standard layer. For example, the adjacent layers of the currently traversed layer to be checked include a layer above the currently traversed layer to be checked and a layer on the right side, so that the electronic device may compare the type of the layer above the currently traversed layer to be checked with the type of the layer above the target standard layer, and similarly compare the type of the layer on the right side of the currently traversed layer to be checked with the type of the layer on the right side of the target standard layer.
S304, determining the matching degree between the currently traversed image layer to be checked and received and the target standard image layer as a second matching degree;
if the type of the currently traversed layer to be checked is the same as that of the target standard layer, and the type of the adjacent layer of the currently traversed layer to be checked is also the same as that of the adjacent layer of the target standard layer, which indicates that the types of the currently traversed layer to be checked and the layers around the currently traversed layer to be checked are both the same as those of the target standard layer and the layers around the target standard layer, it may be determined that the matching degree between the currently traversed layer to be checked and the standard layer is the highest, and the electronic device may execute step S304, that is, it may be determined that the matching degree between the currently traversed layer to be checked and the target standard layer is the second matching degree. Wherein the second matching degree may be 1.
S305, determining the matching degree between the currently traversed image layer to be checked and received and the target standard image layer as a third matching degree;
if the type of the adjacent layer of the currently traversed layer to be checked is different from that of the adjacent layer of the target standard layer, it is indicated that the type of the currently traversed layer to be checked is the same as that of the target standard layer, but the types of the surrounding layers are different, and it can also be determined that the currently traversed layer to be checked is not matched with the target standard layer.
At this time, the electronic device may determine that the matching degree between the currently traversed layer to be checked and the target standard layer is a third matching degree, and the third matching degree may be the same as the first matching degree. Of course, the third matching degree may be a small value as long as it is possible to indicate that the matching degree is low, and may be, for example, 0.1, 0.15, 0.2, etc.
S306, determining the matching degree between the currently traversed graph layer to be checked and received and the target standard graph layer based on the number of the graph layers with the same type.
If the type of the currently traversed layer to be checked is the same as that of the target standard layer, and the type of the adjacent layer of the currently traversed layer to be checked is the same as or different from that of the adjacent layer of the target standard layer, the matching degree between the currently traversed layer to be checked and the target standard layer may be determined according to the number of the adjacent layers of the same type, for example, a value between 0 and 1, or the like.
In an embodiment, the larger the number of adjacent layers with the same type is, the higher the matching degree between the currently traversed layer to be checked and the target standard layer may be.
As can be seen, in this embodiment, the electronic device may accurately determine, for the type of the currently traversed layer to be checked and the type of the layer adjacent to the currently traversed layer, the type of the target standard layer and the type of the layer adjacent to the target standard layer, the matching degree between the currently traversed layer to be checked and each unmatched standard layer, and further improve the accuracy of the correspondence relationship.
As an implementation manner of the embodiment of the present invention, the attribute information may further include transparency. In this case, before the step of sorting the layers to be checked and accepted according to the positions of the layers to be checked and the preset sorting rule to obtain the sorting result, the method may further include:
and removing the layers to be checked and accepted and the layers with the transparency of 100% in the standard layers.
Since the layer with the transparency of 100% is invisible visually, and the layer with the transparency of 100% has no influence on the display effect of the application program interface for the user, the layer with the transparency of 100% in each layer to be checked and each standard layer can be removed in order to improve the processing speed and reduce the calculation amount.
As can be seen, in this embodiment, before the image layers to be checked and accepted are sorted according to the positions of the image layers to be checked and the preset sorting rule, and the sorting result is obtained, the electronic device may remove the image layers with the transparency of 100% from the image layers to be checked and the standard image layers, so that the processing speed may be increased, and the calculation amount may be reduced.
As an implementation manner of the embodiment of the present invention, the attribute information may further include a color. In this case, as shown in fig. 4, before the step of sorting the to-be-checked image layers according to the positions of the to-be-checked image layers and a preset sorting rule to obtain a sorting result, the method may further include:
s401, screening out layers only including background colors from the layers to be checked and the standard layers to serve as target layers;
since the layer only including the background color is not visually visible if covered by other layers with the same background colors as the other layers, and the layer only including the background color has no influence on the display effect of the application program interface for the user, the electronic device can filter the layer only including the background color from the layers to be checked and the standard layers to be used as the target layer.
S402, determining whether the image layer including the target image layer exists or not according to the size and the position of each image layer to be checked or each standard image layer aiming at each target image layer, and if so, executing a step S403; and if not, executing the step of sequencing the layers to be checked and accepted according to the positions of the layers to be checked and accepted and a preset sequencing rule to obtain a sequencing result.
For each target layer, the electronic device may determine whether the layer including the target layer exists according to the size and the position of each layer to be checked or each standard layer. If the target layer is one of the layers to be checked, the electronic device can determine whether the layer to be checked including the target layer exists according to the size and the position of each layer to be checked; if the target layer is one of the standard layers, the electronic device may determine whether the standard layer including the target layer exists according to the size and the position of each standard layer.
If the layer of the target layer is not included, it is indicated that the target layer is only a background color, but is a layer that needs to be displayed in an application program interface, so the electronic device may continue to execute the above step of sorting the layers to be checked according to the positions of the layers to be checked and the preset sorting rule, so as to obtain a sorting result.
S403, removing the target layer when the background color of the layer with the smallest area in the layers including the target layer is the same as the background color of the target layer.
If the layer including the target layer exists, the electronic device may further determine whether a background color of a layer with a smallest area in the layers including the target layer is the same as the background color of the target layer, and if so, the target layer may be removed because the background color of the layer with the smallest area in the layers including the target layer indicates that the target layer is not visually visible. If not, the target layer is shown to have an effect on the display effect of the application program interface visually, so the removing operation may not be performed. And executing the step of sequencing the layers to be checked and accepted according to the positions of the layers to be checked and accepted and a preset sequencing rule to obtain a sequencing result.
It can be seen that, in this embodiment, the electronic device may screen out, from each layer to be checked and each standard layer, a layer that only includes a background color as a target layer, determine, for each target layer, whether there is a layer that includes the target layer according to the size and the position of each layer to be checked and each standard layer, and if there is a layer that includes the target layer, remove the target layer when the background color of the layer with the smallest area in the layers that include the target layer is the same as the background color of the target layer, so that the processing speed may be increased, and the amount of computation may be reduced.
As an implementation manner of the embodiment of the present invention, the step of obtaining attribute information of each layer to be checked in the interface to be checked and obtaining attribute information of each standard layer in the standard interface may include:
calling a preset view interface, and extracting attribute information of each layer to be checked and accepted in the interface to be checked and accepted; analyzing each standard layer in the standard interface to obtain attribute information of each standard layer in the standard interface.
Because the interface to be checked is a developed and executable application program interface, the electronic device can call a preset view interface and extract attribute information of each layer to be checked in the interface to be checked. The preset view interface may be any interface capable of providing a function of analyzing layer attribute information in the interface, and is not specifically limited herein.
The standard interface is an interface in a design draft, the design draft is a manuscript drawn by a design institute for guiding development, and the design draft is generally a file in a psd format, a sketch format and the like, so that the attribute information of a standard layer in the standard interface cannot be extracted through a preset view interface. In order to obtain the attribute information of the standard layer, the electronic device may analyze each standard layer in the standard interface through image processing software and the like, so as to obtain the attribute information of each standard layer in the standard interface. The image processing software may be PhotoShop, Sketch, Figma, etc., and is not limited herein.
As can be seen, in this embodiment, the electronic device may call the preset view interface, extract attribute information of each layer to be checked in the interface to be checked, analyze each standard layer in the standard interface, and obtain attribute information of each standard layer in the standard interface. Therefore, the attribute information of the layer in the interface to be checked can be accurately obtained no matter the interface is the interface to be checked or the standard interface is the interface to be checked.
As an implementation manner of the embodiment of the present invention, as shown in fig. 5, the analyzing each standard layer in the standard interface to obtain the attribute information of each standard layer in the standard interface may include:
s501, analyzing a standard interface, and determining whether each layer in the standard interface has a mask and is a composite layer;
since the mask has an effect on the actual display effect of the layer. The composite layer is formed by compositing a plurality of layers together. Therefore, for the two cases, in order to ensure the accuracy of the determination result of the correspondence relationship, the electronic device may perform corresponding processing for the two cases.
Specifically, the electronic device may parse the standard interface to determine whether each layer in the standard interface has a mask and is a composite layer.
S502, aiming at a layer with a mask, cutting the layer according to the size of the mask to obtain a corresponding standard layer, and determining attribute information of the standard layer;
since the layer with the mask is only visible to the user when actually displayed in the application program interface, and the area covered by the mask is invisible, the electronic device may cut the layer according to the size of the mask to obtain the corresponding standard layer, and determine the attribute information of the standard layer.
S503, aiming at the composite layer, decomposing the composite layer to obtain each standard layer forming the composite layer, and determining attribute information of each standard layer.
For the conforming layers, development needs to be performed on each standard layer forming the conforming layers during development to obtain corresponding to-be-checked and received layers, so that the composite layers can be decomposed to obtain each standard layer forming the composite layers, and then attribute information of each standard layer is determined.
Therefore, in this embodiment, the electronic device may respectively process the layer with the mask and the composite layer, so that the accuracy of the acquired attribute information of each standard layer is ensured.
Corresponding to the method for matching layers in the interface, the embodiment of the invention also provides a device for matching layers in the interface. The following describes a matching device for layers in an interface according to an embodiment of the present invention.
As shown in fig. 6, an apparatus for matching layers in an interface, the apparatus includes:
the attribute information acquiring module 610 is configured to acquire attribute information of each layer to be checked in the interface to be checked, and acquire attribute information of each standard layer in the standard interface;
the standard interface is an interface defined by a design draft corresponding to the interface to be checked and accepted, and the attribute information comprises size, position and type.
The layer sequencing module 620 is configured to sequence the layers to be checked and accepted according to the positions of the layers to be checked and accepted and a preset sequencing rule, so as to obtain a sequencing result;
the matching degree calculating module 630 is configured to traverse the layers to be checked and accepted according to the sorting result, and when each layer to be checked and accepted is traversed, calculate a matching degree between the currently traversed layer to be checked and each unmatched standard layer according to the types and positions of the layers to be checked and the standard layers;
a corresponding relation determining module 640, configured to determine, based on the matching degree, a standard layer that matches the currently traversed to-be-checked image layer, record a corresponding relation between the currently traversed to-be-checked image layer and the standard layer, and determine that the standard layer is matched; and continuously traversing the next layer to be checked and accepted, and returning to the step of calculating the matching degree between the currently traversed layer to be checked and accepted and each unmatched standard layer according to the types and the positions of the layers to be checked and accepted and the standard layers until all the layers to be checked and accepted are traversed, so as to obtain the corresponding relation between the layers to be checked and the standard layers.
As can be seen, in the scheme provided in the embodiment of the present invention, the electronic device may obtain attribute information of each layer to be checked in the interface to be checked, and obtain attribute information of each standard layer in the standard interface, where the standard interface is an interface defined by a design draft corresponding to the interface to be checked, and the attribute information includes a size, a position, and a type; sequencing the layers to be checked according to the positions of the layers to be checked and accepted and a preset sequencing rule to obtain a sequencing result; traversing each layer to be checked and accepted according to the sequencing result, and calculating the matching degree between the currently traversed layer to be checked and accepted and each unmatched standard layer according to the types and the positions of each layer to be checked and accepted and each standard layer when one layer to be checked and accepted is traversed; determining a standard layer matched with the currently traversed to-be-checked image layer based on the matching degree, recording the corresponding relation between the currently traversed to-be-checked image layer and the standard layer, and determining that the standard layer is matched; and continuously traversing the next layer to be checked and accepted, and returning to the step of calculating the matching degree between the currently traversed layer to be checked and accepted and each unmatched standard layer according to the type and the position of each layer to be checked and each standard layer until all the layers to be checked and accepted are traversed, so as to obtain the corresponding relation between each layer to be checked and each standard layer. Because the corresponding relation of the layers in the application program interface and the corresponding interface of the design draft does not need to be identified manually, the determining efficiency of the corresponding relation between the layer to be checked and the standard layer can be greatly improved.
As an implementation manner of the embodiment of the present invention, the apparatus may further include:
an adjacent layer determining module, configured to determine, according to the position of each standard layer, an adjacent layer of each standard layer before the step of traversing each layer to be checked according to the sorting result;
as shown in fig. 7, the matching degree calculating module 630 may include:
an adjacent layer determining unit 631, configured to determine, according to the position of each layer to be checked, an adjacent layer of a currently traversed layer to be checked;
a matching degree determining unit 632, configured to calculate matching degrees between the currently traversed layer to be checked and each currently unmatched standard layer respectively based on the types of the currently traversed layer to be checked and its neighboring layers, and the types of each currently unmatched standard layer and its neighboring layers.
As an implementation manner of the embodiment of the present invention, the matching degree determining unit 632 may include:
the first type determining subunit is used for determining whether the type of the currently traversed graph layer to be checked is the same as the type of each currently unmatched standard graph layer;
a first matching degree determining subunit, configured to determine, if the two layers are different, that a matching degree between the currently traversed to-be-checked graph layer and an unmatched standard graph layer of a different type is a first matching degree;
a second type determining subunit, configured to determine, if the types of the adjacent layers of the currently traversed layer to be checked are the same as the types of the adjacent layers of each unmatched target standard layer, where the target standard layer is a standard layer with the same type as the currently traversed layer to be checked;
a second matching degree determining subunit, configured to determine, if the type of the adjacent layer of the currently traversed to-be-checked image layer is the same as the type of the adjacent layer of the target standard image layer, that the matching degree between the currently traversed to-be-checked image layer and the target standard image layer is a second matching degree;
a third matching degree determining subunit, configured to determine, if the types of adjacent layers of the currently traversed to-be-checked image layer are both different from the types of adjacent layers of the target standard image layer, that the matching degree between the currently traversed to-be-checked image layer and the target standard image layer is a third matching degree;
and the fourth matching degree determining subunit is configured to determine, based on the number of layers of the same type, the matching degree between the currently traversed to-be-checked map layer and the target standard map layer if the type of the adjacent layer of the currently traversed to-be-checked map layer is not completely the same as the type of the adjacent layer of the target standard map layer.
As an implementation manner of the embodiment of the present invention, the attribute information may further include a transparency;
the above apparatus may further include:
and the first layer cleaning module is used for removing the layers with the transparency of 100% in the layers to be checked and the standard layers before sequencing the layers to be checked and accepted according to the positions of the layers to be checked and the preset sequencing rule and obtaining a sequencing result.
As an implementation manner of the embodiment of the present invention, the attribute information may further include a color;
the above apparatus may further include:
the layer screening module is used for screening out layers only including background colors from the layers to be checked and the standard layers to serve as target layers before sequencing the layers to be checked and accepted according to the positions of the layers to be checked and the preset sequencing rule and obtaining a sequencing result;
the layer selection module is used for determining whether each target layer has a layer comprising the target layer according to the size and the position of each layer to be checked or each standard layer;
and the second layer cleaning module is used for removing the target layer under the condition that the background color of the layer with the minimum area in the layers including the target layer is the same as the background color of the target layer if the target layer exists.
As an implementation manner of the embodiment of the present invention, the attribute information acquiring module 610 may include:
the first attribute information acquisition unit is used for calling a preset view interface and extracting attribute information of each layer to be checked and accepted in the interface to be checked and accepted;
and the second attribute information acquisition unit is used for analyzing each standard layer in the standard interface to acquire the attribute information of each standard layer in the standard interface.
As an implementation manner of the embodiment of the present invention, the second attribute information acquiring unit may include:
the interface analysis subunit is used for analyzing the standard interface, and determining whether each layer in the standard interface has a mask and is a composite layer;
the first information acquisition subunit is used for cutting a layer with a mask according to the size of the mask to obtain a corresponding standard layer and determining attribute information of the standard layer;
and the second information acquisition subunit is used for decomposing the composite layer to obtain each standard layer forming the composite layer and determining the attribute information of each standard layer.
An embodiment of the present invention further provides an electronic device, as shown in fig. 8, which includes a processor 801, a communication interface 802, a memory 803, and a communication bus 804, where the processor 801, the communication interface 802, and the memory 803 complete mutual communication through the communication bus 804,
a memory 803 for storing a computer program;
the processor 801 is configured to implement the steps of the method for matching layers in an interface according to any of the embodiments described above when executing the program stored in the memory 803.
As can be seen, in the scheme provided in the embodiment of the present invention, the electronic device may obtain attribute information of each layer to be checked in the interface to be checked, and obtain attribute information of each standard layer in the standard interface, where the standard interface is an interface defined by a design draft corresponding to the interface to be checked, and the attribute information includes a size, a position, and a type; sequencing the layers to be checked according to the positions of the layers to be checked and accepted and a preset sequencing rule to obtain a sequencing result; traversing each layer to be checked and accepted according to the sequencing result, and calculating the matching degree between the currently traversed layer to be checked and accepted and each unmatched standard layer according to the types and the positions of each layer to be checked and accepted and each standard layer when one layer to be checked and accepted is traversed; determining a standard layer matched with the currently traversed to-be-checked image layer based on the matching degree, recording the corresponding relation between the currently traversed to-be-checked image layer and the standard layer, and determining that the standard layer is matched; and continuously traversing the next layer to be checked and accepted, and returning to the step of calculating the matching degree between the currently traversed layer to be checked and accepted and each unmatched standard layer according to the type and the position of each layer to be checked and each standard layer until all the layers to be checked and accepted are traversed, so as to obtain the corresponding relation between each layer to be checked and each standard layer. Because the corresponding relation of the layers in the application program interface and the corresponding interface of the design draft does not need to be identified manually, the determining efficiency of the corresponding relation between the layer to be checked and the standard layer can be greatly improved.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. Optionally, the memory may also be at least one cache device located remotely from the processor.
The Processor may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the device can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component.
In another embodiment of the present invention, a computer-readable storage medium is further provided, where instructions are cached in the computer-readable storage medium, and when the instructions are executed on a computer, the computer is caused to execute the steps of the method for matching layers in an interface according to any one of the above embodiments.
It can be seen that, in the solution provided in the embodiment of the present invention, when running on a computer, a command cached in a computer-readable storage medium may obtain attribute information of each layer to be checked in an interface to be checked, and obtain attribute information of each standard layer in a standard interface, where the standard interface is an interface defined by a design draft corresponding to the interface to be checked, and the attribute information includes a size, a position, and a type; sequencing the layers to be checked according to the positions of the layers to be checked and accepted and a preset sequencing rule to obtain a sequencing result; traversing each layer to be checked and accepted according to the sequencing result, and calculating the matching degree between the currently traversed layer to be checked and accepted and each unmatched standard layer according to the types and the positions of each layer to be checked and accepted and each standard layer when one layer to be checked and accepted is traversed; determining a standard layer matched with the currently traversed to-be-checked image layer based on the matching degree, recording the corresponding relation between the currently traversed to-be-checked image layer and the standard layer, and determining that the standard layer is matched; and continuously traversing the next layer to be checked and accepted, and returning to the step of calculating the matching degree between the currently traversed layer to be checked and accepted and each unmatched standard layer according to the type and the position of each layer to be checked and each standard layer until all the layers to be checked and accepted are traversed, so as to obtain the corresponding relation between each layer to be checked and each standard layer. Because the corresponding relation of the layers in the application program interface and the corresponding interface of the design draft does not need to be identified manually, the determining efficiency of the corresponding relation between the layer to be checked and the standard layer can be greatly improved.
In a further embodiment of the present invention, a computer program product containing instructions is further provided, which when run on a computer, causes the computer to perform the steps of the method for matching layers in an interface according to any one of the above embodiments.
In the solution provided in the embodiment of the present invention, when running on a computer, a computer program product may obtain attribute information of each layer to be checked and accepted in an interface to be checked and accepted, and obtain attribute information of each standard layer in a standard interface, where the standard interface is an interface defined by a design draft corresponding to the interface to be checked and accepted, and the attribute information includes a size, a position, and a type; sequencing the layers to be checked according to the positions of the layers to be checked and accepted and a preset sequencing rule to obtain a sequencing result; traversing each layer to be checked and accepted according to the sequencing result, and calculating the matching degree between the currently traversed layer to be checked and accepted and each unmatched standard layer according to the types and the positions of each layer to be checked and accepted and each standard layer when one layer to be checked and accepted is traversed; determining a standard layer matched with the currently traversed to-be-checked image layer based on the matching degree, recording the corresponding relation between the currently traversed to-be-checked image layer and the standard layer, and determining that the standard layer is matched; and continuously traversing the next layer to be checked and accepted, and returning to the step of calculating the matching degree between the currently traversed layer to be checked and accepted and each unmatched standard layer according to the type and the position of each layer to be checked and each standard layer until all the layers to be checked and accepted are traversed, so as to obtain the corresponding relation between each layer to be checked and each standard layer. Because the corresponding relation of the layers in the application program interface and the corresponding interface of the design draft does not need to be identified manually, the determining efficiency of the corresponding relation between the layer to be checked and the standard layer can be greatly improved.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be cached in a computer-readable cache medium or transmitted from one computer-readable cache medium to another, for example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable cache medium may be any available medium that can be accessed by a computer or a data caching device, such as a server, a data center, etc., that is integrated with one or more available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the apparatus, the electronic device, the computer-readable storage medium, and the computer program product embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the method embodiments.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (11)

1. A method for matching layers in an interface is characterized in that the method comprises the following steps:
acquiring attribute information of each layer to be checked and accepted in an interface to be checked and acquiring attribute information of each standard layer in a standard interface, wherein the standard interface is an interface defined by a design draft corresponding to the interface to be checked and accepted, and the attribute information comprises size, position and type;
sequencing the layers to be checked according to the positions of the layers to be checked and accepted and a preset sequencing rule to obtain a sequencing result;
traversing each layer to be checked and accepted according to the sequencing result, and calculating the matching degree between the currently traversed layer to be checked and accepted and each unmatched standard layer according to the types and the positions of each layer to be checked and accepted and each standard layer when one layer to be checked and accepted is traversed;
determining a standard layer matched with the currently traversed to-be-checked image layer based on the matching degree, recording the corresponding relation between the currently traversed to-be-checked image layer and the standard layer, and determining that the standard layer is matched;
and continuously traversing the next layer to be checked and accepted, and returning to the step of calculating the matching degree between the currently traversed layer to be checked and accepted and each unmatched standard layer according to the types and the positions of the layers to be checked and accepted and the standard layers until all the layers to be checked and accepted are traversed, so as to obtain the corresponding relation between the layers to be checked and the standard layers.
2. The method according to claim 1, wherein before the step of traversing the layers to be checked according to the sorting result, the method further comprises:
determining an adjacent layer of each standard layer according to the position of each standard layer;
the step of calculating the matching degree between the currently traversed to-be-checked image layer and each currently unmatched standard image layer according to the types and the positions of the to-be-checked image layers and the standard image layers comprises the following steps:
determining adjacent layers of the currently traversed layer to be checked according to the positions of the layers to be checked;
and respectively calculating the matching degree between the currently traversed layer to be checked and accepted and each currently unmatched standard layer based on the types of the currently traversed layer to be checked and the adjacent layer thereof and the types of each currently unmatched standard layer and the adjacent layer thereof.
3. The method according to claim 2, wherein the step of calculating the matching degree between the currently traversed layer to be checked and each currently unmatched standard layer respectively based on the types of the currently traversed layer to be checked and its neighboring layers and the types of each currently unmatched standard layer and its neighboring layers comprises:
determining whether the type of the currently traversed graph layer to be checked is the same as the type of each currently unmatched standard graph layer;
if the current traversed graph layer to be checked is different from the unmatched standard graph layer of the different types, determining that the matching degree between the currently traversed graph layer to be checked and the unmatched standard graph layer of the different types is a first matching degree;
if the type of the adjacent layer of the currently traversed layer to be checked is the same as that of the adjacent layer of each unmatched target standard layer, determining whether the type of the adjacent layer of the currently traversed layer to be checked is the same as that of the adjacent layer of each unmatched target standard layer, wherein the target standard layer is a standard layer with the same type as that of the currently traversed layer to be checked;
if the types of the adjacent layers of the currently traversed to-be-checked graph layer are the same as those of the adjacent layers of the target standard graph layer, determining that the matching degree between the currently traversed to-be-checked graph layer and the target standard graph layer is a second matching degree;
if the types of the adjacent layers of the currently traversed to-be-checked image layer are different from the types of the adjacent layers of the target standard image layer, determining that the matching degree between the currently traversed to-be-checked image layer and the target standard image layer is a third matching degree;
and if the type of the adjacent layer of the currently traversed to-be-checked graph layer is not completely the same as that of the adjacent layer of the target standard graph layer, determining the matching degree between the currently traversed to-be-checked graph layer and the target standard graph layer based on the number of the layers with the same type.
4. The method of any of claims 1-3, wherein the attribute information further includes a transparency;
before the step of sequencing the image layers to be checked and accepted according to the positions of the image layers to be checked and accepted and a preset sequencing rule to obtain a sequencing result, the method further comprises the following steps:
and removing the layers to be checked and accepted and the layers with the transparency of 100% in the standard layers.
5. The method of any of claims 1-3, wherein the attribute information further comprises a color;
before the step of sequencing the image layers to be checked and accepted according to the positions of the image layers to be checked and accepted and a preset sequencing rule to obtain a sequencing result, the method further comprises the following steps:
screening out layers only including background colors from the layers to be checked and accepted and the standard layers to serve as target layers;
for each target layer, determining whether the layer comprising the target layer exists or not according to the size and the position of each layer to be checked and accepted or each standard layer;
and if so, removing the target layer under the condition that the background color of the layer with the minimum area in the layers including the target layer is the same as the background color of the target layer.
6. The method according to any one of claims 1 to 3, wherein the step of obtaining attribute information of each layer to be checked in the interface to be checked and obtaining attribute information of each standard layer in the standard interface comprises:
calling a preset view interface, and extracting attribute information of each layer to be checked and accepted in the interface to be checked and accepted;
analyzing each standard layer in the standard interface to obtain attribute information of each standard layer in the standard interface.
7. The method according to claim 6, wherein the step of analyzing each standard layer in the standard interface to obtain the attribute information of each standard layer in the standard interface includes:
analyzing a standard interface, and determining whether each layer in the standard interface has a mask and is a composite layer;
cutting a layer with a mask according to the size of the mask to obtain a corresponding standard layer, and determining attribute information of the standard layer;
and decomposing the composite layer aiming at the composite layer to obtain each standard layer forming the composite layer, and determining the attribute information of each standard layer.
8. An apparatus for matching layers in an interface, the apparatus comprising:
the attribute information acquisition module is used for acquiring attribute information of each layer to be checked in an interface to be checked and accepted and acquiring attribute information of each standard layer in a standard interface, wherein the standard interface is an interface defined by a design draft corresponding to the interface to be checked and accepted, and the attribute information comprises size, position and type;
the layer sequencing module is used for sequencing the layers to be checked and accepted according to the positions of the layers to be checked and accepted and a preset sequencing rule to obtain a sequencing result;
the matching degree calculation module is used for traversing each layer to be checked and accepted according to the sorting result, and calculating the matching degree between the currently traversed layer to be checked and each unmatched standard layer according to the types and the positions of each layer to be checked and accepted and each standard layer when one layer to be checked and accepted is traversed;
the corresponding relation determining module is used for determining a standard layer matched with the currently traversed image layer to be checked based on the matching degree, recording the corresponding relation between the currently traversed image layer to be checked and the standard layer, and determining that the standard layer is matched; and continuously traversing the next layer to be checked and accepted, and returning to the step of calculating the matching degree between the currently traversed layer to be checked and accepted and each unmatched standard layer according to the types and the positions of the layers to be checked and accepted and the standard layers until all the layers to be checked and accepted are traversed, so as to obtain the corresponding relation between the layers to be checked and the standard layers.
9. The apparatus of claim 8, wherein the apparatus further comprises:
an adjacent layer determining module, configured to determine, according to the position of each standard layer, an adjacent layer of each standard layer before the step of traversing each layer to be checked according to the sorting result;
the matching degree calculation module includes:
the adjacent layer determining unit is used for determining adjacent layers of the currently traversed layer to be checked according to the positions of the layers to be checked;
and the matching degree determining unit is used for respectively calculating the matching degree between the currently traversed layer to be checked and each currently unmatched standard layer based on the types of the currently traversed layer to be checked and the adjacent layers thereof and the types of each currently unmatched standard layer and the adjacent layers thereof.
10. The apparatus of claim 9, wherein the matching degree determination unit comprises:
the first type determining subunit is used for determining whether the type of the currently traversed graph layer to be checked is the same as the type of each currently unmatched standard graph layer;
a first matching degree determining subunit, configured to determine, if the two layers are different, that a matching degree between the currently traversed to-be-checked graph layer and an unmatched standard graph layer of a different type is a first matching degree;
a second type determining subunit, configured to determine, if the types of the adjacent layers of the currently traversed layer to be checked are the same as the types of the adjacent layers of each unmatched target standard layer, where the target standard layer is a standard layer with the same type as the currently traversed layer to be checked;
a second matching degree determining subunit, configured to determine, if the type of the adjacent layer of the currently traversed to-be-checked image layer is the same as the type of the adjacent layer of the target standard image layer, that the matching degree between the currently traversed to-be-checked image layer and the target standard image layer is a second matching degree;
a third matching degree determining subunit, configured to determine, if the types of adjacent layers of the currently traversed to-be-checked image layer are both different from the types of adjacent layers of the target standard image layer, that the matching degree between the currently traversed to-be-checked image layer and the target standard image layer is a third matching degree;
and the fourth matching degree determining subunit is configured to determine, based on the number of layers of the same type, the matching degree between the currently traversed to-be-checked map layer and the target standard map layer if the type of the adjacent layer of the currently traversed to-be-checked map layer is not completely the same as the type of the adjacent layer of the target standard map layer.
11. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any of claims 1 to 7 when executing a program stored in the memory.
CN202010761354.3A 2020-07-31 2020-07-31 Matching method and device for layers in interface and electronic equipment Pending CN111857703A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010761354.3A CN111857703A (en) 2020-07-31 2020-07-31 Matching method and device for layers in interface and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010761354.3A CN111857703A (en) 2020-07-31 2020-07-31 Matching method and device for layers in interface and electronic equipment

Publications (1)

Publication Number Publication Date
CN111857703A true CN111857703A (en) 2020-10-30

Family

ID=72953945

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010761354.3A Pending CN111857703A (en) 2020-07-31 2020-07-31 Matching method and device for layers in interface and electronic equipment

Country Status (1)

Country Link
CN (1) CN111857703A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113485707A (en) * 2021-07-26 2021-10-08 亿览在线网络技术(北京)有限公司 Method for automatically checking UI (user interface)
CN113778905A (en) * 2021-11-10 2021-12-10 腾讯科技(深圳)有限公司 UI design acceptance method, device, equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107015793A (en) * 2016-12-12 2017-08-04 阿里巴巴集团控股有限公司 Design original text adaptation method, apparatus and system
US20180267777A1 (en) * 2017-03-20 2018-09-20 Google Inc. Automated interface design
CN109445778A (en) * 2018-09-13 2019-03-08 珠海豆饭科技有限公司 A kind of method and apparatus that the interface auxiliary based on SVG file generates

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107015793A (en) * 2016-12-12 2017-08-04 阿里巴巴集团控股有限公司 Design original text adaptation method, apparatus and system
US20180267777A1 (en) * 2017-03-20 2018-09-20 Google Inc. Automated interface design
CN109445778A (en) * 2018-09-13 2019-03-08 珠海豆饭科技有限公司 A kind of method and apparatus that the interface auxiliary based on SVG file generates

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113485707A (en) * 2021-07-26 2021-10-08 亿览在线网络技术(北京)有限公司 Method for automatically checking UI (user interface)
CN113778905A (en) * 2021-11-10 2021-12-10 腾讯科技(深圳)有限公司 UI design acceptance method, device, equipment and storage medium
CN113778905B (en) * 2021-11-10 2022-02-08 腾讯科技(深圳)有限公司 UI design acceptance method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
CN109697414B (en) Text positioning method and device
CN110502985B (en) Form identification method and device and form identification equipment
JP6900164B2 (en) Information processing equipment, information processing methods and programs
JP2011192274A (en) Method and apparatus for form template definition
CN111857703A (en) Matching method and device for layers in interface and electronic equipment
CN112966583A (en) Image processing method, image processing device, computer equipment and storage medium
CN115240213A (en) Form image recognition method and device, electronic equipment and storage medium
CN115546809A (en) Table structure identification method based on cell constraint and application thereof
CN109241485A (en) Relation establishing method and device are jumped between a kind of page
CN111523531A (en) Word processing method and device, electronic equipment and computer readable storage medium
CN111881049B (en) Acceptance method and device of application program interface and electronic equipment
CN116682130A (en) Method, device and equipment for extracting icon information and readable storage medium
CN112486384B (en) Picture examination processing method and related device
CN111144373B (en) Information identification method and device, computer equipment and storage medium
CN111126029B (en) Electronic document generation method and device, computer equipment and storage medium
CN111079709B (en) Electronic document generation method and device, computer equipment and storage medium
CN112329409B (en) Cell color conversion method and device and electronic equipment
CN111127480A (en) Image processing method and device, electronic equipment and storage medium
CN114663902B (en) Document image processing method, device, equipment and medium
CN113269153B (en) Form identification method and device
JP5414631B2 (en) Character string search method, character string search device, and recording medium
CN114048539A (en) CAD file analysis and rule judgment method and related device
CN110398681B (en) Double-strip-line inspection method and related device
CN111881050A (en) Method and device for clipping text layer and electronic equipment
CN111783180A (en) Drawing splitting method and related device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination