diff --git a/icu4j/readme.html b/icu4j/readme.html index b5b42a05b6d..0973dbfff6e 100644 --- a/icu4j/readme.html +++ b/icu4j/readme.html @@ -1714,18 +1714,10 @@ Then try one of the following:

ICU4J Resource Information

Starting with release 2.1, ICU4J includes its own diff --git a/icu4j/src/com/ibm/icu/dev/demo/rbbi/BreakIteratorRules_en_US_DEMO.java b/icu4j/src/com/ibm/icu/dev/demo/rbbi/BreakIteratorRules_en_US_DEMO.java deleted file mode 100755 index 1a74f65bea2..00000000000 --- a/icu4j/src/com/ibm/icu/dev/demo/rbbi/BreakIteratorRules_en_US_DEMO.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - ******************************************************************************* - * Copyright (C) 1996-2004, International Business Machines Corporation and * - * others. All Rights Reserved. * - ******************************************************************************* - */ -package com.ibm.icu.dev.demo.rbbi; - -import java.util.ListResourceBundle; - -import com.ibm.icu.impl.ICUData; - -/** - * This resource bundle is included for testing and demonstration purposes only. - * It applies the dictionary-based algorithm to English text that has had all the - * spaces removed. Once we have good test cases for Thai, we will replace this - * with good resource data (and a good dictionary file) for Thai - */ -public class BreakIteratorRules_en_US_DEMO extends ListResourceBundle { - private static final String DATA_NAME = "/com/ibm/data/misc/english.dict"; - - public Object[][] getContents() { - final boolean exists = ICUData.exists(DATA_NAME); - - if (!exists) { - return new Object[0][0]; - } - - return new Object[][] { - // names of classes to instantiate for the different kinds of break - // iterator. Notice we're now using DictionaryBasedBreakIterator - // for word and line breaking. - { "BreakIteratorClasses", - new String[] { - "RuleBasedBreakIterator", - // character-break iterator class - "DictionaryBasedBreakIterator", - // word-break iterator class - "DictionaryBasedBreakIterator", - // line-break iterator class - "RuleBasedBreakIterator" } // sentence-break iterator class - }, - - // These are the same word-breaking rules as are specified in the default - // resource, except that the Latin letters, apostrophe, and hyphen are - // specified as dictionary characters - { - "WordBreakRules", - // ignore non-spacing marks, enclosing marks, and format characters, - // all of which should not influence the algorithm - "$_ignore_=[[:Mn:][:Me:][:Cf:]];" - - // lower and upper case Roman letters, apostrophy and dash are - // in the English dictionary - +"$_dictionary_=[a-zA-Z\\'\\-];" - - // Hindi phrase separator, kanji, katakana, hiragana, CJK diacriticals, - // other letters, and digits - +"$danda=[\u0964\u0965];" - + "$kanji=[\u3005\u4e00-\u9fa5\uf900-\ufa2d];" - + "$kata=[\u3099-\u309c\u30a1-\u30fe];" - + "$hira=[\u3041-\u309e\u30fc];" - + "$let=[[[:L:][:Mc:]]-[$kanji$kata$hira]];" - + "$dgt=[:N:];" - - // punctuation that can occur in the middle of a word: currently - // dashes, apostrophes, and quotation marks - +"$mid_word=[[:Pd:]\u00ad\u2027\\\"\\\'];" - - // punctuation that can occur in the middle of a number: currently - // apostrophes, qoutation marks, periods, commas, and the Arabic - // decimal point - +"$mid_num=[\\\"\\\'\\,\u066b\\.];" - - // punctuation that can occur at the beginning of a number: currently - // the period, the number sign, and all currency symbols except the cents sign - +"$pre_num=[[[:Sc:]-[\u00a2]]\\#\\.];" - - // punctuation that can occur at the end of a number: currently - // the percent, per-thousand, per-ten-thousand, and Arabic percent - // signs, the cents sign, and the ampersand - +"$post_num=[\\%\\&\u00a2\u066a\u2030\u2031];" - - // line separators: currently LF, FF, PS, and LS - +"$ls=[\n\u000c\u2028\u2029];" - - // whitespace: all space separators and the tab character - +"$ws=[[:Zs:]\t];" - - // a word is a sequence of letters that may contain internal - // punctuation, as long as it begins and ends with a letter and - // never contains two punctuation marks in a row - +"$word=($let+($mid_word$let+)*$danda?);" - - // a number is a sequence of digits that may contain internal - // punctuation, as long as it begins and ends with a digit and - // never contains two punctuation marks in a row. - +"$number=($dgt+($mid_num$dgt+)*);" - - // break after every character, with the following exceptions - // (this will cause punctuation marks that aren't considered - // part of words or numbers to be treated as words unto themselves) - +".;" - - // keep together any sequence of contiguous words and numbers - // (including just one of either), plus an optional trailing - // number-suffix character - +"$word?($number$word)*($number$post_num?)?;" - - // keep together and sequence of contiguous words and numbers - // that starts with a number-prefix character and a number, - // and may end with a number-suffix character - +"$pre_num($number$word)*($number$post_num?)?;" - - // keep together runs of whitespace (optionally with a single trailing - // line separator or CRLF sequence) - +"$ws*\r?$ls?;" - - // keep together runs of Katakana - +"$kata*;" - - // keep together runs of Hiragana - +"$hira*;" - - // keep together runs of Kanji - +"$kanji*;" }, - - // These are the same line-breaking rules as are specified in the default - // resource, except that the Latin letters, apostrophe, and hyphen are - // specified as dictionary characters - { "LineBreakRules", - // ignore non-spacing marks, enclosing marks, and format characters - "$_ignore_=[[:Mn:][:Me:][:Cf:]];" - - // lower and upper case Roman letters, apostrophy and dash - // are in the English dictionary - +"$_dictionary_=[a-zA-Z\\'\\-];" - - // Hindi phrase separators - +"$danda=[\u0964\u0965];" - - // characters that always cause a break: ETX, tab, LF, FF, LS, and PS - +"$break=[\u0003\t\n\f\u2028\u2029];" - - // characters that always prevent a break: the non-breaking space - // and similar characters - +"$nbsp=[\u00a0\u2007\u2011\ufeff];" - - // whitespace: space separators and control characters, except for - // CR and the other characters mentioned above - +"$space=[[[:Zs:][:Cc:]]-[$nbsp$break\r]];" - - // dashes: dash punctuation and the discretionary hyphen, except for - // non-breaking hyphens - +"$dash=[[[:Pd:]\u00ad]-[$nbsp]];" - - // characters that stick to a word if they precede it: currency symbols - // (except the cents sign) and starting punctuation - +"$pre_word=[[[:Sc:]-[\u00a2]][:Ps:]\\\"\\\'];" - - // characters that stick to a word if they follow it: ending punctuation, - // other punctuation that usually occurs at the end of a sentence, - // small Kana characters, some CJK diacritics, etc. - +"$post_word=[[:Pe:]\\!\\\"\\\'\\%\\.\\,\\:\\;\\?\u00a2\u00b0\u066a\u2030-\u2034" - + "\u2103\u2105\u2109\u3001\u3002\u3005\u3041\u3043\u3045\u3047\u3049\u3063" - + "\u3083\u3085\u3087\u308e\u3099-\u309e\u30a1\u30a3\u30a5\u30a7\u30a9" - + "\u30c3\u30e3\u30e5\u30e7\u30ee\u30f5\u30f6\u30fc-\u30fe\uff01\uff0c" - + "\uff0e\uff1f];" - - // Kanji: actually includes both Kanji and Kana, except for small Kana and - // CJK diacritics - +"$kanji=[[\u4e00-\u9fa5\uf900-\ufa2d\u3041-\u3094\u30a1-\u30fa]-[$post_word$_ignore_]];" - - // digits - +"$digit=[[:Nd:][:No:]];" - - // punctuation that can occur in the middle of a number: periods and commas - +"$mid_num=[\\.\\,];" - - // everything not mentioned above, plus the quote marks (which are both - // , , and ) - +"$char=[^$break$space$dash$kanji$nbsp$_ignore_$pre_word$post_word$mid_num$danda\r\\\"\\\'];" - - // a "number" is a run of prefix characters and dashes, followed by one or - // more digits with isolated number-punctuation characters interspersed - +"$number=([$pre_word$dash]*$digit+($mid_num$digit+)*);" - - // the basic core of a word can be either a "number" as defined above, a single - // "Kanji" character, or a run of any number of not-explicitly-mentioned - // characters (this includes Latin letters) - +"$word_core=([$pre_word$char]*|$kanji|$number);" - - // a word may end with an optional suffix that be either a run of one or - // more dashes or a run of word-suffix characters, followed by an optional - // run of whitespace - +"$word_suffix=(($dash+|$post_word*)$space*);" - - // a word, thus, is an optional run of word-prefix characters, followed by - // a word core and a word suffix (the syntax of and - // actually allows either of them to match the empty string, putting a break - // between things like ")(" or "aaa(aaa" - +"$word=($pre_word*$word_core$word_suffix);" - - // finally, the rule that does the work: Keep together any run of words that - // are joined by runs of one of more non-spacing mark. Also keep a trailing - // line-break character or CRLF combination with the word. (line separators - // "win" over nbsp's) - +"$word($nbsp+$word)*\r?$break?;" }, - - // these two resources specify the pathnames of the dictionary files to - // use for word breaking and line breaking. Both currently refer to - // a file called english.dict placed in com.ibm.icu.impl.data - // somewhere in the class path. It's important to note that - // english.dict was created for testing purposes only, and doesn't - // come anywhere close to being an exhaustive dictionary of English - // words (basically, it contains all the words in the Declaration of - // Independence, and the Revised Standard Version of the book of Genesis, - // plus a few other words thrown in to show more interesting cases). - // { "WordBreakDictionary", "com\\ibm\\text\\resources\\english.dict" }, - // { "LineBreakDictionary", "com\\ibm\\text\\resources\\english.dict" } - { "WordBreakDictionary", DATA_NAME }, - { "LineBreakDictionary", DATA_NAME } - }; - } -} diff --git a/icu4j/src/com/ibm/icu/dev/demo/rbbi/DBBIDemo.java b/icu4j/src/com/ibm/icu/dev/demo/rbbi/DBBIDemo.java deleted file mode 100755 index 29ea548c398..00000000000 --- a/icu4j/src/com/ibm/icu/dev/demo/rbbi/DBBIDemo.java +++ /dev/null @@ -1,498 +0,0 @@ -/* - ******************************************************************************* - * Copyright (C) 1996-2007, International Business Machines Corporation and * - * others. All Rights Reserved. * - ******************************************************************************* - */ -package com.ibm.icu.dev.demo.rbbi; - -import java.awt.*; -import java.awt.event.WindowEvent; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.ItemListener; -import java.awt.event.ItemEvent; -import javax.swing.JTextArea; -import javax.swing.JScrollPane; -import javax.swing.BorderFactory; -import java.util.*; -import com.ibm.icu.dev.demo.impl.*; -import com.ibm.icu.text.BreakIterator; - -public class DBBIDemo extends DemoApplet -{ - /** - * For serialization - */ - private static final long serialVersionUID = 7175919574190623523L; - - public static void main(String argv[]) { - Locale.setDefault(new Locale("en", "US", "DEMO")); - new DBBIDemo().showDemo(); - } - - public Frame createDemoFrame(DemoApplet applet) { - return new DBBIFrame(applet); - } -} - - - -class DBBIFrame extends Frame implements ItemListener -{ - - /** - * For serialization - */ - private static final long serialVersionUID = -5905807460776050144L; - private static final Font choiceFont = null; - private static final boolean DEBUG = false; - private DemoApplet applet; - - final String right = "-->"; - final String left = "<--"; - - private BreakIterator iter; - private static boolean isctrldown_ = false; - -JTextArea text; -// TextArea text; - Choice bound; - - public DBBIFrame(DemoApplet applet) - { - this.applet = applet; - init(); - start(); - } - - - - public void run() - { - /* - while (true) { - try { - checkChange(); - Thread.sleep(250); - } - catch (InterruptedException e) { - } - catch (Exception e) { - } - catch (Throwable e) { - } - } - */ - } - - int start, end; - int ts, te; - - public void checkChange() - { -// System.out.println("checkChange..."); - if ((text.getSelectionStart() & 0x7FFF) != ts || - (text.getSelectionEnd() & 0x7FFF) != te) { - - // not used int tempS = text.getSelectionStart() & 0x7FFF; - // not used int tempE = text.getSelectionEnd() & 0x7FFF; - -// System.out.println(">"); -// select(0, 0); -// select(tempS, tempE); - //select(tempS - (ts - s), tempE - (te - e)); -// System.out.println("<"); - - -// if (s != ts || e != te) System.out.println(" s("+s+") ts("+ts+") e("+e+") te("+te+")"); -// if (tempS != ts || tempE != te) System.out.println(">s("+s+") tempS("+tempS+") e("+e+") tempE("+tempE+")"); -// select(s - (ts - s), e - (te - e)); -// if (tempS != ts || tempE != te) System.out.println("s("+s+") tempS("+tempS+") e("+e+") tempE("+tempE+")"); - -// System.out.println("lkdslksj"); - } - } - - public void select(int sIn, int eIn) - { - start = sIn; - end = eIn; - text.select(start, end); - ts = text.getSelectionStart() & 0x7FFF; - te = text.getSelectionEnd() & 0x7FFF; -// if (s != ts || e != te) { -// System.out.println(">s("+s+") ts("+ts+") e("+e+") te("+te+")"); -// System.out.println(" "+(ts-s)+","+(te-e)); -// } - } - - public int getSelectionStart() - { - checkChange(); -// return s; - return text.getSelectionStart() & 0x7FFF; - } - - - public int getSelectionEnd() - { - checkChange(); -// return e; - return text.getSelectionEnd() & 0x7FFF; - } - - public final synchronized void selectRange(int s, int e) - { - try { - //if (getSelectionStart() != s || getSelectionEnd() != e) { - //text.select(s, e); - select(s,e); - //} -// if (getSelectionStart() != s || getSelectionEnd() != e) { -// System.out.println("AGH! select("+s+","+e+") -> ("+ -// getSelectionStart()+","+getSelectionEnd()+")"); -// text.select(s - (getSelectionStart() - s), e - (getSelectionEnd() - e)); -// } - } catch (Exception exp) { - errorText(exp.toString()); - } - } - - - - public void init() - { - buildGUI(); - } - - - public void start() - { - } - - - void addWithFont(Container container, Component foo, Font font) { - if (font != null) - foo.setFont(font); - container.add(foo); - } - - - - public void buildGUI() - { - setBackground(DemoUtility.bgColor); - setLayout(new BorderLayout()); - - Panel topPanel = new Panel(); - - Label titleLabel = - new Label("Text Boundary Demo", Label.CENTER); - titleLabel.setFont(DemoUtility.titleFont); - topPanel.add(titleLabel); - - //Label demo=new Label(creditString, Label.CENTER); - //demo.setFont(DemoUtility.creditFont); - //topPanel.add(demo); - - Panel choicePanel = new Panel(); - - Label demo1=new Label("Boundaries", Label.LEFT); - demo1.setFont(DemoUtility.labelFont); - choicePanel.add(demo1); - - bound = new Choice(); - bound.setBackground(DemoUtility.choiceColor); - bound.addItem("Sentence"); - bound.addItem("Line Break"); - bound.addItem("Word"); - bound.addItem("Char"); - - bound.addItemListener(this); - if (choiceFont != null) - bound.setFont(choiceFont); - - choicePanel.add(bound); - topPanel.add(choicePanel); - - DemoUtility.fixGrid(topPanel,1); - - - add("North", topPanel); - - - int ROWS = 15; - int COLUMNS = 50; -// text = new TextArea(getInitialText(), ROWS, COLUMNS); -text = new JTextArea(getInitialText(), ROWS, COLUMNS); -text.setLineWrap(true); -text.setWrapStyleWord(true); - text.setEditable(true); - text.selectAll(); - text.setFont(DemoUtility.editFont); - text.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); - - add("Center", new JScrollPane(text, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, - JScrollPane.HORIZONTAL_SCROLLBAR_NEVER)); - - Panel copyrightPanel = new Panel(); - addWithFont (copyrightPanel, - new Label(DemoUtility.copyright1, Label.LEFT),DemoUtility.creditFont); - DemoUtility.fixGrid(copyrightPanel,1); - add("South", copyrightPanel); - - //layout(); - handleEnumChanged(); - - enableEvents(WindowEvent.WINDOW_CLOSING); - enableEvents(KeyEvent.KEY_PRESSED); - enableEvents(KeyEvent.KEY_RELEASED); - - text.addKeyListener(new KeyAdapter() { - public void keyPressed(KeyEvent e) { - if (e.isControlDown()) { - int kc = e.getKeyCode(); - switch (kc) { - case KeyEvent.VK_N: - case KeyEvent.VK_RIGHT: - handleForward(); - break; - case KeyEvent.VK_P: - case KeyEvent.VK_LEFT: - handleBackward(); - break; - default: - break; - } - e.consume(); - } - } - public void keyReleased(KeyEvent e) { - if (e.isControlDown()) { - e.consume(); - } - } - public void keyTyped(KeyEvent e) { - if (e.isControlDown()) { - e.consume(); - } - } - }); - - // (new Thread(this)).start(); - } - - - - public String getInitialText() - { - return -"When,inthecourseofhumanevents,itbecomesnecessaryforonepeopletodissolvethepoliticalbondswhichhave" -+ "connectedthemwithanother,andtoassumeamongthepowersoftheearth,theseparateandequalstationtowhichthelaws" -+ "ofnatureandofnature'sGodentitlethem,adecentrespecttotheopinionsofmankindrequiresthattheyshoulddeclarethe" -+ "causeswhichimpelthemtotheseparation.\n" -+ "Weholdthesetruthstobeself-evident,thatallmenarecreatedequal,thattheyareendowedbytheirCreatorwithcertain" -+ "unalienablerights,thatamongthesearelife,libertyandthepursuitofhappiness.Thattosecuretheserights,governmentsare" -+ "institutedamongmen,derivingtheirjustpowersfromtheconsentofthegoverned.Thatwheneveranyformofgovernment" -+ "becomesdestructivetotheseends,itistherightofthepeopletoalterortoabolishit,andtoinstitutenewgovernment,laying" -+ "itsfoundationonsuchprinciplesandorganizingitspowersinsuchform,astothemshallseemmostlikelytoeffecttheirsafety" -+ "andhappiness.Prudence,indeed,willdictatethatgovernmentslongestablishedshouldnotbechangedforlightandtransient" -+ "causes;andaccordinglyallexperiencehathshownthatmankindaremoredisposedtosuffer,whileevilsaresufferable,than" -+ "torightthemselvesbyabolishingtheformstowhichtheyareaccustomed.Butwhenalongtrainofabusesandusurpations," -+ "pursuinginvariablythesameobjectevincesadesigntoreducethemunderabsolutedespotism,itistheirright,itistheirduty," -+ "tothrowoffsuchgovernment,andtoprovidenewguardsfortheirfuturesecurity.--Suchhasbeenthepatientsufferanceof" -+ "thesecolonies;andsuchisnowthenecessitywhichconstrainsthemtoaltertheirformersystemsofgovernment.Thehistory" -+ "ofthepresentKingofGreatBritainisahistoryofrepeatedinjuriesandusurpations,allhavingindirectobjectthe" -+ "establishmentofanabsolutetyrannyoverthesestates.Toprovethis,letfactsbesubmittedtoacandidworld.\n" -+ "Hehasrefusedhisassenttolaws,themostwholesomeandnecessaryforthepublicgood.\n" -+ "Hehasforbiddenhisgovernorstopasslawsofimmediateandpressingimportance,unlesssuspendedintheiroperationtill" -+ "hisassentshouldbeobtained;andwhensosuspended,hehasutterlyneglectedtoattendtothem.\n" -+ "Hehasrefusedtopassotherlawsfortheaccommodationoflargedistrictsofpeople,unlessthosepeoplewouldrelinquish" -+ "therightofrepresentationinthelegislature,arightinestimabletothemandformidabletotyrantsonly.\n" -+ "Hehascalledtogetherlegislativebodiesatplacesunusual,uncomfortable,anddistantfromthedepositoryoftheirpublic" -+ "records,forthesolepurposeoffatiguingthemintocompliancewithhismeasures.\n" -+ "Hehasdissolvedrepresentativehousesrepeatedly,foropposingwithmanlyfirmnesshisinvasionsontherightsofthepeople.\n" -+ "Hehasrefusedforalongtime,aftersuchdissolutions,tocauseotherstobeelected;wherebythelegislativepowers," -+ "incapableofannihilation,havereturnedtothepeopleatlargefortheirexercise;thestateremaininginthemeantimeexposed" -+ "toallthedangersofinvasionfromwithout,andconvulsionswithin.\n" -+ "Hehasendeavoredtopreventthepopulationofthesestates;forthatpurposeobstructingthelawsfornaturalizationof" -+ "foreigners;refusingtopassotherstoencouragetheirmigrationhither,andraisingtheconditionsofnewappropriationsof" -+ "lands.\n" -+ "Hehasobstructedtheadministrationofjustice,byrefusinghisassenttolawsforestablishingjudiciarypowers.\n" -+ "Hehasmadejudgesdependentonhiswillalone,forthetenureoftheiroffices,andtheamountandpaymentoftheirsalaries.\n" -+ "Hehaserectedamultitudeofnewoffices,andsenthitherswarmsofofficerstoharassourpeople,andeatouttheir" -+ "substance.\n" -+ "Hehaskeptamongus,intimesofpeace,standingarmieswithouttheconsentofourlegislature.\n" -+ "Hehasaffectedtorenderthemilitaryindependentofandsuperiortocivilpower.\n" -+ "Hehascombinedwithotherstosubjectustoajurisdictionforeigntoourconstitution,andunacknowledgedbyourlaws;" -+ "givinghisassenttotheiractsofpretendedlegislation:\n" -+ "Forquarteringlargebodiesofarmedtroopsamongus:\n" -+ "Forprotectingthem,bymocktrial,frompunishmentforanymurderswhichtheyshouldcommitontheinhabitantsofthese" -+ "states:\n" -+ "Forcuttingoffourtradewithallpartsoftheworld:\n" -+ "Forimposingtaxesonuswithoutourconsent:\n" -+ "Fordeprivingusinmanycases,ofthebenefitsoftrialbyjury:\n" -+ "Fortransportingusbeyondseastobetriedforpretendedoffenses:\n" -+ "ForabolishingthefreesystemofEnglishlawsinaneighboringprovince,establishingthereinanarbitrarygovernment,and" -+ "enlargingitsboundariessoastorenderitatonceanexampleandfitinstrumentforintroducingthesameabsoluteruleinthese" -+ "colonies:\n" -+ "Fortakingawayourcharters,abolishingourmostvaluablelaws,andalteringfundamentallytheformsofourgovernments:\n" -+ "Forsuspendingourownlegislatures,anddeclaringthemselvesinvestedwithpowertolegislateforusinallcaseswhatsoever.\n" -+ "Hehasabdicatedgovernmenthere,bydeclaringusoutofhisprotectionandwagingwaragainstus.\n" -+ "Hehasplunderedourseas,ravagedourcoasts,burnedourtowns,anddestroyedthelivesofourpeople.\n" -+ "Heisatthistimetransportinglargearmiesofforeignmercenariestocompletetheworksofdeath,desolationandtyranny," -+ "alreadybegunwithcircumstancesofcrueltyandperfidyscarcelyparalleledinthemostbarbarousages,andtotallyunworthy" -+ "theheadofacivilizednation.\n" -+ "Hehasconstrainedourfellowcitizenstakencaptiveonthehighseastobeararmsagainsttheircountry,tobecomethe" -+ "executionersoftheirfriendsandbrethren,ortofallthemselvesbytheirhands.\n" -+ "Hehasexciteddomesticinsurrectionsamongstus,andhasendeavoredtobringontheinhabitantsofourfrontiers,the" -+ "mercilessIndiansavages,whoseknownruleofwarfare,isundistinguisheddestructionofallages,sexesandconditions.\n" -+ "Ineverystageoftheseoppressionswehavepetitionedforredressinthemosthumbleterms:ourrepeatedpetitionshave" -+ "beenansweredonlybyrepeatedinjury.Aprince,whosecharacteristhusmarkedbyeveryactwhichmaydefineatyrant,is" -+ "unfittobetherulerofafreepeople.\n" -+ "NorhavewebeenwantinginattentiontoourBritishbrethren.Wehavewarnedthemfromtimetotimeofattemptsbytheir" -+ "legislaturetoextendanunwarrantablejurisdictionoverus.Wehaveremindedthemofthecircumstancesofouremigration" -+ "andsettlementhere.Wehaveappealedtotheirnativejusticeandmagnanimity,andwehaveconjuredthembythetiesofour" -+ "commonkindredtodisavowtheseusurpations,which,wouldinevitablyinterruptourconnectionsandcorrespondence.We" -+ "must,therefore,acquiesceinthenecessity,whichdenouncesourseparation,andholdthem,asweholdtherestofmankind," -+ "enemiesinwar,inpeacefriends.\n" -+ "We,therefore,therepresentativesoftheUnitedStatesofAmerica,inGeneralCongress,assembled,appealingtothe" -+ "SupremeJudgeoftheworldfortherectitudeofourintentions,do,inthename,andbytheauthorityofthegoodpeopleof" -+ "thesecolonies,solemnlypublishanddeclare,thattheseunitedcoloniesare,andofrightoughttobefreeandindependent" -+ "states;thattheyareabsolvedfromallallegiancetotheBritishCrown,andthatallpoliticalconnectionbetweenthemandthe" -+ "stateofGreatBritain,isandoughttobetotallydissolved;andthatasfreeandindependentstates,theyhavefullpowerto" -+ "leveywar,concludepeace,contractalliances,establishcommerce,andtodoallotheractsandthingswhichindependent" -+ "statesmayofrightdo.Andforthesupportofthisdeclaration,withafirmrelianceontheprotectionofDivineProvidence,we" -+ "mutuallypledgetoeachotherourlives,ourfortunesandoursacredhonor.\n"; - } - - - public void handleEnumChanged() - { - String s = bound.getSelectedItem(); - if (s.equals("Char")) { - errorText("getCharacterInstance"); - iter = BreakIterator.getCharacterInstance(); - } - else if (s.equals("Word")) { - errorText("getWordInstance"); - iter = BreakIterator.getWordInstance(); - } - else if (s.equals("Line Break")) { - errorText("getLineInstance"); - iter = BreakIterator.getLineInstance(); - } - else /* if (s.equals("Sentence")) */ { - errorText("getSentenceInstance"); - iter = BreakIterator.getSentenceInstance(); - } - iter.setText(text.getText()); - selectRange(0, 0); - //text.select(0,0); - } - - public void handleForward() - { - try { -// System.out.println("entering handleForward"); - iter.setText(text.getText()); - int oldStart = getSelectionStart(); - int oldEnd = getSelectionEnd(); - -// System.out.println("handleForward: oldStart=" + oldStart + ", oldEnd=" + oldEnd); - - if (oldEnd < 1) { - selectRange(0, iter.following(0)); - } - else { - int s = iter.following(oldEnd-1); - int e = iter.next(); - if (e == -1) { - e = s; - } - selectRange(s, e); - } - //text.select(s, e); - errorText("<" + oldStart + "," + oldEnd + "> -> <" + - start + "," + end + ">"); - } - catch (Exception exp) { - errorText(exp.toString()); - } - } - - public void handleBackward() - { - try { - iter.setText(text.getText()); - int oldStart = getSelectionStart(); - int oldEnd = getSelectionEnd(); - if (oldStart < 1) { - selectRange(0, 0); - } - else { - int e = iter.following(oldStart-1); - int s = iter.previous(); - selectRange(s, e); - } - //text.select(s, e); - errorText("<" + oldStart + "," + oldEnd + "> -> <" + start + "," + end + ">"); - } - catch (Exception exp) { - errorText(exp.toString()); - } - } - - public void itemStateChanged(ItemEvent evt) - { - if (evt.getSource() instanceof Choice) { - handleEnumChanged(); - } - } - - public void errorText(String s) - { - if (DEBUG) - System.out.println(s); - } - - protected void processWindowEvent(WindowEvent evt) - { - if (evt.getID() == WindowEvent.WINDOW_CLOSING && - evt.getWindow() == this) { - hide(); - dispose(); - if (applet != null) { - applet.demoClosed(); - } else System.exit(0); - } - } - - protected void processKeyEvent(KeyEvent evt) - { - switch (evt.getID()) { - case KeyEvent.KEY_PRESSED : - if (evt.getKeyCode() == KeyEvent.VK_CONTROL) { - isctrldown_ = true; - } - break; - case KeyEvent.KEY_RELEASED : - // key detection for left and right buttons are removed - // to emulate the old release behaviour - int key = evt.getKeyCode(); - if (key == KeyEvent.VK_N && isctrldown_) { - handleForward(); - } - else - if (key == KeyEvent.VK_P && isctrldown_) { - handleBackward(); - } - else - if (key == KeyEvent.VK_CONTROL) { - isctrldown_ = false; - } - break; - } - } -} diff --git a/icu4j/src/com/ibm/icu/dev/demo/rbbi/RBBIDemo.java b/icu4j/src/com/ibm/icu/dev/demo/rbbi/RBBIDemo.java deleted file mode 100755 index ace92a4da75..00000000000 --- a/icu4j/src/com/ibm/icu/dev/demo/rbbi/RBBIDemo.java +++ /dev/null @@ -1,484 +0,0 @@ -/* - ******************************************************************************* - * Copyright (C) 1996-2007, International Business Machines Corporation and * - * others. All Rights Reserved. * - ******************************************************************************* - */ -package com.ibm.icu.dev.demo.rbbi; - -import java.awt.*; -import java.awt.event.WindowEvent; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.ItemListener; -import java.awt.event.ItemEvent; -import javax.swing.JTextArea; -import javax.swing.JScrollPane; -import javax.swing.BorderFactory; -import java.util.*; -import com.ibm.icu.dev.demo.impl.*; -import com.ibm.icu.text.BreakIterator; - -public class RBBIDemo extends DemoApplet -{ - /** - * For serialization - */ - private static final long serialVersionUID = 728543547366617131L; - - public static void main(String argv[]) { - Locale.setDefault(new Locale("en", "US")); - new RBBIDemo().showDemo(); - } - - public Frame createDemoFrame(DemoApplet applet) { - return new RBBIFrame(applet); - } -} - - - -class RBBIFrame extends Frame implements ItemListener -{ - /** - * For serialization - */ - private static final long serialVersionUID = 5986183892855142947L; - //private static final String creditString = "v1.1a9, Demo"; - - //private static final int FIELD_COLUMNS = 45; - private static final Font choiceFont = null; - private static final boolean DEBUG = false; - private DemoApplet applet; - - final String right = "-->"; - final String left = "<--"; - - private BreakIterator iter; - private boolean isctrldown_ = false; - - JTextArea text; -// TextArea text; - Choice bound; - - public RBBIFrame(DemoApplet applet) - { - this.applet = applet; - init(); - start(); - } - - - - public void run() - { - /* - while (true) { - try { - checkChange(); - Thread.sleep(250); - } - catch (InterruptedException e) { - } - catch (Exception e) { - } - catch (Throwable e) { - } - } - */ - } - - int start, end; - int ts, te; - - public void checkChange() - { -// System.out.println("checkChange..."); - if ((text.getSelectionStart() & 0x7FFF) != ts || - (text.getSelectionEnd() & 0x7FFF) != te) { - - // not used int tempS = text.getSelectionStart() & 0x7FFF; - // not used int tempE = text.getSelectionEnd() & 0x7FFF; - -// System.out.println(">"); -// select(0, 0); -// select(tempS, tempE); - //select(tempS - (ts - s), tempE - (te - e)); -// System.out.println("<"); - - -// if (s != ts || e != te) System.out.println(" s("+s+") ts("+ts+") e("+e+") te("+te+")"); -// if (tempS != ts || tempE != te) System.out.println(">s("+s+") tempS("+tempS+") e("+e+") tempE("+tempE+")"); -// select(s - (ts - s), e - (te - e)); -// if (tempS != ts || tempE != te) System.out.println("s("+s+") tempS("+tempS+") e("+e+") tempE("+tempE+")"); - -// System.out.println("lkdslksj"); - } - } - - public void select(int sIn, int eIn) - { - start = sIn; - end = eIn; - text.select(start, end); - ts = text.getSelectionStart() & 0x7FFF; - te = text.getSelectionEnd() & 0x7FFF; -// if (s != ts || e != te) { -// System.out.println(">s("+s+") ts("+ts+") e("+e+") te("+te+")"); -// System.out.println(" "+(ts-s)+","+(te-e)); -// } - } - - public int getSelectionStart() - { - checkChange(); -// return s; - return text.getSelectionStart() & 0x7FFF; - } - - - public int getSelectionEnd() - { - checkChange(); -// return e; - return text.getSelectionEnd() & 0x7FFF; - } - - public final synchronized void selectRange(int s, int e) - { - try { - //if (getSelectionStart() != s || getSelectionEnd() != e) { - //text.select(s, e); - select(s,e); - //} -// if (getSelectionStart() != s || getSelectionEnd() != e) { -// System.out.println("AGH! select("+s+","+e+") -> ("+ -// getSelectionStart()+","+getSelectionEnd()+")"); -// text.select(s - (getSelectionStart() - s), e - (getSelectionEnd() - e)); -// } - } catch (Exception exp) { - errorText(exp.toString()); - } - } - - - - public void init() - { - buildGUI(); - } - - - public void start() - { - } - - - void addWithFont(Container container, Component foo, Font font) { - if (font != null) - foo.setFont(font); - container.add(foo); - } - - - - public void buildGUI() - { - setBackground(DemoUtility.bgColor); - setLayout(new BorderLayout()); - - Panel topPanel = new Panel(); - - Label titleLabel = - new Label("Deva Text Boundary Demo", Label.CENTER); - titleLabel.setFont(DemoUtility.titleFont); - topPanel.add(titleLabel); - - //Label demo=new Label(creditString, Label.CENTER); - //demo.setFont(DemoUtility.creditFont); - //topPanel.add(demo); - - Panel choicePanel = new Panel(); - - Label demo1=new Label("Boundaries", Label.LEFT); - demo1.setFont(DemoUtility.labelFont); - choicePanel.add(demo1); - - bound = new Choice(); - bound.setBackground(DemoUtility.choiceColor); - bound.addItem("Sentence"); - bound.addItem("Line Break"); - bound.addItem("Word"); - bound.addItem("Char"); - bound.addItemListener(this); - if (choiceFont != null) - bound.setFont(choiceFont); - - choicePanel.add(bound); - topPanel.add(choicePanel); - - DemoUtility.fixGrid(topPanel,1); - - - add("North", topPanel); - - - int ROWS = 15; - int COLUMNS = 50; -// text = new TextArea(getInitialText(), ROWS, COLUMNS); - text = new JTextArea(getInitialText(), ROWS, COLUMNS); - text.setLineWrap(true); - text.setWrapStyleWord(true); - text.setEditable(true); - text.selectAll(); - text.setFont(new Font("Devanagari MT for IBM", Font.PLAIN, 48)); - text.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); - - add("Center", new JScrollPane(text, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, - JScrollPane.HORIZONTAL_SCROLLBAR_NEVER)); - - Panel copyrightPanel = new Panel(); - addWithFont (copyrightPanel, - new Label(DemoUtility.copyright1, Label.LEFT),DemoUtility.creditFont); - DemoUtility.fixGrid(copyrightPanel,1); - add("South", copyrightPanel); - - //layout(); - handleEnumChanged(); - - enableEvents(WindowEvent.WINDOW_CLOSING); - enableEvents(KeyEvent.KEY_PRESSED); - enableEvents(KeyEvent.KEY_RELEASED); - - text.addKeyListener(new KeyAdapter() { - public void keyPressed(KeyEvent e) { - if (e.isControlDown()) { - int kc = e.getKeyCode(); - switch (kc) { - case KeyEvent.VK_N: - case KeyEvent.VK_RIGHT: - handleForward(); - break; - case KeyEvent.VK_P: - case KeyEvent.VK_LEFT: - handleBackward(); - break; - default: - break; - } - e.consume(); - } - } - public void keyReleased(KeyEvent e) { - if (e.isControlDown()) { - e.consume(); - } - } - public void keyTyped(KeyEvent e) { - if (e.isControlDown()) { - e.consume(); - } - } - }); - - // (new Thread(this)).start(); - } - - - - public String getInitialText() - { - return - "\u0936\u094d\u0930\u0940\u092e\u0926\u094d " + - "\u092d\u0917\u0935\u0926\u094d\u0917\u0940\u0924\u093e " + - "\u0905\u0927\u094d\u092f\u093e\u092f " + - "\u0905\u0930\u094d\u091c\u0941\u0928 " + - "\u0935\u093f\u0937\u093e\u0926 " + - "\u092f\u094b\u0917 " + - "\u0927\u0943\u0924\u0930\u093e\u0937\u094d\u091f\u094d\u0930 " + - "\u0909\u0935\u093E\u091A\u0964 " + - "\u0927\u0930\u094d\u092e\u0915\u094d\u0937\u0947\u0924\u094d\u0930\u0947 " + - "\u0915\u0941\u0930\u0941\u0915\u094d\u0937\u0947\u0924\u094d\u0930\u0947 " + - "\u0938\u092e\u0935\u0947\u0924\u093e " + - "\u092f\u0941\u092f\u0941\u0924\u094d\u0938\u0935\u0903 " + - "\u092e\u093e\u092e\u0915\u093e\u0903 " + - "\u092a\u093e\u0923\u094d\u0921\u0935\u093e\u0936\u094d\u091a\u0948\u0935 " + - "\u0915\u093f\u092e\u0915\u0941\u0930\u094d\u0935\u0924 " + - "\u0938\u0902\u091c\u092F"; - } - - - public void handleEnumChanged() - { - String s = bound.getSelectedItem(); - if (s.equals("Char")) { - errorText("getCharacterInstance"); - iter = BreakIterator.getCharacterInstance(); - } - else if (s.equals("Word")) { - errorText("tWordBreak"); - iter = BreakIterator.getWordInstance(); - } - else if (s.equals("Line Break")) { - errorText("getLineInstance"); - iter = BreakIterator.getLineInstance(); - } - else /* if (s.equals("Sentence")) */ { - errorText("getSentenceInstance"); - iter = BreakIterator.getSentenceInstance(); - } - iter.setText(text.getText()); - selectRange(0, 0); - //text.select(0,0); - } - - public void handleForward() - { - try { -// System.out.println("entering handleForward"); - iter.setText(text.getText()); - int oldStart = getSelectionStart(); - int oldEnd = getSelectionEnd(); - -// System.out.println("handleForward: oldStart=" + oldStart + ", oldEnd=" + oldEnd); - - if (oldEnd < 1) { - selectRange(0, iter.following(0)); - } - else { - int s = iter.following(oldEnd-1); - int e = iter.next(); - if (e == -1) { - e = s; - } - selectRange(s, e); - } - //text.select(s, e); - errorText("<" + oldStart + "," + oldEnd + "> -> <" + - start + "," + end + ">"); - } - catch (Exception exp) { - errorText(exp.toString()); - } - } - - public void handleBackward() - { - try { - iter.setText(text.getText()); - int oldStart = getSelectionStart(); - int oldEnd = getSelectionEnd(); - if (oldStart < 1) { - selectRange(0, 0); - } - else { - int e = iter.following(oldStart-1); - int s = iter.previous(); - selectRange(s, e); - } - //text.select(s, e); - errorText("<" + oldStart + "," + oldEnd + "> -> <" + start + "," + end + ">"); - } - catch (Exception exp) { - errorText(exp.toString()); - } - } - - /* - public boolean action(Event evt, Object obj) - { - - if(evt.target instanceof Button && left.equals(obj)) - { - handleBackward(); - return true; - } - else if(evt.target instanceof Button && right.equals(obj)) - { - handleForward(); - return true; - } - else if(evt.target instanceof Choice) - { - handleEnumChanged(); - return true; - } - return false; - } - - public boolean handleEvent(Event evt) - { - if (evt.id == Event.KEY_PRESS || evt.id == Event.KEY_ACTION) { - if (evt.key == Event.RIGHT || (evt.key == 0x0E && evt.controlDown())) { - handleForward(); - return true; - } - else if (evt.key == Event.LEFT || (evt.key == 0x10 && evt.controlDown())) { - handleBackward(); - return true; - } - } - else - if (evt.id == Event.WINDOW_DESTROY && evt.target == this) { - this.hide(); - this.dispose(); - if (applet != null) { - applet.demoClosed(); - } else System.exit(0); - return true; - } - return super.handleEvent(evt); - }*/ - - public void itemStateChanged(ItemEvent evt) - { - if (evt.getSource() instanceof Choice) { - handleEnumChanged(); - } - } - - public void errorText(String s) - { - if (DEBUG) - System.out.println(s); - } - - protected void processWindowEvent(WindowEvent evt) - { - if (evt.getID() == WindowEvent.WINDOW_CLOSING && - evt.getWindow() == this) { - hide(); - dispose(); - if (applet != null) { - applet.demoClosed(); - } else System.exit(0); - } - } - - protected void processKeyEvent(KeyEvent evt) - { - switch (evt.getID()) { - case KeyEvent.KEY_PRESSED : - if (evt.getKeyCode() == KeyEvent.VK_CONTROL) { - isctrldown_ = true; - } - break; - case KeyEvent.KEY_RELEASED : - // key detection for left and right buttons are removed - // to emulate the old release behaviour - int key = evt.getKeyCode(); - if (key == KeyEvent.VK_N && isctrldown_) { - handleForward(); - } - else - if (key == KeyEvent.VK_P && isctrldown_) { - handleBackward(); - } - else - if (key == KeyEvent.VK_CONTROL) { - isctrldown_ = false; - } - break; - } - } -} diff --git a/icu4j/src/com/ibm/icu/dev/demo/rbbi/TextBoundDemo.java b/icu4j/src/com/ibm/icu/dev/demo/rbbi/TextBoundDemo.java deleted file mode 100755 index 9a847aae878..00000000000 --- a/icu4j/src/com/ibm/icu/dev/demo/rbbi/TextBoundDemo.java +++ /dev/null @@ -1,465 +0,0 @@ -/* - ******************************************************************************* - * Copyright (C) 1996-2007, International Business Machines Corporation and * - * others. All Rights Reserved. * - ******************************************************************************* - */ -package com.ibm.icu.dev.demo.rbbi; - -import java.awt.*; -import java.awt.event.ItemListener; -import java.awt.event.ItemEvent; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.WindowEvent; -import javax.swing.JTextArea; -import javax.swing.JScrollPane; -import javax.swing.BorderFactory; -import com.ibm.icu.dev.demo.impl.*; -import com.ibm.icu.text.BreakIterator; - -public class TextBoundDemo extends DemoApplet -{ - /** - * For serialization - */ - private static final long serialVersionUID = 8123658019297481938L; - - public static void main(String argv[]) { - new TextBoundDemo().showDemo(); - } - - public Frame createDemoFrame(DemoApplet applet) { - return new TextBoundFrame(applet); - } -} - - - -class TextBoundFrame extends Frame implements ItemListener -{ - /** - * For serialization - */ - private static final long serialVersionUID = 4829041307280329194L; -// private static final String creditString = -// "v1.1a9, Demo"; - -// private static final int FIELD_COLUMNS = 45; - private static final Font choiceFont = null; - private static final boolean DEBUG = false; - private DemoApplet applet; - - final String right = "-->"; - final String left = "<--"; - - private BreakIterator iter; - private boolean isctrldown_ = false; - -JTextArea text; -// TextArea text; - Choice bound; - - public TextBoundFrame(DemoApplet applet) - { - this.applet = applet; - init(); - start(); - } - - - - public void run() - { - /* - while (true) { - try { - checkChange(); - Thread.sleep(250); - } - catch (InterruptedException e) { - } - catch (Exception e) { - } - catch (Throwable e) { - } - } - */ - } - - int start, end; - int ts, te; - - public void checkChange() - { -// System.out.println("checkChange..."); - if ((text.getSelectionStart() & 0x7FFF) != ts || - (text.getSelectionEnd() & 0x7FFF) != te) { - - // not used int tempS = text.getSelectionStart() & 0x7FFF; - // not used int tempE = text.getSelectionEnd() & 0x7FFF; - -// System.out.println(">"); -// select(0, 0); -// select(tempS, tempE); - //select(tempS - (ts - s), tempE - (te - e)); -// System.out.println("<"); - - -// if (s != ts || e != te) System.out.println(" s("+s+") ts("+ts+") e("+e+") te("+te+")"); -// if (tempS != ts || tempE != te) System.out.println(">s("+s+") tempS("+tempS+") e("+e+") tempE("+tempE+")"); -// select(s - (ts - s), e - (te - e)); -// if (tempS != ts || tempE != te) System.out.println("s("+s+") tempS("+tempS+") e("+e+") tempE("+tempE+")"); - -// System.out.println("lkdslksj"); - } - } - - public void select(int sIn, int eIn) - { - start = sIn; - end = eIn; - text.select(start, end); - ts = text.getSelectionStart() & 0x7FFF; - te = text.getSelectionEnd() & 0x7FFF; -// if (s != ts || e != te) { -// System.out.println(">s("+s+") ts("+ts+") e("+e+") te("+te+")"); -// System.out.println(" "+(ts-s)+","+(te-e)); -// } - } - - public int getSelectionStart() - { - checkChange(); -// return s; - return text.getSelectionStart() & 0x7FFF; - } - - - public int getSelectionEnd() - { - checkChange(); -// return e; - return text.getSelectionEnd() & 0x7FFF; - } - - public final synchronized void selectRange(int s, int e) - { - try { - //if (getSelectionStart() != s || getSelectionEnd() != e) { - //text.select(s, e); - select(s,e); - //} -// if (getSelectionStart() != s || getSelectionEnd() != e) { -// System.out.println("AGH! select("+s+","+e+") -> ("+ -// getSelectionStart()+","+getSelectionEnd()+")"); -// text.select(s - (getSelectionStart() - s), e - (getSelectionEnd() - e)); -// } - } catch (Exception exp) { - errorText(exp.toString()); - } - } - - - - public void init() - { - buildGUI(); - } - - - public void start() - { - } - - - void addWithFont(Container container, Component foo, Font font) { - if (font != null) - foo.setFont(font); - container.add(foo); - } - - - - public void buildGUI() - { - setBackground(DemoUtility.bgColor); - setLayout(new BorderLayout()); - - Panel topPanel = new Panel(); - - Label titleLabel = - new Label("Text Boundary Demo", Label.CENTER); - titleLabel.setFont(DemoUtility.titleFont); - topPanel.add(titleLabel); - - //Label demo=new Label(creditString, Label.CENTER); - //demo.setFont(DemoUtility.creditFont); - //topPanel.add(demo); - - Panel choicePanel = new Panel(); - - Label demo1=new Label("Boundaries", Label.LEFT); - demo1.setFont(DemoUtility.labelFont); - choicePanel.add(demo1); - - bound = new Choice(); - bound.setBackground(DemoUtility.choiceColor); - bound.addItem("Sentence"); - bound.addItem("Line Break"); - bound.addItem("Word"); - bound.addItem("Char"); - bound.addItemListener(this); - if (choiceFont != null) - bound.setFont(choiceFont); - - choicePanel.add(bound); - topPanel.add(choicePanel); - - DemoUtility.fixGrid(topPanel,1); - - - add("North", topPanel); - - - int ROWS = 15; - int COLUMNS = 50; -// text = new TextArea(getInitialText(), ROWS, COLUMNS); -text = new JTextArea(getInitialText(), ROWS, COLUMNS); -text.setLineWrap(true); -text.setWrapStyleWord(true); - text.setEditable(true); - text.selectAll(); - text.setFont(DemoUtility.editFont); - text.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); - - add("Center", new JScrollPane(text, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, - JScrollPane.HORIZONTAL_SCROLLBAR_NEVER)); - - Panel copyrightPanel = new Panel(); - addWithFont (copyrightPanel, - new Label(DemoUtility.copyright1, Label.LEFT),DemoUtility.creditFont); - DemoUtility.fixGrid(copyrightPanel,1); - add("South", copyrightPanel); - - //layout(); - handleEnumChanged(); - - enableEvents(WindowEvent.WINDOW_CLOSING); - enableEvents(KeyEvent.KEY_PRESSED); - enableEvents(KeyEvent.KEY_RELEASED); - - text.addKeyListener(new KeyAdapter() { - public void keyPressed(KeyEvent e) { - if (e.isControlDown()) { - int kc = e.getKeyCode(); - switch (kc) { - case KeyEvent.VK_N: - case KeyEvent.VK_RIGHT: - handleForward(); - break; - case KeyEvent.VK_P: - case KeyEvent.VK_LEFT: - handleBackward(); - break; - default: - break; - } - e.consume(); - } - } - public void keyReleased(KeyEvent e) { - if (e.isControlDown()) { - e.consume(); - } - } - public void keyTyped(KeyEvent e) { - if (e.isControlDown()) { - e.consume(); - } - } - }); - - // (new Thread(this)).start(); - } - - - - public String getInitialText() - { - return - /* - "\"This is a sentence.\" This is not.\" \"because. And go. " + - "This is a simple 012.566,5 sample sentence. \n"+ - "It does not have to make any sense as you can see. \n"+ - "Nel mezzo del cammin di nostra vita, mi ritrovai in "+ - "una selva oscura. \n"+ - "Che la dritta via aveo smarrita. \n"+ - "He said, that I said, that you said!! \n"+ - "Don't rock the boat.\n\n"+ - "Because I am the daddy, that is why. \n"+ - "Not on my time (el timo.)! \n"+ - "Tab\tTab\rTab\tWow."+ - "So what!!\n\n"+ - "Is this a question??? " + - "I wonder...Hmm.\n" + - "Harris thumbed down several, including \"Away We Go\" "+ - "(which became the huge success Oklahoma!). \n"+ - "One species, B. anthracis, is highly virulent.\n"+ - "Wolf said about Sounder: \"Beautifully thought-out and "+ - "directed.\"\n"+ - "Have you ever said, \"This is where I shall live\"? \n"+ - "He 1000,233,456.000 answered, \"You may not!\" \n"+ - "Another popular saying is: \"How do you do?\". \n"+ - "What is the proper use of the abbreviation pp.? \n"+ - "Yes, I am 1,23.322% definatelly 12\" tall!!"; - */ - "(\"This is a complete sentence.\") This is (\"not.\") also. " - +"An abbreviation in the middle, etc. and one at the end, etc. "+ - "This " - +"is a simple sample 012.566,5 sentence. It doesn't " - +"have to make any sense, as you can see. Nel mezzo del c" - +"ammin di nostra vita, mi ritrovai in una selva oscura. Che " - +"la dritta via aveo smarrita. Not on my time (el timo.)! And " - +"tabulated columns: \tCol1\tCol2\t3,456%.\t " - +"Is this a question??? I wonder... Hmm. Harris thumbed " - +"down several, including \"Away We Go\" (which became the " - +"huge success Oklahoma!). One species, B. anthracis, is " - +"highly virulent. Wolf said about Sounder: \"Beautifully " - +"thought-out and directed.\" Have you ever said, \"This is "+ - "where I " - +"shall live\"? He said 1000,233,456.000 and answered, \"You "+ - "may not!\" " - +"Another popular saying is: \"How do you do?\". What is the " - +"proper use of the abbreviation pp.? Yes, I am 12\' 3\" tall!!"; - } - - - public void handleEnumChanged() - { - String s = bound.getSelectedItem(); - if (s.equals("Char")) { - errorText("getCharacterInstance"); - iter = BreakIterator.getCharacterInstance(); - } - else if (s.equals("Word")) { - errorText("tWordBreak"); - iter = BreakIterator.getWordInstance(); - } - else if (s.equals("Line Break")) { - errorText("getLineInstance"); - iter = BreakIterator.getLineInstance(); - } - else /* if (s.equals("Sentence")) */ { - errorText("getSentenceInstance"); - iter = BreakIterator.getSentenceInstance(); - } - iter.setText(text.getText()); - selectRange(0, 0); - //text.select(0,0); - } - - public void handleForward() - { - try { -// System.out.println("entering handleForward"); - iter.setText(text.getText()); - int oldStart = getSelectionStart(); - int oldEnd = getSelectionEnd(); - -// System.out.println("handleForward: oldStart=" + oldStart + ", oldEnd=" + oldEnd); - - if (oldEnd < 1) { - selectRange(0, iter.following(0)); - } - else { - int s = iter.following(oldEnd-1); - int e = iter.next(); - if (e == -1) { - e = s; - } - selectRange(s, e); - } - //text.select(s, e); - errorText("<" + oldStart + "," + oldEnd + "> -> <" + - start + "," + end + ">"); - } - catch (Exception exp) { - errorText(exp.toString()); - } - } - - public void handleBackward() - { - try { - iter.setText(text.getText()); - int oldStart = getSelectionStart(); - int oldEnd = getSelectionEnd(); - if (oldStart < 1) { - selectRange(0, 0); - } - else { - int e = iter.following(oldStart-1); - int s = iter.previous(); - selectRange(s, e); - } - //text.select(s, e); - errorText("<" + oldStart + "," + oldEnd + "> -> <" + start + "," + end + ">"); - } - catch (Exception exp) { - errorText(exp.toString()); - } - } - - public void itemStateChanged(ItemEvent evt) - { - if (evt.getSource() instanceof Choice) { - handleEnumChanged(); - } - } - - public void errorText(String s) - { - if (DEBUG) - System.out.println(s); - } - - protected void processWindowEvent(WindowEvent evt) - { - if (evt.getID() == WindowEvent.WINDOW_CLOSING && - evt.getWindow() == this) { - hide(); - dispose(); - if (applet != null) { - applet.demoClosed(); - } else System.exit(0); - } - } - - protected void processKeyEvent(KeyEvent evt) - { - switch (evt.getID()) { - case KeyEvent.KEY_PRESSED : - if (evt.getKeyCode() == KeyEvent.VK_CONTROL) { - isctrldown_ = true; - } - break; - case KeyEvent.KEY_RELEASED : - // key detection for left and right buttons are removed - // to emulate the old release behaviour - int key = evt.getKeyCode(); - if (key == KeyEvent.VK_N && isctrldown_) { - handleForward(); - } - else - if (key == KeyEvent.VK_P && isctrldown_) { - handleBackward(); - } - else - if (key == KeyEvent.VK_CONTROL) { - isctrldown_ = false; - } - break; - } - } -} diff --git a/icu4j/src/com/ibm/icu/dev/demo/rbbi/package.html b/icu4j/src/com/ibm/icu/dev/demo/rbbi/package.html deleted file mode 100755 index 13f0c2caec3..00000000000 --- a/icu4j/src/com/ibm/icu/dev/demo/rbbi/package.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - -RuleBasedBreakIterator and DictionaryBasedBreakIterator demo applications. - - \ No newline at end of file