CN103605638B - Character method for trimming and device - Google Patents

Character method for trimming and device Download PDF

Info

Publication number
CN103605638B
CN103605638B CN201310603871.8A CN201310603871A CN103605638B CN 103605638 B CN103605638 B CN 103605638B CN 201310603871 A CN201310603871 A CN 201310603871A CN 103605638 B CN103605638 B CN 103605638B
Authority
CN
China
Prior art keywords
character
text
case
finishing
new
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.)
Active
Application number
CN201310603871.8A
Other languages
Chinese (zh)
Other versions
CN103605638A (en
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 Gridsum Technology Co Ltd
Original Assignee
Beijing Gridsum 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 Gridsum Technology Co Ltd filed Critical Beijing Gridsum Technology Co Ltd
Priority to CN201310603871.8A priority Critical patent/CN103605638B/en
Publication of CN103605638A publication Critical patent/CN103605638A/en
Application granted granted Critical
Publication of CN103605638B publication Critical patent/CN103605638B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention discloses a kind of character method for trimming and device, wherein, the method includes: create can rendering text area size be the control of SizeA, and after obtaining viewing area size SizeS distributing to control, at least perform the most following circulation: treat character finishing text by control and draw, and obtain size SizeB treating character finishing text of drafting;In the case of the condition of not met end loop, it is judged that whether SizeB is equal to SizeS, in the case of judged result is no, treats character finishing text according to pre-defined rule and cut out or recover the character of predetermined number, obtain new treating that text repaired in character;Wherein, in the case of meeting the condition of end loop, end loop, and determine the result that character is repaired.By the present invention, improve the effect that text shows, thus improve the experience of user.

Description

Character method for trimming and device
Technical field
The present invention relates to data processing field, in particular to a kind of character method for trimming and device.
Background technology
Generally, application program, processing text when, can process according to English word, such as, The strategy that the TextBlock control of Silverlight platform uses when showing supertext has following two: (1) is not cut Take text;(2) text intercepts according to word, finally adds ellipsis at remaining text.
Inventor finds in research process, in mode (2), is not enough to completely show certain in current layout width In the case of individual long word text data, whole long word all will be hidden.
Such as: for network address: http://www.gridsum.com/service/Analysis/Description/, will It is identified as multiple word respectively, such as: " http ", "/www.gridsum.com ", in aforesaid way (2) Middle will be processed according to the mode of a word.
If now in the page, layout width only allows to demonstrate the length of 21 characters, due to "/www.gridsum.com " is identified as a word, causes the text truly demonstrated to be: “http://...”;But, it is easier to allow user understand and the form that accepts should be: “http://www.gridsum.co...”。
For the text exceeding layout width viewing area is intercepted asking of being caused by correlation technique according to word Topic, the most not yet proposes effective solution.
Summary of the invention
The invention provides a kind of character method for trimming and device, at least to solve the problems referred to above.
According to an aspect of the invention, it is provided a kind of character method for trimming, including: can rendering text district creating Territory size is the control of SizeA, and after obtaining viewing area size SizeS distributing to described control, at least holds The most following circulation of row: treat character finishing text by described control and draw, and obtain and wait for a right man to marry described in drafting Size SizeB of symbol finishing text;In the case of the condition of not met end loop, it is judged that whether SizeB is equal to To described, SizeS, in the case of judged result is no, treats that character finishing text cuts out or extensive according to pre-defined rule The character of multiple predetermined number, obtains new treating that text repaired in character;Wherein, the condition of described end loop includes: Using the urtext repaired without character as described treat character finishing text and described judged result be SizeB be less than or In the case of SizeS, terminate described circulation, and determine the result that described urtext is character finishing, or Person, in the circulation after first time, judged result is, in the case of SizeB is equal to SizeS, to terminate described circulation, And determine that the result that character finishing text is character finishing is treated in obtain in last circulation new.
Preferably, in the case of described control allows line feed automatically, SizeA is highly unlimited and that length is fixing district Territory, wherein, the length of SizeS and the length of SizeB are equal.
Preferably, in the case of described control does not allows automatically to enter a new line, SizeA is highly to fix and infinite in length Region, wherein, the height of SizeS and the height of SizeB are equal.
Preferably, determining in the case of the SizeB result whether equal to SizeS is no, according to described pre-set pattern Then treat that character finishing text cuts out or recovers the character of predetermined number by described, obtain new treating that text bag repaired in character Include: determining SizeB more than in the case of SizeS, treating that text repaired in character according to described pre-defined rule by described Cut out the character of predetermined number, obtain described new treating that text repaired in character;Determining SizeB less than SizeS's In the case of, according to described pre-defined rule by described treat character finishing text recover predetermined number character, obtain described newly Treat character repair text.
Preferably, described pre-defined rule includes one below: binary chop, one by one character cut out method.
Preferably, in the case of described pre-defined rule is binary chop, the condition of described end loop also includes: In circulation after first time, judged result is that SizeB is less than obtain in SizeS, and previous cycle new and treats character Finishing text draw after size and previous cycle before a circulation in obtain new treat that character finishing text is drawn After equal in magnitude in the case of, terminate described circulation, and determine that character finishing literary composition is treated in obtain in previous cycle new This is the result of character finishing.
Preferably, in the case of described pre-defined rule is described binary chop, according to described binary chop to institute State and treat that character finishing text cuts out or recovers the character of predetermined number, obtain described new treating that text bag repaired in character Include:
In the case of circulating at the 1st time, cut out the individual character of described text to be trimmed [LenB/2], obtain the 1st new Text to be trimmed, wherein, LenB represent described in treat character finishing text number of characters, [] represent round Or round up;
In the case of n-th circulates, cut out described N-1 new text [LenB/2 to be trimmedN] individual character, Or, recover described N-1 new text [LenB/2 to be trimmedN] individual character, obtain new to be trimmed of n-th Text, wherein, N is the integer more than 1.
Preferably, in the case of described pre-defined rule is described binary chop, according to described binary chop to institute State and treat that character finishing text cuts out or recovers the character of predetermined number, obtain described new treating that text bag repaired in character Include:
In the case of circulating at the 1st time, cutting out the individual character of described text to be trimmed [LenB/2], obtaining number of characters is [LenB]1The 1st new text to be trimmed, wherein, LenB represent described in treat character finishing text number of characters, [] represents round or rounds up;
In the case of circulating at the 2nd time, cut out described 1st new text to be trimmed [(LenB-[LenB]1)/2] individual Character, or, recover described 1st new text to be trimmed [| (LenB-[LenB]1) |/2] individual character, obtain word Symbol number is [LenB]2The 2nd new text to be trimmed;
In the case of n-th circulates, cut out described N-1 new text to be trimmed [([LenB]N-2-[LenB]N-1)/2] individual character, or, recover described N-1 new text to be trimmed [|([LenB]N-2-[LenB]N-1) |/2] individual character, obtain size for [LenB]NThe new text to be trimmed of n-th, Wherein, N is the integer more than 2.
Preferably, in performing the circulation after described circulation primary, treat character finishing literary composition by described control to described Originally carry out drafting to include: treating that character adds book character after repairing text described, wherein, described book character is used Described in representing, treat that character finishing text is for by the trimmed text of character;By described control to adding described reserved word Treat described in after symbol that character finishing text is drawn.
According to another aspect of the present invention, additionally provide a kind of character trimming device, including: processing module, it is used for Establishment can rendering text area size be the control of SizeA, and obtains the viewing area size distributing to described control SizeS;Loop module, at least performing the most following circulation: treat character finishing text by described control and enter Row is drawn, and obtains size SizeB treating character finishing text described in drafting;Condition in not met end loop In the case of, it is judged that whether SizeB is equal to SizeS, in the case of judged result is no, according to pre-defined rule to institute State and treat that character finishing text cuts out or recovers the character of predetermined number, obtain new treating that text repaired in character;Wherein, The condition of described end loop includes: using the urtext repaired without character as described treat character finishing text and Described judged result is in the case of SizeB is less than or equal to SizeS, terminates described circulation, and determines described original Text is the result of character finishing;Or, in the circulation after first time, judged result is that SizeB is equal to SizeS In the case of, terminate described circulation, and determine that obtain in last circulation new treats that character finishing text is that character is repaiied Whole result.
Preferably, described pre-defined rule includes one below: binary chop, one by one character cut out method.
By the present invention, using creating rendering text area size to be the control of SizeA, and control is distributed in acquisition After viewing area size SizeS of part, at least perform the most following circulation: treat character finishing text by control Draw, and obtain size SizeB treating character finishing text of drafting;Condition in not met end loop In the case of, it is judged that whether SizeB is equal to SizeS, in the case of judged result is no, according to pre-defined rule to waiting for a right man to marry Symbol finishing text cuts out or recovers the character of predetermined number, obtains new treating that text repaired in character;Wherein, described knot The condition of Shu Xunhuan includes: using the urtext repaired without character as treat character finishing text and judged result be In the case of SizeB is less than or equal to SizeS, end loop, and determine the result that urtext is character finishing, or Person, in the circulation after first time, judged result is in the case of SizeB is equal to SizeS, end loop, and really The new mode treating result that character finishing text is character finishing obtained in fixed last time circulation, solves relevant skill Art intercepts caused problem according to word to the text exceeding layout width viewing area, improves text and show The effect shown, thus improve the experience of user.
Accompanying drawing explanation
Accompanying drawing described herein is used for providing a further understanding of the present invention, constitutes the part of the application, this Bright schematic description and description is used for explaining the present invention, is not intended that inappropriate limitation of the present invention.At accompanying drawing In:
Fig. 1 is the schematic flow sheet of character method for trimming according to embodiments of the present invention;
Fig. 2 is the structural representation of character trimming device according to embodiments of the present invention;
Fig. 3 is the schematic flow sheet of character method for trimming according to the preferred embodiment of the invention.
Detailed description of the invention
It should be noted that in the case of not conflicting, the embodiment in the application and the feature in embodiment can phases Combination mutually.Describe the present invention below with reference to the accompanying drawings and in conjunction with the embodiments in detail.
Present embodiments providing a kind of character method for trimming, Fig. 1 is character method for trimming according to embodiments of the present invention Schematic flow sheet, as it is shown in figure 1, this flow process comprises the steps:
Step S102, creating rendering text area size to be the control of SizeA, and obtains the display distributing to control Area size SizeS;
Step S104, by control treat character finishing text draw, and obtain drafting treat character finishing literary composition This size SizeB;In the case of the condition of not met end loop, it is judged that whether SizeB is equal to SizeS, Judged result be no in the case of, according to pre-defined rule treat character finishing text cut out or recover the word of predetermined number Symbol, obtains new treating that text repaired in character;
Wherein, step S104 will perform at least one times, until meeting the condition of end loop: will repair without character Whole urtext as treat character finishing text and judged result be in the case of SizeB is less than or equal to SizeS, End loop, and determine the result that urtext is character finishing, or, the circulation after first time judges knot Fruit for SizeB equal in the case of SizeS, end loop, and determine that character is treated in obtain in last circulation new Finishing text is the result of character finishing.
It should be noted that can be at such as one group of computer executable instructions in the step shown in the flow chart of accompanying drawing Computer system performs, and, although show logical order in flow charts, but in some cases, can With to be different from the step shown or described by order execution herein.
By above-mentioned steps, use repeatedly to cutting out or recover the drafting of text of predetermined number character, and to painting Size SizeB of result processed (that i.e. draws treats that text repaired in character) and the pass of viewing area size SizeS distributed System judges, such that it is able to search out the text size of optimum to draw, display is in the size region as SizeS.Phase For correlation technique, based on character, text is intercepted in the present embodiment, therefore, its optimal result Display effect will be better than the display effect of mode in correlation technique (2), it is possible to demonstrate be easier to allow user understand and The form accepted, thus improve the experience of user.
Above-mentioned size be the region of SizeA be the control region for tentative rendering text, in order to judge tentative painting The region shared by text of system and size are the relation in the region of SizeA.Preferably, line feed automatically is allowed at control In the case of, SizeA is highly unlimited and that length is fixing region, wherein, the length of SizeS and the length of SizeB Equal.
Preferably, in the case of control does not allows automatically to enter a new line, SizeA is highly to fix and the district of infinite in length Territory, wherein, the height of SizeS and the height of SizeB are equal.
Preferably, determining in the case of the SizeB result whether equal to SizeS is no, will according to pre-defined rule Treat that character finishing text cuts out or recovers the character of predetermined number, obtain new treating that character finishing text includes following two Individual aspect:
(1) determining SizeB more than in the case of SizeS, will treat that character is repaired text and cut out according to pre-defined rule The character of predetermined number, obtains new treating that text repaired in character;
(2) determine SizeB less than in the case of SizeS, will treat character finishing text recovery according to pre-defined rule The character of predetermined number, obtains new treating that text repaired in character.
Preferably, above-mentioned pre-defined rule includes one below: binary chop, one by one character cut out method.
Wherein, character cuts out method and refers to the most fixing character intercepting text, by repeatedly cutting out word one by one Symbol, finds optimum text size, uses character one by one to cut out method, be the text of 2^10 for a number of characters, if To mate with the viewing area of 21 number of characters, then to need circulation to perform 2^10-21 time.In order to reduce opening of process Pin, uses binary chop in the preferred embodiment, is the text of 2^10 similarly for a number of characters, to Mate with the viewing area of 21 number of characters, it is only necessary to circulate 5 times and just the number of characters of text to be trimmed can be truncated to 2^5=32, it is seen then that use binary chop can be obviously improved treatment effeciency.
Preferably, it is also possible to by binary chop and one by one character cut out method and combine, such as, in the example above, Determine number of characters 2^5=32 > 21 and in the case of 2^4=16 < 21, can cut out one by one being 2^5 by number of characters Character, so that it is determined that the text of optimum character length.
Preferably, in the case of pre-defined rule is binary chop, the condition of end loop also includes: for the first time In later circulation, judged result is that SizeB is less than obtain in SizeS, and previous cycle new and treats that text repaired in character The new size after character finishing text is drawn obtained in size after drafting and the circulation of before previous cycle In the case of equal, end loop, and determine that obtain in previous cycle new treats that character finishing text is character finishing Result.
Preferably, in the case of pre-defined rule is binary chop, treat character finishing text according to binary chop Cut out or recover the character of predetermined number, obtain new treating that character finishing text, during realizing, has multiple side Formula, such as:
Mode one:
In the case of circulating at the 1st time, cut out text to be trimmed [LenB/2] individual character, obtain the 1st new to be repaired Whole text, wherein, LenB represents the number of characters treating character finishing text, and [] represents round or upwards Round;
In the case of n-th circulates, cut out N-1 new text [LenB/2 to be trimmedN] individual character, or Person, recovers N-1 new text [LenB/2 to be trimmedN] individual character, obtain the text to be trimmed that n-th is new, Wherein, N is the integer more than 1.
Mode two:
In the case of circulating at the 1st time, cutting out text to be trimmed [LenB/2] individual character, obtaining number of characters is [LenB]1The 1st new text to be trimmed, wherein, LenB represent treat character finishing text number of characters, [] table Show round or round up;
In the case of circulating at the 2nd time, cut out the 1st new text to be trimmed [(LenB-[LenB]1)/2] individual word Symbol, or, recover the 1st new text to be trimmed [| (LenB-[LenB]1) |/2] individual character, obtaining number of characters is [LenB]2The 2nd new text to be trimmed;
In the case of n-th circulates, cut out N-1 new text to be trimmed [([LenB]N-2-[LenB]N-1)/2] individual character, or, recover N-1 new text to be trimmed [|([LenB]N-2-[LenB]N-1) |/2] individual character, obtain size for [LenB]NThe new text to be trimmed of n-th, Wherein, N is the integer more than 2.
Preferably, in performing the circulation after step S104, treat character finishing text by control and carry out Drafting includes: adding book character after treating character finishing text, such as, subscribing character is " ... ", and this makes a reservation for For expression, character treats that character finishing text is for by the trimmed text of character;By control to adding after book character Treat that character finishing text is drawn.
The present embodiment additionally provides a kind of character trimming device, and this device is used for realizing above-mentioned character method for trimming, its tool The process that realizes of body had carried out detailed description in embodiment of the method, did not repeated them here.
Fig. 2 is the structural representation of character trimming device according to embodiments of the present invention, as in figure 2 it is shown, this device bag Include: processing module 22 and loop module 24, wherein, processing module 22, can rendering text area size for establishment For the control of SizeA, and obtain viewing area size SizeS distributing to control;Loop module 24 coupled to process Module 22, at least performing the most following circulation: the first processing unit 242 treats character finishing text by control Draw, and obtain size SizeB treating character finishing text of drafting;Second processing unit 244 is at not met In the case of the condition of end loop, it is judged that whether SizeB is equal to SizeS, in the case of judged result is no, root Treat character finishing text according to pre-defined rule cut out or recover the character of predetermined number, obtain new treating character finishing literary composition This;
Wherein, the condition of end loop includes: using the urtext repaired without character as treat character repair text And judged result is in the case of SizeB is less than or equal to SizeS, end loop, and determine that urtext is character The result of finishing;Or, in the circulation after first time, judged result is in the case of SizeB is equal to SizeS, End loop, and determine that the result that character finishing text is character finishing is treated in obtain in last circulation new.
Module, unit involved in embodiments of the invention can realize by the way of software, it is also possible to pass through The mode of hardware realizes.Described module, unit in the present embodiment can also be arranged within a processor, example As, can be described as: a kind of processor includes processing module 22 and loop module 24.Wherein, the name of these modules Claiming to be not intended that under certain conditions the restriction to this module itself, such as, processing module is also described as " using Can rendering text area size be viewing area size SizeS that control is distributed in the control of SizeA acquisition in creating Module ".
Preferably, in the case of control allows line feed automatically, SizeA is highly unlimited and that length is fixing region, Wherein, the length of SizeS and the length of SizeB are equal.
Preferably, in the case of control does not allows automatically to enter a new line, SizeA is highly to fix and the district of infinite in length Territory, wherein, the height of SizeS and the height of SizeB are equal.
Preferably, the second processing unit 244 is determining in the case of the SizeB result whether equal to SizeS is no also For:
Determining SizeB more than in the case of SizeS, will treat that character is repaired text and cut out predetermined according to pre-defined rule The character of number, obtains new treating that text repaired in character;
Determining SizeB less than in the case of SizeS, will treat that character finishing text recovers to make a reservation for according to pre-defined rule The character of number, obtains new treating that text repaired in character.
Preferably, pre-defined rule includes one below: binary chop, one by one character cut out method.
Preferably, in the case of pre-defined rule is binary chop, the condition of end loop also includes: for the first time In later circulation, judged result is that SizeB is less than obtain in SizeS, and previous cycle new and treats that text repaired in character The new size after character finishing text is drawn obtained in size after drafting and the circulation of before previous cycle In the case of equal, end loop, and determine that obtain in previous cycle new treats that character finishing text is character finishing Result.
Preferably, in the case of pre-defined rule is binary chop, the second processing unit 244 is additionally operable to:
In the case of circulating at the 1st time, cut out text to be trimmed [LenB/2] individual character, obtain the 1st new to be repaired Whole text, wherein, LenB represents the number of characters treating character finishing text, and [] represents round or upwards Round;
In the case of n-th circulates, cut out N-1 new text [LenB/2 to be trimmedN] individual character, or Person, recovers N-1 new text [LenB/2 to be trimmedN] individual character, obtain the text to be trimmed that n-th is new, Wherein, N is the integer more than 1.
Preferably, in the case of pre-defined rule is binary chop, the second processing unit 244 is additionally operable to:
In the case of circulating at the 1st time, cutting out text to be trimmed [LenB/2] individual character, obtaining number of characters is [LenB]1The 1st new text to be trimmed, wherein, LenB represent treat character finishing text number of characters, [] table Show round or round up;
In the case of circulating at the 2nd time, cut out the 1st new text to be trimmed [(LenB-[LenB]1)/2] individual word Symbol, or, recover the 1st new text to be trimmed [| (LenB-[LenB]1) |/2] individual character, obtaining number of characters is [LenB]2The 2nd new text to be trimmed;
In the case of n-th circulates, cut out N-1 new text to be trimmed [([LenB]N-2-[LenB]N-1)/2] individual character, or, recover N-1 new text to be trimmed [|([LenB]N-2-[LenB]N-1) |/2] individual character, obtain size for [LenB]NThe new text to be trimmed of n-th, Wherein, N is the integer more than 2.
Preferably, the first processing unit 242 is additionally operable to: in performing the circulation after circulation primary, treating that character is repaiied Adding book character after whole text, wherein, for expression, book character treats that character finishing text is for trimmed by character Text;Treat that character finishing text draw to adding after book character by control.
It is described below in conjunction with preferred embodiment.
Fig. 3 is the schematic flow sheet of character method for trimming according to the preferred embodiment of the invention.As it is shown on figure 3, this reality The step executing example character method for trimming includes:
Step S1: size SizeS of record current control distribution.
Step S2: judge whether control arranges permission line feed (wrapping) automatically;When the situation that judged result is yes Under, perform step S3;In the case of judged result is no, perform step S4.
Step S3: setting drafting target sizes unlimited as height, width is the width of current control.
Step S4: set the target sizes drawn unlimited as width, height is the height of current control.
Step S5: obtaining control text drawing area size is SizeA, and wherein, SizeA is step S3 or step S4 The middle area size determined.
Step S6: set urtext TextA.
Step S7: create text and draw control ControlA and SizeA is appointed as the size of control.
It is SizeB that step S8:ControlA carries out the size after being drawn.
Step S9: judge that SizeB, whether more than SizeS, wherein, in the case of judged result is no, performs step Rapid S10;In the case of judged result is for being, perform step S11.
Step S10: current ControlA is set as the content element of control.
Step S11: length LengthTextA of recording text.
Step S12: block text according to the length of LengthTextA/2.
Step S13: length LengthTextC of record rendering text last time.
Step S14: set text TextB to be redrawn, and text size LengthTextB.
Step S15: set and treat that rendering text adds " ... " character as TextB.
Step S16: create text and draw control ControlA and SizeA is appointed as the size of control.
It is SizeC that step S17:ControlA carries out the size after being drawn.
Step S18: judge that whether SizeC is more than SizeS;Wherein, in the case of judged result is for being, perform step Rapid S19;In the case of judged result is no, perform step S20.
Step S19: reset according to LengthTextB/2 and treat rendering text;Wherein, after performing step S19, continue to hold Row step S17.
Step S20: round according to (LengthTextB+LengthTextC)/2 and obtain LengthTextD.
Step S21: judge that whether LengthTextD is equal to LengthTextB or LengthTextC;Wherein, when Judged result be no in the case of, perform step S22, in the case of judged result is for being, execution step S10.
Step S22: reset according to LengthTextD length and treat rendering text;Wherein, after performing step S22, continue Continuous execution step S17.
Obviously, those skilled in the art should be understood that each module of the above-mentioned present invention or each step can be with general Calculating device realize, they can concentrate on single calculating device, or is distributed in multiple calculating device institute On the network of composition, alternatively, they can realize with calculating the executable program code of device, it is thus possible to It is stored in storing in device and is performed by calculating device, or they are fabricated to respectively each integrated circuit die Block, or the multiple modules in them or step are fabricated to single integrated circuit module realize.So, the present invention It is not restricted to any specific hardware and software combine.
The foregoing is only the preferred embodiments of the present invention, be not limited to the present invention, for the skill of this area For art personnel, the present invention can have various modifications and variations.All within the spirit and principles in the present invention, made Any modification, equivalent substitution and improvement etc., should be included within the scope of the present invention.

Claims (11)

1. a character method for trimming, it is characterised in that including: create can rendering text area size be the control of SizeA Part, and after obtaining viewing area size SizeS distributing to described control, at least performs the most following circulation:
By described control treat character finishing text draw, and obtain treat described in drafting character finishing literary composition This size SizeB;
In the case of the condition of not met end loop, it is judged that whether SizeB is equal to SizeS;In judged result In the case of no, treat that character finishing text cuts out or recovers the word of predetermined number according to pre-defined rule to described Symbol, obtains new treating that text repaired in character;
Wherein, the condition of described end loop includes: the urtext repaired without character treated as described Character finishing text and described judged result are, in the case of SizeB is less than or equal to SizeS, to terminate described circulation, And determine the result that described urtext is character finishing, or, judged result in the circulation after first time For SizeB equal in the case of SizeS, terminate described circulation, and determine new the treating obtained in last circulation Character finishing text is the result of character finishing.
Method the most according to claim 1, it is characterised in that in the case of described control allows line feed automatically, SizeA is highly unlimited and that length is fixing region, and wherein, the length of SizeS and the length of SizeB are equal.
Method the most according to claim 1, it is characterised in that in the case of described control does not allows automatically to enter a new line, SizeA is highly to fix and the region of infinite in length, and wherein, the height of SizeS and the height of SizeB are equal.
Method the most according to claim 1, it is characterised in that determining the SizeB result whether equal to SizeS In the case of no, treat that character finishing text cuts out or recovers predetermined number according to described pre-defined rule by described Character, obtain new treating that character finishing text includes:
Determine SizeB more than in the case of SizeS, treat character finishing literary composition according to described pre-defined rule by described Originally cut out the character of predetermined number, obtain described new treating that text repaired in character;
Determine SizeB less than in the case of SizeS, treat character finishing literary composition according to described pre-defined rule by described The character of this recovery predetermined number, obtains described new treating that text repaired in character.
Method the most according to claim 1, it is characterised in that described pre-defined rule includes one below:
Binary chop, one by one character cut out method.
Method the most according to claim 5, it is characterised in that be the situation of binary chop at described pre-defined rule Under, the condition of described end loop also includes:
In circulation after first time, judged result is that SizeB is less than obtain in SizeS, and previous cycle new Size and previous cycle after character finishing text is drawn before a circulation in obtain new treat character Finishing text draw after equal in magnitude in the case of, terminate described circulation, and determine previous cycle obtains New treats the result that character finishing text is character finishing.
Method the most according to claim 6, it is characterised in that be described binary chop at described pre-defined rule In the case of, treat that character finishing text cuts out or recovers the word of predetermined number according to described binary chop to described Symbol, obtains described new treating that character finishing text includes:
In the case of circulating at the 1st time, cut out the individual character of described text to be trimmed [LenB/2], obtain the 1st New text to be trimmed, wherein, LenB represent described in treat the number of characters of character finishing text, [] represents four houses Five enter to round or round up;
In the case of n-th circulates, cut out described N-1 new text [LenB/2 to be trimmedN] individual word Symbol, or, recover described N-1 new text [LenB/2 to be trimmedN] individual character, obtain n-th new Text to be trimmed, wherein, N is the integer more than 1.
Method the most according to claim 6, it is characterised in that be described binary chop at described pre-defined rule In the case of, treat that character finishing text cuts out or recovers the word of predetermined number according to described binary chop to described Symbol, obtains described new treating that character finishing text includes:
In the case of circulating at the 1st time, cut out the individual character of described text to be trimmed [LenB/2], obtain number of characters For [LenB]1The 1st new text to be trimmed, wherein, LenB represent described in treat character finishing text word Symbol number, [] represents round or rounds up;
In the case of circulating at the 2nd time, cut out described 1st new text to be trimmed [(LenB-[LenB]1)/2] individual character, or, recover described 1st new text to be trimmed [|(LenB-[LenB]1) |/2] individual character, obtain number of characters for [LenB]2The 2nd new text to be trimmed;
In the case of n-th circulates, cut out described N-1 new text to be trimmed [([LenB]N-2-[LenB]N-1)/2] individual character, or, recover described N-1 new text to be trimmed [|([LenB]N-2-[LenB]N-1) |/2] individual character, obtain size for [LenB]NThe new literary composition to be trimmed of n-th This, wherein, N is the integer more than 2.
Method the most according to any one of claim 1 to 8, it is characterised in that perform described circulation primary it After circulation in, treat that character finishing text carries out drafting and includes by described control to described:
Treating that character adds book character after repairing text described, wherein, described book character is used for representing institute State and treat that character finishing text is for by the trimmed text of character;
Described in after adding described book character, treat that character finishing text is drawn by described control.
10. a character trimming device, it is characterised in that including:
Processing module, can rendering text area size be the control of SizeA for creating, and institute is distributed in acquisition State viewing area size SizeS of control;
Loop module, at least performing the most following circulation: treat character finishing text by described control and enter Row is drawn, and obtains size SizeB treating character finishing text described in drafting;Bar in not met end loop In the case of part, it is judged that whether SizeB is equal to SizeS, in the case of judged result is no, according to pre-set pattern Then treat that character finishing text cuts out or recovers the character of predetermined number to described, obtain new treating character finishing literary composition This;
Wherein, the condition of described end loop includes: the urtext repaired without character treated as described Character finishing text and described judged result are, in the case of SizeB is less than or equal to SizeS, to terminate described circulation, And determine the result that described urtext is character finishing;Or, judged result in the circulation after first time For SizeB equal in the case of SizeS, terminate described circulation, and determine new the treating obtained in last circulation Character finishing text is the result of character finishing.
11. devices according to claim 10, it is characterised in that described pre-defined rule includes one below:
Binary chop, one by one character cut out method.
CN201310603871.8A 2013-11-25 2013-11-25 Character method for trimming and device Active CN103605638B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310603871.8A CN103605638B (en) 2013-11-25 2013-11-25 Character method for trimming and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310603871.8A CN103605638B (en) 2013-11-25 2013-11-25 Character method for trimming and device

Publications (2)

Publication Number Publication Date
CN103605638A CN103605638A (en) 2014-02-26
CN103605638B true CN103605638B (en) 2016-08-10

Family

ID=50123867

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310603871.8A Active CN103605638B (en) 2013-11-25 2013-11-25 Character method for trimming and device

Country Status (1)

Country Link
CN (1) CN103605638B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104994312A (en) * 2015-07-15 2015-10-21 北京金山安全软件有限公司 Video generation method and device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004110411A (en) * 2002-09-18 2004-04-08 Nec Corp Document display system, document display method, and document display program
CN101539923A (en) * 2008-03-18 2009-09-23 北京搜狗科技发展有限公司 Method and device for extracting text segment from file
CN102436439A (en) * 2010-09-29 2012-05-02 鸿富锦精密工业(深圳)有限公司 Text box and text display method

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004110411A (en) * 2002-09-18 2004-04-08 Nec Corp Document display system, document display method, and document display program
CN101539923A (en) * 2008-03-18 2009-09-23 北京搜狗科技发展有限公司 Method and device for extracting text segment from file
CN102436439A (en) * 2010-09-29 2012-05-02 鸿富锦精密工业(深圳)有限公司 Text box and text display method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
关于二分法查找算法的历史研究;周广声;《计算机工程》;19841226;52-58 *

Also Published As

Publication number Publication date
CN103605638A (en) 2014-02-26

Similar Documents

Publication Publication Date Title
US9953010B2 (en) Template-based page layout for hosted social magazines
CN105630478B (en) A kind of method and apparatus for realizing page switching
CN103678651B (en) A kind of sensitive word lookup method and device
CN107239566B (en) User journal generation method, electronic equipment and computer-readable storage medium
CN106303723A (en) Method for processing video frequency and device
CN105468617B (en) Adjust the method and device of web page contents color
CN105447205B (en) Method and device for sorting search results
CN110276060A (en) The method and device of data processing
CN108700988A (en) Digital picture is presented
CN104461634B (en) The loading method and device of sharing module on webpage
CN103605638B (en) Character method for trimming and device
CN109558173A (en) For switching the method, apparatus and system of login mode on interface
CN110415324A (en) A method of it is rendered based on cloud
CN105159900B (en) Multi-medium data edit methods and editing machine
US9116886B2 (en) Document translation including pre-defined term translator and translation model
CN103577047B (en) The display processing method of HScrollBar and device for DataGrid control
CN110019380A (en) A kind of data query method, apparatus, server and storage medium
CN109640148A (en) A kind of method and device by text box text exhibition content
CN108090035A (en) Data processing method and device
US20130254157A1 (en) Computer-implemented methods and systems for associating files with cells of a collaborative spreadsheet
CN103778220A (en) Decision support method and device based on cloud computing
CN106161570A (en) Document down loading method based on page script, device, server group and system
CN106202162A (en) A kind of for testing the test system and method recommending room data list
CN106294451A (en) A kind of Data processing display processes method and the device thereof of progress
CN113407847A (en) Recommendation method and device for online three-dimensional exhibition hall and electronic equipment

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
PE01 Entry into force of the registration of the contract for pledge of patent right

Denomination of invention: Character finishing method and character finishing device

Effective date of registration: 20190531

Granted publication date: 20160810

Pledgee: Shenzhen Black Horse World Investment Consulting Co., Ltd.

Pledgor: Beijing Guoshuang Technology Co.,Ltd.

Registration number: 2019990000503

PE01 Entry into force of the registration of the contract for pledge of patent right
CP02 Change in the address of a patent holder

Address after: 100083 No. 401, 4th Floor, Haitai Building, 229 North Fourth Ring Road, Haidian District, Beijing

Patentee after: Beijing Guoshuang Technology Co.,Ltd.

Address before: 100086 Beijing city Haidian District Shuangyushu Area No. 76 Zhichun Road cuigongfandian 8 layer A

Patentee before: Beijing Guoshuang Technology Co.,Ltd.

CP02 Change in the address of a patent holder