pax_global_header00006660000000000000000000000064116630172060014514gustar00rootroot0000000000000052 comment=0fd8131852e91f7fe4cd53def0e9d8659b8cfe43 eclipse-gef-3.7.1/000077500000000000000000000000001166301720600137075ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.draw2d-feature/000077500000000000000000000000001166301720600207345ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.draw2d-feature/.project000066400000000000000000000005751166301720600224120ustar00rootroot00000000000000 org.eclipse.draw2d.feature org.eclipse.pde.FeatureBuilder org.eclipse.pde.FeatureNature eclipse-gef-3.7.1/org.eclipse.draw2d-feature/build.properties000066400000000000000000000015471166301720600241600ustar00rootroot00000000000000############################################################################### # Copyright (c) 2007, 2009 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # # Contributors: # IBM Corporation - initial API and implementation ############################################################################### bin.includes = epl-v10.html,\ feature.xml,\ feature.properties,\ eclipse_update_120.jpg,\ license.html root=rootfiles src.includes = eclipse_update_120.jpg,\ epl-v10.html,\ feature.properties,\ feature.xml,\ license.html eclipse-gef-3.7.1/org.eclipse.draw2d-feature/eclipse_update_120.jpg000066400000000000000000000522771166301720600250230ustar00rootroot00000000000000JFIFHHExifMM*bj(1r2iHHAdobe Photoshop CS Windows2005:06:17 09:55:47xx&(.kHHJFIFHH Adobe_CMAdobed            xx"?   3!1AQa"q2B#$Rb34rC%Scs5&DTdE£t6UeuF'Vfv7GWgw5!1AQaq"2B#R3$brCScs4%&5DTdEU6teuFVfv'7GWgw ?I!")Jh*AZRRʉi *d!I$JRI$I$$I)I!"U6PKtwpWOdؕpCfS%*^; vxmgEml>Klz DFWioZMԒqv 5'.'I4򠅖6yU?I| 2(e>s<;B]NI潡2:rI$S8m>#&fXC Lqi@#vJ:+P%q>[hk?IŽqoMWZ\Q7"ʡuQS6㪵}*R AIJK) qOw௬PF(K^HuJI)LJ_-ExKF)&ۺ^"ւ8gou@g>i?><#ɾE*12˿yڕ2R.P%Klz DFWioZMԒqv 5'.'I4򠅖6yU?I| 2(e>s<;B]NI潡2:rI$S8m>#&fXC Lqi@#vJ:+P%q>[hk?IŽqoMWZ\Q7"ʡuQS6㪵}*R AIJK) qOw௬PF(K^HuJI)LJ_-ExKF)&ۺ^"ւ8gou@g>i?><#ɾE*12˿yڕ2R.P% 1 120 120 1 72/1 72/1 2 2005-06-17T09:55:47-05:00 2005-06-17T09:55:47-05:00 2005-06-17T09:55:47-05:00 Adobe Photoshop CS Windows adobe:docid:photoshop:5dd9930e-df37-11d9-b295-daca1d068cfc image/jpeg XICC_PROFILE HLinomntrRGB XYZ  1acspMSFTIEC sRGB-HP cprtP3desclwtptbkptrXYZgXYZ,bXYZ@dmndTpdmddvuedLview$lumimeas $tech0 rTRC< gTRC< bTRC< textCopyright (c) 1998 Hewlett-Packard CompanydescsRGB IEC61966-2.1sRGB IEC61966-2.1XYZ QXYZ XYZ o8XYZ bXYZ $descIEC http://www.iec.chIEC http://www.iec.chdesc.IEC 61966-2.1 Default RGB colour space - sRGB.IEC 61966-2.1 Default RGB colour space - sRGBdesc,Reference Viewing Condition in IEC61966-2.1,Reference Viewing Condition in IEC61966-2.1view_. \XYZ L VPWmeassig CRT curv #(-27;@EJOTY^chmrw| %+28>ELRY`gnu| &/8AKT]gqz !-8COZfr~ -;HUcq~ +:IXgw'7HYj{+=Oat 2FZn  % : O d y  ' = T j " 9 Q i  * C \ u & @ Z t .Id %A^z &Ca~1Om&Ed#Cc'Ij4Vx&IlAe@e Ek*Qw;c*R{Gp@j>i  A l !!H!u!!!"'"U"""# #8#f###$$M$|$$% %8%h%%%&'&W&&&''I'z''( (?(q(())8)k))**5*h**++6+i++,,9,n,,- -A-v--..L.../$/Z///050l0011J1112*2c223 3F3334+4e4455M555676r667$7`7788P8899B999:6:t::;-;k;;<' >`>>?!?a??@#@d@@A)AjAAB0BrBBC:C}CDDGDDEEUEEF"FgFFG5G{GHHKHHIIcIIJ7J}JK KSKKL*LrLMMJMMN%NnNOOIOOP'PqPQQPQQR1R|RSS_SSTBTTU(UuUVV\VVWDWWX/X}XYYiYZZVZZ[E[[\5\\]']x]^^l^__a_``W``aOaabIbbcCccd@dde=eef=ffg=ggh?hhiCiijHjjkOkklWlmm`mnnknooxop+ppq:qqrKrss]sttptu(uuv>vvwVwxxnxy*yyzFz{{c{|!||}A}~~b~#G k͂0WGrׇ;iΉ3dʋ0cʍ1fΏ6n֑?zM _ɖ4 uL$h՛BdҞ@iءG&vVǥ8nRĩ7u\ЭD-u`ֲK³8%yhYѹJº;.! zpg_XQKFAǿ=ȼ:ɹ8ʷ6˶5̵5͵6ζ7ϸ9к<Ѿ?DINU\dlvۀ܊ݖޢ)߯6DScs 2F[p(@Xr4Pm8Ww)KmAdobed@xx     u!"1A2# QBa$3Rqb%C&4r 5'S6DTsEF7Gc(UVWdte)8fu*9:HIJXYZghijvwxyzm!1"AQ2aqB#Rb3 $Cr4%ScD&5T6Ed' sFtUeuV7)(GWf8vgwHXhx9IYiy*:JZjz ?aɰ?A{ߺ\ ?݂1*h=onS>T.T.U׺u{{^׺u{{^Щ$̓ P]Y*ǾP6Uzz /YZVAZ U>})kbG8"F*UksnG!@^H]:QpߏX?.ecqæ|#E5rK{'I$:Lu߿u{{^׺u{{^ѩ_>c54S9WCˋ?*FVnаT ]G"Z9t?4`$%t,ުU_k ު.L=*;W#M{a7'Wҝܵ䊓]V 5MH{\fxMpFaoWgulJ},~UM H! f;8T=E>^?sVnp@I7]UqmIB~tI.Jg4`OdtKwoPWR<W3]?jgtqzS%\ OTrWcſ&KG'(?Imp<^ Q{ID#\@GOcЕtjֹ @,"WzV!]Y.-æTWЋ:ߺ^׽uҩ9.x#q ipeܑã(F0--e,ORGR>}* "8GSc8֨zuy,POu[tr^iX\-LcT!*2S@t.H}}2l?o_oUb#+T Jt 8AG$dϯGW[*6 j7ΩqgfydbڞF.ͽybO7;<#cĜTiE?PO5{OD+M_s(#?m=XX]CS G)7އt>#nyi2.Ot!5JX?EI>2[wC^c7:0bJ~߷|nJ/CMT%U\bH'P*AV +qȓ"UCFQSzuӬ{[)œQ`uM8*=%P֨='xm N")O}C"@?^TQJFú n udtȺO_Judž\icل Iꥦt~yPOG{n%kЖjtHqP?y~gV~ݨvV*9d @T D$ymWKvԀ:I1ts4T qVTVn)9?{Qj::έ $QuInW3_7?텽@\Sg_O?8HIo?Ӑ OX'=)AQLp~!JCOTvbc&?2;z(X莱nlM_H )!g˯^Y~|ǘ7=rA{ԩFPASBYU8څZiݔ^dtomw,D!-&7) x[']R4i%752{y6%Gˡ/bd c$Zr6T^HּBB,HA#H>;܅z1kyny3| 3$j4+ݚ]DRykܛ9؊Y@~9-S}E[xFw9kNJ'ra%r9c o8$噹7>}['y@(V?ɷoi}D ?S??J"ңb[Ey`_ i_5gU@N>9P#\,Κ }gոmtH5-@ p?>?ν-Aթo}1R58oCNG[7UNZ*ҶU_On 0ǯSO6Zw ¹iBct!B'JZN8ApƴJ@DJq?Ýd[[Zjc?DbgpouqZBq8v#+9$CG~?n]6b};sX6{ǤRē7˴ZaI ޑ9bo<~ğv$^OϬ6-{DƤҴC[EFckSӀpbumo }K",iSJWђ (l 8RS֪44.>y;c FtE-D/N۟t=z ֬ ÌU*l\M>cDq=76o׵Ay@=x.o4 ^;XYVcƻ+S%2- $de<tjSPr ҟχEV] ִC"3"TA_{-ܟ '=ά2mo]-k_֔QOu upkt=QӏIݏ?T%gg=Ǧ)%.~}q괯Qi_Ii}XLiLGp/o?>16767W'~<ߟ'lt.F:s?w!PsфKR:S( [kqkҲB|:~`¾?vȿ\9M\z?=]>n?sAשo}8@S`K}l,ea#R.>~D-7z_0k-ȞH>z4/fϝ⥃w1WM;"Y:xj#/oWdĕ%mh-:S}\햗h܃0+Mg>u{YO^|IѰm6C(8q{s~=W)k?7^厢spit?ub28Qcp:UtFXsTFGϬf' 'I7zn~JeQib{Cjd;U0}K4nOљ:tKЩVfA$, zVᎃ3'kf+ ڨ"x{L?~΄v0 ⃡7Ng2fZG>HO)1@'Ldoтҿ>=b65'D]X?gN;gGG3BXڂy>45ţ,/Ϸ!6Bx;6˫&ˏ?˭_;i&m$ԓQV,ѴSE7n~~u/_[:^zoyx_kÏNǩȽw6Vr MՖAU?0z _сt&ѬMՎD4sJmH} xW\PQ3޾A )~Xdr4xɱK U;I  Z#pm@˨Qtra? k'm\,yH#uRqoׂ| *no~-Eiӂ2i^<JܟZˮ/0j$^j5#?'S5{Ztc :GϤc-$NY}/.\=?t^UvM嚧a^(LnE )7N$b(Ao&z?貯X&ndЪ:=ˠ}aIҩaŭǾdק wS`jx,G(K#\ !Bƃ = UvpRJ%sisQ!E $d\bۚV%guЧu)NOXUT}P!pQa h-2 9p,mo ">_}z6dE|ET^j \y!\nE462)|,D&K) gd O: .O5],%|N2ݻ-QXzeM<4c`FR5[ ǰ=nGEw[]Ք%Xzf?dģzpHUM\\N!'#[9p?ޭ;uZ7UgQzKeR噏*I7kצ P3Љ>?nMSo~CY2"Q%.w:D$G ;PUrǷđhmkI'ʜcSM *Qu0AARbTtmQRƱS¡c(<}v±Ơ*`:&zkI iDwөo}1f G$&?$_N[wTAV= FhS<%*7Lvs&:6כKc϶]Ml-cQM#K`)J kpDKS(*o~}:#I=Ei*H 1ֺԩZYH FG Qs Mz "3U'RO^:S2чozUz=El[Pܑ:C-DJM#K<^I\ܟtW.jz6Ѳta)-P)ҧ3?1o?۪h Wj}zY\vAb#Wi7?װDtaN:ǚ1St4پ?_zOul7G>K>.re}Ϸ>g&?SY{BDֹy\ڕON&}7;>"Ӣz>龽{խ8q_Ffb %n c IH" NI,I44JI'ɯL9ꀑé0y5eP?<=O!KR1hyZiZQ[ ty5SJQ>1]ԥ<. #6_?zV'G"駼'ϨrUoŏI.׷><>*VrzS{^׺eclipse-gef-3.7.1/org.eclipse.draw2d-feature/epl-v10.html000066400000000000000000000402301166301720600230050ustar00rootroot00000000000000 Eclipse Public License - Version 1.0

Eclipse Public License - v 1.0

THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.

1. DEFINITIONS

"Contribution" means:

a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
b) in the case of each subsequent Contributor:

i) changes to the Program, and

ii) additions to the Program;

where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.

"Contributor" means any person or entity that distributes the Program.

"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.

"Program" means the Contributions distributed in accordance with this Agreement.

"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.

2. GRANT OF RIGHTS

a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.

b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.

c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.

d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.

3. REQUIREMENTS

A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:

a) it complies with the terms and conditions of this Agreement; and

b) its license agreement:

i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;

ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;

iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and

iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.

When the Program is made available in source code form:

a) it must be made available under this Agreement; and

b) a copy of this Agreement must be included with each copy of the Program.

Contributors may not remove or alter any copyright notices contained within the Program.

Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.

4. COMMERCIAL DISTRIBUTION

Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.

For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.

5. NO WARRANTY

EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.

6. DISCLAIMER OF LIABILITY

EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

7. GENERAL

If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.

If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.

All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.

Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.

This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.

 

eclipse-gef-3.7.1/org.eclipse.draw2d-feature/feature.properties000066400000000000000000000240511166301720600245070ustar00rootroot00000000000000############################################################################### # Copyright (c) 2003, 2010 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # # Contributors: # IBM Corporation - initial API and implementation ############################################################################### # feature.properties # contains externalized strings for feature.xml # "%foo" in feature.xml corresponds to the key "foo" in this file # java.io.Properties file (ISO 8859-1 with "\" escapes) # This file should be translated. # "featureName" property - name of the feature featureName=Graphical Editing Framework Draw2d # "providerName" property - name of the company that provides the feature providerName=Eclipse Modeling Project # "updateSiteName" property - label for the update site updateSiteName=Graphical Editing Framework (GEF) Update Site # "description" property - description of the feature description=Graphical Editing Framework Draw2d # "licenseURL" property - URL of the "Feature License" # do not translate value - just change to point to a locale-specific HTML page licenseURL=license.html # "copyright" property - text of the "Feature Update Copyright" copyright=\ Copyright (c) 2000, 2009 IBM Corporation and others.\n\ All rights reserved. This program and the accompanying materials\n\ are made available under the terms of the Eclipse Public License v1.0\n\ which accompanies this distribution, and is available at\n\ http://www.eclipse.org/legal/epl-v10.html\n\ \n\ Contributors:\n\ IBM Corporation - initial API and implementation\n ################ end of copyright property #################################### # "license" property - text of the "Feature Update License" # should be plain text version of license agreement pointed to be "licenseURL" license=\ Eclipse Foundation Software User Agreement\n\ February 1, 2011\n\ \n\ Usage Of Content\n\ \n\ THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\ OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\ USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\ AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\ NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\ AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\ AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\ OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\ TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\ OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\ BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\ \n\ Applicable Licenses\n\ \n\ Unless otherwise indicated, all Content made available by the\n\ Eclipse Foundation is provided to you under the terms and conditions of\n\ the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is\n\ provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\ For purposes of the EPL, "Program" will mean the Content.\n\ \n\ Content includes, but is not limited to, source code, object code,\n\ documentation and other files maintained in the Eclipse Foundation source code\n\ repository ("Repository") in software modules ("Modules") and made available\n\ as downloadable archives ("Downloads").\n\ \n\ - Content may be structured and packaged into modules to facilitate delivering,\n\ extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\ plug-in fragments ("Fragments"), and features ("Features").\n\ - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java(TM) ARchive)\n\ in a directory named "plugins".\n\ - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\ Each Feature may be packaged as a sub-directory in a directory named "features".\n\ Within a Feature, files named "feature.xml" may contain a list of the names and version\n\ numbers of the Plug-ins and/or Fragments associated with that Feature.\n\ - Features may also include other Features ("Included Features"). Within a Feature, files\n\ named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\ \n\ The terms and conditions governing Plug-ins and Fragments should be\n\ contained in files named "about.html" ("Abouts"). The terms and\n\ conditions governing Features and Included Features should be contained\n\ in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\ Licenses may be located in any directory of a Download or Module\n\ including, but not limited to the following locations:\n\ \n\ - The top-level (root) directory\n\ - Plug-in and Fragment directories\n\ - Inside Plug-ins and Fragments packaged as JARs\n\ - Sub-directories of the directory named "src" of certain Plug-ins\n\ - Feature directories\n\ \n\ Note: if a Feature made available by the Eclipse Foundation is installed using the\n\ Provisioning Technology (as defined below), you must agree to a license ("Feature \n\ Update License") during the installation process. If the Feature contains\n\ Included Features, the Feature Update License should either provide you\n\ with the terms and conditions governing the Included Features or inform\n\ you where you can locate them. Feature Update Licenses may be found in\n\ the "license" property of files named "feature.properties" found within a Feature.\n\ Such Abouts, Feature Licenses, and Feature Update Licenses contain the\n\ terms and conditions (or references to such terms and conditions) that\n\ govern your use of the associated Content in that directory.\n\ \n\ THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER\n\ TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\ SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\ \n\ - Eclipse Distribution License Version 1.0 (available at http://www.eclipse.org/licenses/edl-v1.0.html)\n\ - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\ - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\ - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\ - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\ - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\ \n\ IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\ TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License\n\ is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\ govern that particular Content.\n\ \n\ \n\Use of Provisioning Technology\n\ \n\ The Eclipse Foundation makes available provisioning software, examples of which include,\n\ but are not limited to, p2 and the Eclipse Update Manager ("Provisioning Technology") for\n\ the purpose of allowing users to install software, documentation, information and/or\n\ other materials (collectively "Installable Software"). This capability is provided with\n\ the intent of allowing such users to install, extend and update Eclipse-based products.\n\ Information about packaging Installable Software is available at\n\ http://eclipse.org/equinox/p2/repository_packaging.html ("Specification").\n\ \n\ You may use Provisioning Technology to allow other parties to install Installable Software.\n\ You shall be responsible for enabling the applicable license agreements relating to the\n\ Installable Software to be presented to, and accepted by, the users of the Provisioning Technology\n\ in accordance with the Specification. By using Provisioning Technology in such a manner and\n\ making it available in accordance with the Specification, you further acknowledge your\n\ agreement to, and the acquisition of all necessary rights to permit the following:\n\ \n\ 1. A series of actions may occur ("Provisioning Process") in which a user may execute\n\ the Provisioning Technology on a machine ("Target Machine") with the intent of installing,\n\ extending or updating the functionality of an Eclipse-based product.\n\ 2. During the Provisioning Process, the Provisioning Technology may cause third party\n\ Installable Software or a portion thereof to be accessed and copied to the Target Machine.\n\ 3. Pursuant to the Specification, you will provide to the user the terms and conditions that\n\ govern the use of the Installable Software ("Installable Software Agreement") and such\n\ Installable Software Agreement shall be accessed from the Target Machine in accordance\n\ with the Specification. Such Installable Software Agreement must inform the user of the\n\ terms and conditions that govern the Installable Software and must solicit acceptance by\n\ the end user in the manner prescribed in such Installable Software Agreement. Upon such\n\ indication of agreement by the user, the provisioning Technology will complete installation\n\ of the Installable Software.\n\ \n\ Cryptography\n\ \n\ Content may contain encryption software. The country in which you are\n\ currently may have restrictions on the import, possession, and use,\n\ and/or re-export to another country, of encryption software. BEFORE\n\ using any encryption software, please check the country's laws,\n\ regulations and policies concerning the import, possession, or use, and\n\ re-export of encryption software, to see if this is permitted.\n\ \n\ Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.\n ########### end of license property ########################################## eclipse-gef-3.7.1/org.eclipse.draw2d-feature/feature.xml000066400000000000000000000022301166301720600231060ustar00rootroot00000000000000 %description %copyright %license eclipse-gef-3.7.1/org.eclipse.draw2d-feature/license.html000066400000000000000000000220161166301720600232450ustar00rootroot00000000000000 Eclipse Foundation Software User Agreement

Eclipse Foundation Software User Agreement

February 1, 2011

Usage Of Content

THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.

Applicable Licenses

Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, "Program" will mean the Content.

Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse Foundation source code repository ("Repository") in software modules ("Modules") and made available as downloadable archives ("Downloads").

  • Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"), plug-in fragments ("Fragments"), and features ("Features").
  • Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java™ ARchive) in a directory named "plugins".
  • A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Each Feature may be packaged as a sub-directory in a directory named "features". Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of the Plug-ins and/or Fragments associated with that Feature.
  • Features may also include other Features ("Included Features"). Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of Included Features.

The terms and conditions governing Plug-ins and Fragments should be contained in files named "about.html" ("Abouts"). The terms and conditions governing Features and Included Features should be contained in files named "license.html" ("Feature Licenses"). Abouts and Feature Licenses may be located in any directory of a Download or Module including, but not limited to the following locations:

  • The top-level (root) directory
  • Plug-in and Fragment directories
  • Inside Plug-ins and Fragments packaged as JARs
  • Sub-directories of the directory named "src" of certain Plug-ins
  • Feature directories

Note: if a Feature made available by the Eclipse Foundation is installed using the Provisioning Technology (as defined below), you must agree to a license ("Feature Update License") during the installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or inform you where you can locate them. Feature Update Licenses may be found in the "license" property of files named "feature.properties" found within a Feature. Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in that directory.

THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):

IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License is provided, please contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.

Use of Provisioning Technology

The Eclipse Foundation makes available provisioning software, examples of which include, but are not limited to, p2 and the Eclipse Update Manager ("Provisioning Technology") for the purpose of allowing users to install software, documentation, information and/or other materials (collectively "Installable Software"). This capability is provided with the intent of allowing such users to install, extend and update Eclipse-based products. Information about packaging Installable Software is available at http://eclipse.org/equinox/p2/repository_packaging.html ("Specification").

You may use Provisioning Technology to allow other parties to install Installable Software. You shall be responsible for enabling the applicable license agreements relating to the Installable Software to be presented to, and accepted by, the users of the Provisioning Technology in accordance with the Specification. By using Provisioning Technology in such a manner and making it available in accordance with the Specification, you further acknowledge your agreement to, and the acquisition of all necessary rights to permit the following:

  1. A series of actions may occur ("Provisioning Process") in which a user may execute the Provisioning Technology on a machine ("Target Machine") with the intent of installing, extending or updating the functionality of an Eclipse-based product.
  2. During the Provisioning Process, the Provisioning Technology may cause third party Installable Software or a portion thereof to be accessed and copied to the Target Machine.
  3. Pursuant to the Specification, you will provide to the user the terms and conditions that govern the use of the Installable Software ("Installable Software Agreement") and such Installable Software Agreement shall be accessed from the Target Machine in accordance with the Specification. Such Installable Software Agreement must inform the user of the terms and conditions that govern the Installable Software and must solicit acceptance by the end user in the manner prescribed in such Installable Software Agreement. Upon such indication of agreement by the user, the provisioning Technology will complete installation of the Installable Software.

Cryptography

Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to see if this is permitted.

Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.

eclipse-gef-3.7.1/org.eclipse.draw2d-feature/rootfiles/000077500000000000000000000000001166301720600227425ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.draw2d-feature/rootfiles/epl-v10.html000066400000000000000000000402301166301720600250130ustar00rootroot00000000000000 Eclipse Public License - Version 1.0

Eclipse Public License - v 1.0

THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.

1. DEFINITIONS

"Contribution" means:

a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
b) in the case of each subsequent Contributor:

i) changes to the Program, and

ii) additions to the Program;

where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.

"Contributor" means any person or entity that distributes the Program.

"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.

"Program" means the Contributions distributed in accordance with this Agreement.

"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.

2. GRANT OF RIGHTS

a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.

b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.

c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.

d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.

3. REQUIREMENTS

A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:

a) it complies with the terms and conditions of this Agreement; and

b) its license agreement:

i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;

ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;

iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and

iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.

When the Program is made available in source code form:

a) it must be made available under this Agreement; and

b) a copy of this Agreement must be included with each copy of the Program.

Contributors may not remove or alter any copyright notices contained within the Program.

Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.

4. COMMERCIAL DISTRIBUTION

Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.

For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.

5. NO WARRANTY

EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.

6. DISCLAIMER OF LIABILITY

EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

7. GENERAL

If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.

If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.

All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.

Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.

This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.

 

eclipse-gef-3.7.1/org.eclipse.draw2d-feature/rootfiles/notice.html000066400000000000000000000135641166301720600251220ustar00rootroot00000000000000 Eclipse.org Software User Agreement

Eclipse Foundation Software User Agreement

January 28, 2005

Usage Of Content

THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.

Applicable Licenses

Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, "Program" will mean the Content.

Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse.org CVS repository ("Repository") in CVS modules ("Modules") and made available as downloadable archives ("Downloads").

Content may be apportioned into plug-ins ("Plug-ins"), plug-in fragments ("Fragments"), and features ("Features"). A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Files named "feature.xml" may contain a list of the names and version numbers of the Plug-ins and/or Fragments associated with a Feature. Plug-ins and Fragments are located in directories named "plugins" and Features are located in directories named "features".

Features may also include other Features ("Included Features"). Files named "feature.xml" may contain a list of the names and version numbers of Included Features.

The terms and conditions governing Plug-ins and Fragments should be contained in files named "about.html" ("Abouts"). The terms and conditions governing Features and Included Features should be contained in files named "license.html" ("Feature Licenses"). Abouts and Feature Licenses may be located in any directory of a Download or Module including, but not limited to the following locations:

  • The top-level (root) directory
  • Plug-in and Fragment directories
  • Subdirectories of the directory named "src" of certain Plug-ins
  • Feature directories

Note: if a Feature made available by the Eclipse Foundation is installed using the Eclipse Update Manager, you must agree to a license ("Feature Update License") during the installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or inform you where you can locate them. Feature Update Licenses may be found in the "license" property of files named "feature.properties". Such Abouts, Feature Licenses and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in that directory.

THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):

IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License or Feature Update License is provided, please contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.

Cryptography

Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to see if this is permitted.

eclipse-gef-3.7.1/org.eclipse.draw2d-feature/sourceTemplateFeature/000077500000000000000000000000001166301720600252445ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.draw2d-feature/sourceTemplateFeature/build.properties000066400000000000000000000015501166301720600304620ustar00rootroot00000000000000############################################################################### # Copyright (c) 2003, 2009 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # # Contributors: # IBM Corporation - initial API and implementation ############################################################################### bin.includes = epl-v10.html,\ feature.xml,\ feature.properties,\ eclipse_update_120.jpg,\ license.html src.includes = epl-v10.html,\ feature.xml,\ feature.properties,\ eclipse_update_120.jpg,\ license.html eclipse-gef-3.7.1/org.eclipse.draw2d-feature/sourceTemplateFeature/eclipse_update_120.jpg000066400000000000000000000522771166301720600313330ustar00rootroot00000000000000JFIFHHExifMM*bj(1r2iHHAdobe Photoshop CS Windows2005:06:17 09:55:47xx&(.kHHJFIFHH Adobe_CMAdobed            xx"?   3!1AQa"q2B#$Rb34rC%Scs5&DTdE£t6UeuF'Vfv7GWgw5!1AQaq"2B#R3$brCScs4%&5DTdEU6teuFVfv'7GWgw ?I!")Jh*AZRRʉi *d!I$JRI$I$$I)I!"U6PKtwpWOdؕpCfS%*^; vxmgEml>Klz DFWioZMԒqv 5'.'I4򠅖6yU?I| 2(e>s<;B]NI潡2:rI$S8m>#&fXC Lqi@#vJ:+P%q>[hk?IŽqoMWZ\Q7"ʡuQS6㪵}*R AIJK) qOw௬PF(K^HuJI)LJ_-ExKF)&ۺ^"ւ8gou@g>i?><#ɾE*12˿yڕ2R.P%Klz DFWioZMԒqv 5'.'I4򠅖6yU?I| 2(e>s<;B]NI潡2:rI$S8m>#&fXC Lqi@#vJ:+P%q>[hk?IŽqoMWZ\Q7"ʡuQS6㪵}*R AIJK) qOw௬PF(K^HuJI)LJ_-ExKF)&ۺ^"ւ8gou@g>i?><#ɾE*12˿yڕ2R.P% 1 120 120 1 72/1 72/1 2 2005-06-17T09:55:47-05:00 2005-06-17T09:55:47-05:00 2005-06-17T09:55:47-05:00 Adobe Photoshop CS Windows adobe:docid:photoshop:5dd9930e-df37-11d9-b295-daca1d068cfc image/jpeg XICC_PROFILE HLinomntrRGB XYZ  1acspMSFTIEC sRGB-HP cprtP3desclwtptbkptrXYZgXYZ,bXYZ@dmndTpdmddvuedLview$lumimeas $tech0 rTRC< gTRC< bTRC< textCopyright (c) 1998 Hewlett-Packard CompanydescsRGB IEC61966-2.1sRGB IEC61966-2.1XYZ QXYZ XYZ o8XYZ bXYZ $descIEC http://www.iec.chIEC http://www.iec.chdesc.IEC 61966-2.1 Default RGB colour space - sRGB.IEC 61966-2.1 Default RGB colour space - sRGBdesc,Reference Viewing Condition in IEC61966-2.1,Reference Viewing Condition in IEC61966-2.1view_. \XYZ L VPWmeassig CRT curv #(-27;@EJOTY^chmrw| %+28>ELRY`gnu| &/8AKT]gqz !-8COZfr~ -;HUcq~ +:IXgw'7HYj{+=Oat 2FZn  % : O d y  ' = T j " 9 Q i  * C \ u & @ Z t .Id %A^z &Ca~1Om&Ed#Cc'Ij4Vx&IlAe@e Ek*Qw;c*R{Gp@j>i  A l !!H!u!!!"'"U"""# #8#f###$$M$|$$% %8%h%%%&'&W&&&''I'z''( (?(q(())8)k))**5*h**++6+i++,,9,n,,- -A-v--..L.../$/Z///050l0011J1112*2c223 3F3334+4e4455M555676r667$7`7788P8899B999:6:t::;-;k;;<' >`>>?!?a??@#@d@@A)AjAAB0BrBBC:C}CDDGDDEEUEEF"FgFFG5G{GHHKHHIIcIIJ7J}JK KSKKL*LrLMMJMMN%NnNOOIOOP'PqPQQPQQR1R|RSS_SSTBTTU(UuUVV\VVWDWWX/X}XYYiYZZVZZ[E[[\5\\]']x]^^l^__a_``W``aOaabIbbcCccd@dde=eef=ffg=ggh?hhiCiijHjjkOkklWlmm`mnnknooxop+ppq:qqrKrss]sttptu(uuv>vvwVwxxnxy*yyzFz{{c{|!||}A}~~b~#G k͂0WGrׇ;iΉ3dʋ0cʍ1fΏ6n֑?zM _ɖ4 uL$h՛BdҞ@iءG&vVǥ8nRĩ7u\ЭD-u`ֲK³8%yhYѹJº;.! zpg_XQKFAǿ=ȼ:ɹ8ʷ6˶5̵5͵6ζ7ϸ9к<Ѿ?DINU\dlvۀ܊ݖޢ)߯6DScs 2F[p(@Xr4Pm8Ww)KmAdobed@xx     u!"1A2# QBa$3Rqb%C&4r 5'S6DTsEF7Gc(UVWdte)8fu*9:HIJXYZghijvwxyzm!1"AQ2aqB#Rb3 $Cr4%ScD&5T6Ed' sFtUeuV7)(GWf8vgwHXhx9IYiy*:JZjz ?aɰ?A{ߺ\ ?݂1*h=onS>T.T.U׺u{{^׺u{{^Щ$̓ P]Y*ǾP6Uzz /YZVAZ U>})kbG8"F*UksnG!@^H]:QpߏX?.ecqæ|#E5rK{'I$:Lu߿u{{^׺u{{^ѩ_>c54S9WCˋ?*FVnаT ]G"Z9t?4`$%t,ުU_k ު.L=*;W#M{a7'Wҝܵ䊓]V 5MH{\fxMpFaoWgulJ},~UM H! f;8T=E>^?sVnp@I7]UqmIB~tI.Jg4`OdtKwoPWR<W3]?jgtqzS%\ OTrWcſ&KG'(?Imp<^ Q{ID#\@GOcЕtjֹ @,"WzV!]Y.-æTWЋ:ߺ^׽uҩ9.x#q ipeܑã(F0--e,ORGR>}* "8GSc8֨zuy,POu[tr^iX\-LcT!*2S@t.H}}2l?o_oUb#+T Jt 8AG$dϯGW[*6 j7ΩqgfydbڞF.ͽybO7;<#cĜTiE?PO5{OD+M_s(#?m=XX]CS G)7އt>#nyi2.Ot!5JX?EI>2[wC^c7:0bJ~߷|nJ/CMT%U\bH'P*AV +qȓ"UCFQSzuӬ{[)œQ`uM8*=%P֨='xm N")O}C"@?^TQJFú n udtȺO_Judž\icل Iꥦt~yPOG{n%kЖjtHqP?y~gV~ݨvV*9d @T D$ymWKvԀ:I1ts4T qVTVn)9?{Qj::έ $QuInW3_7?텽@\Sg_O?8HIo?Ӑ OX'=)AQLp~!JCOTvbc&?2;z(X莱nlM_H )!g˯^Y~|ǘ7=rA{ԩFPASBYU8څZiݔ^dtomw,D!-&7) x[']R4i%752{y6%Gˡ/bd c$Zr6T^HּBB,HA#H>;܅z1kyny3| 3$j4+ݚ]DRykܛ9؊Y@~9-S}E[xFw9kNJ'ra%r9c o8$噹7>}['y@(V?ɷoi}D ?S??J"ңb[Ey`_ i_5gU@N>9P#\,Κ }gոmtH5-@ p?>?ν-Aթo}1R58oCNG[7UNZ*ҶU_On 0ǯSO6Zw ¹iBct!B'JZN8ApƴJ@DJq?Ýd[[Zjc?DbgpouqZBq8v#+9$CG~?n]6b};sX6{ǤRē7˴ZaI ޑ9bo<~ğv$^OϬ6-{DƤҴC[EFckSӀpbumo }K",iSJWђ (l 8RS֪44.>y;c FtE-D/N۟t=z ֬ ÌU*l\M>cDq=76o׵Ay@=x.o4 ^;XYVcƻ+S%2- $de<tjSPr ҟχEV] ִC"3"TA_{-ܟ '=ά2mo]-k_֔QOu upkt=QӏIݏ?T%gg=Ǧ)%.~}q괯Qi_Ii}XLiLGp/o?>16767W'~<ߟ'lt.F:s?w!PsфKR:S( [kqkҲB|:~`¾?vȿ\9M\z?=]>n?sAשo}8@S`K}l,ea#R.>~D-7z_0k-ȞH>z4/fϝ⥃w1WM;"Y:xj#/oWdĕ%mh-:S}\햗h܃0+Mg>u{YO^|IѰm6C(8q{s~=W)k?7^厢spit?ub28Qcp:UtFXsTFGϬf' 'I7zn~JeQib{Cjd;U0}K4nOљ:tKЩVfA$, zVᎃ3'kf+ ڨ"x{L?~΄v0 ⃡7Ng2fZG>HO)1@'Ldoтҿ>=b65'D]X?gN;gGG3BXڂy>45ţ,/Ϸ!6Bx;6˫&ˏ?˭_;i&m$ԓQV,ѴSE7n~~u/_[:^zoyx_kÏNǩȽw6Vr MՖAU?0z _сt&ѬMՎD4sJmH} xW\PQ3޾A )~Xdr4xɱK U;I  Z#pm@˨Qtra? k'm\,yH#uRqoׂ| *no~-Eiӂ2i^<JܟZˮ/0j$^j5#?'S5{Ztc :GϤc-$NY}/.\=?t^UvM嚧a^(LnE )7N$b(Ao&z?貯X&ndЪ:=ˠ}aIҩaŭǾdק wS`jx,G(K#\ !Bƃ = UvpRJ%sisQ!E $d\bۚV%guЧu)NOXUT}P!pQa h-2 9p,mo ">_}z6dE|ET^j \y!\nE462)|,D&K) gd O: .O5],%|N2ݻ-QXzeM<4c`FR5[ ǰ=nGEw[]Ք%Xzf?dģzpHUM\\N!'#[9p?ޭ;uZ7UgQzKeR噏*I7kצ P3Љ>?nMSo~CY2"Q%.w:D$G ;PUrǷđhmkI'ʜcSM *Qu0AARbTtmQRƱS¡c(<}v±Ơ*`:&zkI iDwөo}1f G$&?$_N[wTAV= FhS<%*7Lvs&:6כKc϶]Ml-cQM#K`)J kpDKS(*o~}:#I=Ei*H 1ֺԩZYH FG Qs Mz "3U'RO^:S2чozUz=El[Pܑ:C-DJM#K<^I\ܟtW.jz6Ѳta)-P)ҧ3?1o?۪h Wj}zY\vAb#Wi7?װDtaN:ǚ1St4پ?_zOul7G>K>.re}Ϸ>g&?SY{BDֹy\ڕON&}7;>"Ӣz>龽{խ8q_Ffb %n c IH" NI,I44JI'ɯL9ꀑé0y5eP?<=O!KR1hyZiZQ[ ty5SJQ>1]ԥ<. #6_?zV'G"駼'ϨrUoŏI.׷><>*VrzS{^׺eclipse-gef-3.7.1/org.eclipse.draw2d-feature/sourceTemplateFeature/epl-v10.html000066400000000000000000000402301166301720600273150ustar00rootroot00000000000000 Eclipse Public License - Version 1.0

Eclipse Public License - v 1.0

THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.

1. DEFINITIONS

"Contribution" means:

a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
b) in the case of each subsequent Contributor:

i) changes to the Program, and

ii) additions to the Program;

where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.

"Contributor" means any person or entity that distributes the Program.

"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.

"Program" means the Contributions distributed in accordance with this Agreement.

"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.

2. GRANT OF RIGHTS

a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.

b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.

c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.

d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.

3. REQUIREMENTS

A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:

a) it complies with the terms and conditions of this Agreement; and

b) its license agreement:

i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;

ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;

iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and

iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.

When the Program is made available in source code form:

a) it must be made available under this Agreement; and

b) a copy of this Agreement must be included with each copy of the Program.

Contributors may not remove or alter any copyright notices contained within the Program.

Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.

4. COMMERCIAL DISTRIBUTION

Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.

For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.

5. NO WARRANTY

EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.

6. DISCLAIMER OF LIABILITY

EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

7. GENERAL

If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.

If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.

All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.

Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.

This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.

 

eclipse-gef-3.7.1/org.eclipse.draw2d-feature/sourceTemplateFeature/feature.properties000066400000000000000000000241371166301720600310240ustar00rootroot00000000000000############################################################################### # Copyright (c) 2007, 2010 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # # Contributors: # IBM Corporation - initial API and implementation ############################################################################### # feature.properties # contains externalized strings for feature.xml # "%foo" in feature.xml corresponds to the key "foo" in this file # java.io.Properties file (ISO 8859-1 with "\" escapes) # This file should be translated. # "featureName" property - name of the feature featureName=Graphical Editing Framework Draw2d Source Feature # "providerName" property - name of the company that provides the feature providerName=Eclipse Modeling Project # "updateSiteName" property - label for the update site updateSiteName=Graphical Editing Framework (GEF) Update Site # "description" property - description of the feature description=API documentation and source code for Graphical Editing Framework Draw2d. # "licenseURL" property - URL of the "Feature License" # do not translate value - just change to point to a locale-specific HTML page licenseURL=license.html # "copyright" property - text of the "Feature Update Copyright" copyright=\ Copyright (c) 2000, 2009 IBM Corporation and others.\n\ All rights reserved. This program and the accompanying materials\n\ are made available under the terms of the Eclipse Public License v1.0\n\ which accompanies this distribution, and is available at\n\ http://www.eclipse.org/legal/epl-v10.html\n\ \n\ Contributors:\n\ IBM Corporation - initial API and implementation\n ################ end of copyright property #################################### # "license" property - text of the "Feature Update License" # should be plain text version of license agreement pointed to be "licenseURL" license=\ Eclipse Foundation Software User Agreement\n\ February 1, 2011\n\ \n\ Usage Of Content\n\ \n\ THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\ OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\ USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\ AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\ NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\ AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\ AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\ OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\ TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\ OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\ BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\ \n\ Applicable Licenses\n\ \n\ Unless otherwise indicated, all Content made available by the\n\ Eclipse Foundation is provided to you under the terms and conditions of\n\ the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is\n\ provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\ For purposes of the EPL, "Program" will mean the Content.\n\ \n\ Content includes, but is not limited to, source code, object code,\n\ documentation and other files maintained in the Eclipse Foundation source code\n\ repository ("Repository") in software modules ("Modules") and made available\n\ as downloadable archives ("Downloads").\n\ \n\ - Content may be structured and packaged into modules to facilitate delivering,\n\ extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\ plug-in fragments ("Fragments"), and features ("Features").\n\ - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java(TM) ARchive)\n\ in a directory named "plugins".\n\ - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\ Each Feature may be packaged as a sub-directory in a directory named "features".\n\ Within a Feature, files named "feature.xml" may contain a list of the names and version\n\ numbers of the Plug-ins and/or Fragments associated with that Feature.\n\ - Features may also include other Features ("Included Features"). Within a Feature, files\n\ named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\ \n\ The terms and conditions governing Plug-ins and Fragments should be\n\ contained in files named "about.html" ("Abouts"). The terms and\n\ conditions governing Features and Included Features should be contained\n\ in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\ Licenses may be located in any directory of a Download or Module\n\ including, but not limited to the following locations:\n\ \n\ - The top-level (root) directory\n\ - Plug-in and Fragment directories\n\ - Inside Plug-ins and Fragments packaged as JARs\n\ - Sub-directories of the directory named "src" of certain Plug-ins\n\ - Feature directories\n\ \n\ Note: if a Feature made available by the Eclipse Foundation is installed using the\n\ Provisioning Technology (as defined below), you must agree to a license ("Feature \n\ Update License") during the installation process. If the Feature contains\n\ Included Features, the Feature Update License should either provide you\n\ with the terms and conditions governing the Included Features or inform\n\ you where you can locate them. Feature Update Licenses may be found in\n\ the "license" property of files named "feature.properties" found within a Feature.\n\ Such Abouts, Feature Licenses, and Feature Update Licenses contain the\n\ terms and conditions (or references to such terms and conditions) that\n\ govern your use of the associated Content in that directory.\n\ \n\ THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER\n\ TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\ SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\ \n\ - Eclipse Distribution License Version 1.0 (available at http://www.eclipse.org/licenses/edl-v1.0.html)\n\ - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\ - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\ - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\ - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\ - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\ \n\ IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\ TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License\n\ is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\ govern that particular Content.\n\ \n\ \n\Use of Provisioning Technology\n\ \n\ The Eclipse Foundation makes available provisioning software, examples of which include,\n\ but are not limited to, p2 and the Eclipse Update Manager ("Provisioning Technology") for\n\ the purpose of allowing users to install software, documentation, information and/or\n\ other materials (collectively "Installable Software"). This capability is provided with\n\ the intent of allowing such users to install, extend and update Eclipse-based products.\n\ Information about packaging Installable Software is available at\n\ http://eclipse.org/equinox/p2/repository_packaging.html ("Specification").\n\ \n\ You may use Provisioning Technology to allow other parties to install Installable Software.\n\ You shall be responsible for enabling the applicable license agreements relating to the\n\ Installable Software to be presented to, and accepted by, the users of the Provisioning Technology\n\ in accordance with the Specification. By using Provisioning Technology in such a manner and\n\ making it available in accordance with the Specification, you further acknowledge your\n\ agreement to, and the acquisition of all necessary rights to permit the following:\n\ \n\ 1. A series of actions may occur ("Provisioning Process") in which a user may execute\n\ the Provisioning Technology on a machine ("Target Machine") with the intent of installing,\n\ extending or updating the functionality of an Eclipse-based product.\n\ 2. During the Provisioning Process, the Provisioning Technology may cause third party\n\ Installable Software or a portion thereof to be accessed and copied to the Target Machine.\n\ 3. Pursuant to the Specification, you will provide to the user the terms and conditions that\n\ govern the use of the Installable Software ("Installable Software Agreement") and such\n\ Installable Software Agreement shall be accessed from the Target Machine in accordance\n\ with the Specification. Such Installable Software Agreement must inform the user of the\n\ terms and conditions that govern the Installable Software and must solicit acceptance by\n\ the end user in the manner prescribed in such Installable Software Agreement. Upon such\n\ indication of agreement by the user, the provisioning Technology will complete installation\n\ of the Installable Software.\n\ \n\ Cryptography\n\ \n\ Content may contain encryption software. The country in which you are\n\ currently may have restrictions on the import, possession, and use,\n\ and/or re-export to another country, of encryption software. BEFORE\n\ using any encryption software, please check the country's laws,\n\ regulations and policies concerning the import, possession, or use, and\n\ re-export of encryption software, to see if this is permitted.\n\ \n\ Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.\n ########### end of license property ########################################## eclipse-gef-3.7.1/org.eclipse.draw2d-feature/sourceTemplateFeature/license.html000066400000000000000000000220161166301720600275550ustar00rootroot00000000000000 Eclipse Foundation Software User Agreement

Eclipse Foundation Software User Agreement

February 1, 2011

Usage Of Content

THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.

Applicable Licenses

Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, "Program" will mean the Content.

Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse Foundation source code repository ("Repository") in software modules ("Modules") and made available as downloadable archives ("Downloads").

  • Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"), plug-in fragments ("Fragments"), and features ("Features").
  • Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java™ ARchive) in a directory named "plugins".
  • A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Each Feature may be packaged as a sub-directory in a directory named "features". Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of the Plug-ins and/or Fragments associated with that Feature.
  • Features may also include other Features ("Included Features"). Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of Included Features.

The terms and conditions governing Plug-ins and Fragments should be contained in files named "about.html" ("Abouts"). The terms and conditions governing Features and Included Features should be contained in files named "license.html" ("Feature Licenses"). Abouts and Feature Licenses may be located in any directory of a Download or Module including, but not limited to the following locations:

  • The top-level (root) directory
  • Plug-in and Fragment directories
  • Inside Plug-ins and Fragments packaged as JARs
  • Sub-directories of the directory named "src" of certain Plug-ins
  • Feature directories

Note: if a Feature made available by the Eclipse Foundation is installed using the Provisioning Technology (as defined below), you must agree to a license ("Feature Update License") during the installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or inform you where you can locate them. Feature Update Licenses may be found in the "license" property of files named "feature.properties" found within a Feature. Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in that directory.

THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):

IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License is provided, please contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.

Use of Provisioning Technology

The Eclipse Foundation makes available provisioning software, examples of which include, but are not limited to, p2 and the Eclipse Update Manager ("Provisioning Technology") for the purpose of allowing users to install software, documentation, information and/or other materials (collectively "Installable Software"). This capability is provided with the intent of allowing such users to install, extend and update Eclipse-based products. Information about packaging Installable Software is available at http://eclipse.org/equinox/p2/repository_packaging.html ("Specification").

You may use Provisioning Technology to allow other parties to install Installable Software. You shall be responsible for enabling the applicable license agreements relating to the Installable Software to be presented to, and accepted by, the users of the Provisioning Technology in accordance with the Specification. By using Provisioning Technology in such a manner and making it available in accordance with the Specification, you further acknowledge your agreement to, and the acquisition of all necessary rights to permit the following:

  1. A series of actions may occur ("Provisioning Process") in which a user may execute the Provisioning Technology on a machine ("Target Machine") with the intent of installing, extending or updating the functionality of an Eclipse-based product.
  2. During the Provisioning Process, the Provisioning Technology may cause third party Installable Software or a portion thereof to be accessed and copied to the Target Machine.
  3. Pursuant to the Specification, you will provide to the user the terms and conditions that govern the use of the Installable Software ("Installable Software Agreement") and such Installable Software Agreement shall be accessed from the Target Machine in accordance with the Specification. Such Installable Software Agreement must inform the user of the terms and conditions that govern the Installable Software and must solicit acceptance by the end user in the manner prescribed in such Installable Software Agreement. Upon such indication of agreement by the user, the provisioning Technology will complete installation of the Installable Software.

Cryptography

Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to see if this is permitted.

Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.

eclipse-gef-3.7.1/org.eclipse.draw2d-feature/sourceTemplatePlugin/000077500000000000000000000000001166301720600251075ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.draw2d-feature/sourceTemplatePlugin/about.html000066400000000000000000000026321166301720600271120ustar00rootroot00000000000000 About

About This Content

June 5, 2006

License

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available at http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, "Program" will mean the Content.

If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party ("Redistributor") and different terms and conditions may apply to your use of any object code in the Content. Check the Redistributor's license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise indicated below, the terms and conditions of the EPL still apply to any source code in the Content and such source code may be obtained at http://www.eclipse.org.

eclipse-gef-3.7.1/org.eclipse.draw2d-feature/sourceTemplatePlugin/about.ini000066400000000000000000000016401166301720600267230ustar00rootroot00000000000000# about.ini # contains information about a feature # java.io.Properties file (ISO 8859-1 with "\" escapes) # "%key" are externalized strings defined in about.properties # This file does not need to be translated. # Property "aboutText" contains blurb for "About" dialog (translated) aboutText=%blurb # Property "windowImage" contains path to window icon (16x16) # needed for primary features only # Property "featureImage" contains path to feature image (32x32) featureImage=modeling32.png # Property "aboutImage" contains path to product image (500x330 or 115x164) # needed for primary features only # Property "appName" contains name of the application (translated) # needed for primary features only # Property "welcomePage" contains path to welcome page (special XML-based format) # optional # Property "welcomePerspective" contains the id of the perspective in which the # welcome page is to be opened. # optional eclipse-gef-3.7.1/org.eclipse.draw2d-feature/sourceTemplatePlugin/about.mappings000066400000000000000000000002501166301720600277560ustar00rootroot00000000000000# about.mappings # contains fill-ins for about.properties # java.io.Properties file (ISO 8859-1 with "\" escapes) # This file does not need to be translated. 0=@build@eclipse-gef-3.7.1/org.eclipse.draw2d-feature/sourceTemplatePlugin/about.properties000066400000000000000000000017041166301720600303410ustar00rootroot00000000000000############################################################################### # Copyright (c) 2003, 2009 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # # Contributors: # IBM Corporation - initial API and implementation ############################################################################### # about.properties # contains externalized strings for about.ini # java.io.Properties file (ISO 8859-1 with "\" escapes) # fill-ins are supplied by about.mappings # This file should be translated. blurb=Eclipse Graphical Editing Framework Draw2d Source Bundle\n\ \n\ Version: {featureVersion}\n\ Build id: {0}\n\ \n\ (c) Copyright Eclipse Contributors and others 2000, 2009. All rights reserved.\n\ Visit http://www.eclipse.org/gef eclipse-gef-3.7.1/org.eclipse.draw2d-feature/sourceTemplatePlugin/build.properties000066400000000000000000000015071166301720600303270ustar00rootroot00000000000000############################################################################### # Copyright (c) 2003, 2009 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # # Contributors: # IBM Corporation - initial API and implementation ############################################################################### bin.includes = about.html,\ about.ini,\ about.mappings,\ about.properties,\ modeling32.png,\ plugin.xml,\ plugin.properties,\ src/**,\ META-INF/ src.includes = about.html sourcePlugin=true eclipse-gef-3.7.1/org.eclipse.draw2d-feature/sourceTemplatePlugin/modeling32.png000066400000000000000000000045561166301720600275720ustar00rootroot00000000000000PNG  IHDR szzgAMAOX2tEXtSoftwareAdobe ImageReadyqe< IDATxڬW}l{޶MGL'Yܔ9$fKYE "p7ee٬ f(ks6%˶==<FhAԡk$e! ć8b@t3lF=?!+xq\͐&)\y XJP,A8/g54ř4JmUZ-|n`%/HpĤquB# LH0EsB_ex^(yH0 AƬ/Yeќ9P o4bmdٷ?§0,F42,BLa6nX~}O}a@]Y |^ C^$jYfӅNc4*Mt4&ɲ42E(r3*+Z}{[w+r }P# -p45z ] Ma[ʔ'}{ţ+7oߎK,Ob8Nu<$|Q%Pi&:MǛg|o?Z7o ۶;w+ se:Z9OF'y\!C~*G2wdh u6/u(zF>z{1[<󂁚x /WJbmԜ`rݚ&uޒyfffjn%QkAb,dG/D ‘}._)2'/J_>$ ҆8mٲ^?E~ zAhit&{;dm6k$S u_{%m-KWW֬k%=zUXKs6#!"<26Tyx}8/\0}7詇H&쳯ѥKYiuϞ~};  1t#W#p ::Zܾ}G<o|a߾~7soOӮ=J>v~JŲLAWtq~78k]dXOo_]]뵷4+y4OѴ(0P.XPc~n\`4| g\# [h5nk+Лc轡Zª%,\b>474)݅rvF>ᑑhOpx`jHƺ3\R0 U_(Б%6,sGQgFvJrꗽ@\2+4AAxB `F3pM&n#J27Oz+Aj_ ʘWvoIENDB`eclipse-gef-3.7.1/org.eclipse.draw2d-feature/sourceTemplatePlugin/plugin.properties000066400000000000000000000011641166301720600305250ustar00rootroot00000000000000############################################################################### # Copyright (c) 2003, 2009 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # # Contributors: # IBM Corporation - initial API and implementation ############################################################################### pluginName=Graphical Editing Framework Draw2d Source Bundle providerName=Eclipse Modeling Project eclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/000077500000000000000000000000001166301720600206475ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/.classpath000066400000000000000000000004031166301720600226270ustar00rootroot00000000000000 eclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/.cvsignore000066400000000000000000000000541166301720600226460ustar00rootroot00000000000000bin reference doc.bin.log buildDocLocal.xml eclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/.project000066400000000000000000000003331166301720600223150ustar00rootroot00000000000000 org.eclipse.draw2d.doc.isv eclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/META-INF/000077500000000000000000000000001166301720600220075ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/META-INF/MANIFEST.MF000066400000000000000000000004601166301720600234410ustar00rootroot00000000000000Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Plugin.name Bundle-SymbolicName: org.eclipse.draw2d.doc.isv; singleton:=true Bundle-Version: 3.5.0.qualifier Bundle-Vendor: %Plugin.providerName Bundle-Localization: plugin Eclipse-LazyStart: true Bundle-RequiredExecutionEnvironment: J2SE-1.4eclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/about.html000066400000000000000000000024631166301720600226540ustar00rootroot00000000000000 About

About This Content

June 5, 2007

License

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available at http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, "Program" will mean the Content.

If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party ("Redistributor") and different terms and conditions may apply to your use of any object code in the Content. Check the Redistributor's license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise indicated below, the terms and conditions of the EPL still apply to any source code in the Content and such source code may be obtained at http://www.eclipse.org.

eclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/book.css000066400000000000000000000000461166301720600223130ustar00rootroot00000000000000@import "../PRODUCT_PLUGIN/book.css"; eclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/build.properties000066400000000000000000000010401166301720600240570ustar00rootroot00000000000000############################################################################### # Copyright (c) 2002, 2005 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # # Contributors: # IBM Corporation - initial API and implementation ############################################################################### custom = true eclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/build.xml000066400000000000000000000113411166301720600224700ustar00rootroot00000000000000 eclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/buildDoc.xml000066400000000000000000000021121166301720600231120ustar00rootroot00000000000000 eclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/buildDocLocal.xml000066400000000000000000000016321166301720600240730ustar00rootroot00000000000000 eclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/doc.properties000066400000000000000000000010241166301720600235270ustar00rootroot00000000000000############################################################################### # Copyright (c) 2002, 2005 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # # Contributors: # IBM Corporation - initial API and implementation ############################################################################### eclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/draw2dOptions000066400000000000000000000024761166301720600233420ustar00rootroot00000000000000-charset "iso-8859-1" -sourcepath "../org.eclipse.draw2d/src" -d reference/api -classpath @rt@:../org.eclipse.debug.core.jar:../org.eclipse.compare.jar:../org.eclipse.help.jar:../org.eclipse.help.ui.jar:../org.eclipse.core.resources.jar:../org.eclipse.core.runtime.jar:../org.eclipse.swt.win32.win32.x86.jar:../org.eclipse.ui.jar:../org.eclipse.debug.ui.jar:../org.eclipse.search.jar:../org.eclipse.jface.jar:../org.eclipse.jface.text.jar:../org.eclipse.text.jar:../org.eclipse.ui.editors.jar:../org.eclipse.ui.views.jar:../org.eclipse.ui.workbench.jar:../org.eclipse.ui.workbench.texteditor.jar -use -breakiterator -splitIndex -windowtitle "Eclipse Draw2d API Specification" -doctitle "Eclipse Draw2d API Specification" -header "Eclipse Draw2d
3.3" -bottom "Copyright (c) IBM Corp. and others 2000, 2007. All Rights Reserved." -overview ../org.eclipse.draw2d/src/overview.html -link http://java.sun.com/j2se/1.4.2/docs/api/ -linkoffline ../../../org.eclipse.platform.doc.isv/reference/api ../org.eclipse.platform.doc.isv/reference/api -linkoffline ../../../org.eclipse.platform.doc.isv/reference/osgi ../org.eclipse.platform.doc.isv/reference/osgi org.eclipse.draw2d org.eclipse.draw2d.geometry org.eclipse.draw2d.graph org.eclipse.draw2d.internal.graph org.eclipse.draw2d.parts org.eclipse.draw2d.text org.eclipse.draw2d.widgetseclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/draw2dOptions.txt000066400000000000000000000024751166301720600241570ustar00rootroot00000000000000-charset "iso-8859-1" -sourcepath "../org.eclipse.draw2d/src" -d reference/api -classpath @rt@:../org.eclipse.debug.core.jar:../org.eclipse.compare.jar:../org.eclipse.help.jar:../org.eclipse.help.ui.jar:../org.eclipse.core.resources.jar:../org.eclipse.core.runtime.jar:../org.eclipse.swt.win32.win32.x86.jar:../org.eclipse.ui.jar:../org.eclipse.debug.ui.jar:../org.eclipse.search.jar:../org.eclipse.jface.jar:../org.eclipse.jface.text.jar:../org.eclipse.text.jar:../org.eclipse.ui.editors.jar:../org.eclipse.ui.views.jar:../org.eclipse.ui.workbench.jar:../org.eclipse.ui.workbench.texteditor.jar -use -breakiterator -splitIndex -windowtitle "Eclipse Draw2d API Specification" -doctitle "Eclipse Draw2d API Specification" -header "Eclipse Draw2d
3.3" -bottom "Copyright (c) IBM Corp. and others 2000, 2007. All Rights Reserved." -overview ../org.eclipse.draw2d/src/overview.html -link http://java.sun.com/j2se/1.4.2/docs/api -linkoffline ../../../org.eclipse.platform.doc.isv/reference/api ../org.eclipse.platform.doc.isv/reference/api -linkoffline ../../../org.eclipse.platform.doc.isv/reference/osgi ../org.eclipse.platform.doc.isv/reference/osgi org.eclipse.draw2d org.eclipse.draw2d.geometry org.eclipse.draw2d.graph org.eclipse.draw2d.internal.graph org.eclipse.draw2d.parts org.eclipse.draw2d.text org.eclipse.draw2d.widgetseclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/guide/000077500000000000000000000000001166301720600217445ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/guide/connections.html000066400000000000000000000124231166301720600251560ustar00rootroot00000000000000 Connections and Routing

Connections and Routing

Connections figures are used to display a line between two points. The Connection interface extends IFigure. The provided PolylineConnection  implementation can be used in most cases. The source and target endpoints of a connection are each defined using a ConnectionAnchor. These endpoints, along with any other points on the connection, are set by the connection's ConnectionRouter. Usually every connection in a drawing has the same router instance. Connections with common endpoints can share anchor instances as well.

Connection Usage

Connections are created and added just like any other figure. Usually, connections should be displayed above other elements of a drawing using Layers. Unlike normal figures, you must not set the bounds of a connection. Instead, you must provide the source and target anchors and let the connection router calculate the connection's points.  The connection then determines its own bounding box.

A connection has a simple router by default - one that can connect the source and target anchors. But additional routers are available and can be set on the connection. Some routers can handle constraints for the connection such as a list of bendpoints through which the connection passes. Note that when setting a routing constraint on a connection, you must first set the router which will use that constraint.

A convenient way to share the router with all connections and to place connections above the drawing is to use a ConnectionLayer. The layer has a connection router property which it shares with every child that's a connection. You can update this property and easily change every connection's router at once.

Routing and Anchors

A connection always has a router and it must set at least two points on the connection: the source and target endpoints. By default, or when set to null, the connection's routing will be performed by an internal default router. The ends are placed with the help of anchors. An anchor is a fixed or calculated location, usually associated with some figure. For example, the ChopboxAnchor finds the point at which a line going to the reference point intersects a box, such as the bounds of a figure. The reference point is either the anchor at the opposite end, or a bendpoint or some other point nearest to the anchor. Anchors notify the connection when their anchor points has changed.


A ChopboxAnchor calculates the connection endpoint by finding the reference's intersection with a rectangle

The router calculates the endpoints and any other points in the middle of the connection. It then sets the points on the connection by calling setPoints(PointList). The connection's existing point list can be reused to reduce garbage, but the points must be set on the connection anyway so that it knows about any changes made.

Adding Decorations and Children to Connections

Like most figures, PolylineConnection supports the addition of children. The children might be arrowheads or labels that decorate the connection. The placement of each type of decoration can vary, so a DelegatingLayout is used to delegate to each child's constraint object, a Locator. PolygonDecoration can be used to create render a rotatable shape at the end of a connection. The end of a connection can be labeled by adding a Label with a ConnectionEndpointLocator. A connection will extend its bounds beyond what would be required to paint just the polyline.


A connection with 2 child decorations

Connection Layout

Connections extend the process of validation and layout to include routing. Since layout is the process of positioning children, routing must come first. This allows a child's locator to operate on the connection's newly-routed points.

During the validation step, the connection must remember its old bounds and determine its new. It then must damage the appropriate regions on the update manager. The provided implementation does all of these things for you. It also requests revalidation according to certain events specific to connections, such as an anchor moving or the router changing.

eclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/guide/coordinates.html000066400000000000000000000201301166301720600251400ustar00rootroot00000000000000 Coordinate Systems

Coordinate Systems

Draw2d provides a flexible coordinate with simple defaults. Different coordinate systems are required by certain optimizations and features provided by draw2d. A coordinate system is nothing more than an adjustment made to the Draw2d Graphics when painting children (coordinate systems have no affect on the way a figure paints itself). For example, it is possible to translate or zoom a Graphics. Both of these operations affect subsequent paint calls. To match what you see, operations like searching for a figure at a point must respect such coordinate changes.

The default coordinate system is very simple, it is the same for every figure. So it doesn't matter if a figure is parented by another figure, you could compare the bounding boxes directly to each other. When the figures paint, they all paint in the same coordinates, and when hit testing is performed, the location is not modified when searching recursively through the children. This coordinate system is called absolute. If a figure uses absolute coordinates, when it moves, it must also translate its children by the same amount. "Absolute" may not be the best choice of words. "Inherited" is probably more accurate, since children are inheriting the parent's coordinate system, which could be anything.

The opposite of absolute (or inherited) coordinates is relative (also local). In a relative coordinate system, the bounds of children are relative to the client area of their parent. The client area is the parent's bounds unless the parent has insets. When a figure with relative coordinates is moved, the children come along for free, without any changes to their bounds.

Relative vs. Absolute

The default coordinate system is absolute and is often left unchanged. A figure can easily change the coordinate system used for its children by overriding useLocalCoordinates(). The following table shows some possible reasons to choose either.

Task Absolute Coordinates Relative Coordinates
Translate/move a figure The figure and all of its children must be translated, which can be expensive in extreme cases. Only the figure's bounds must be updated. The children move for free.

Hit-test / determine repaint regions

No adjustments are needed to coordinates. Some simple math is used to adjust coordinates and rectangles to/from the coordinate system's origin.
Observe the figure's "location" on the Canvas A FigureListener can be used if the entire parent chain is using absolute coordinates. But this guarantee is rare. A FigureListener and CoordinateListener must be used. You must call translateToAsbolute on the figure being observed to get its canvas coordinates.
Determine the bounds of a parent based on the bounds of the children

Easy - after the children have been position, the parent can then figure out what its bounds should be.

Extremely hard, since updating the parent's bounds will cause the children to "move".

Other Coordinate Systems

Zooming and scrolling are done specially by the viewport and scalable layered pane figures provided with Draw2d. Scrolling a drawing is quite common, and it would be silly if doing this required updating the bounding rectangle of every figure in the drawing. As an optimization, a viewport can be constructed with virtual scrolling, which is implemented by translating the coordinate system's origin.

Zoom is done by scaling the coordinate system about the origin.

Working with Absolute Coordinates

The only types of locations which can be passed around and compared in a meaningful way are absolute. Here, "absolute" means the top-most parent (or root) figure's coordinate system. When Draw2d is used with SWT Canvas, an absolute location is the location on that Canvas. To get the location on the Display (i.e. the monitor), you would then have to use the utilities on SWT's Display to convert from a Control to the Display.

To convert to and from absolute coordinates, utility methods are defined on IFigure. These methods will convert any object implementing the Translatable interface (historical note: zoom was not in the first draw2d release so translation was the only type of converting necessary).

  • IFigure#translateToAbsolute(Translatable) - converts from the receiver's coordinates to absolute coordinates. Note that the receiver's coordinate system is the system in which the receiver is placed, and not the coordinates in which it places its children.
  • IFigure#translateToRelative(Translatable) - converts from absolute coordinates to the receiver's coordinates.

The above methods are implemented recursively by walking up the parent chain and performing the conversion for each parent. It's not easy to extend the behavior of a recursive method, so the actual conversions are factored out into separate methods.  These methods are also public and are called in some situations.

  • IFigure#translateToParent(Translatable) - converts from the coordinate system defined by the receiver.  If the receiver uses absolute/inherited coordinates, no conversion is performed.
  • IFigure#translateFromParent(Translatable) - converts to the coordinate system defined by the receiver.

Example: How to place a Shell on top of a Figure

Given a figure that is displayed on a Canvas, how do we popup a shell such that it is in exactly the same location on the screen?

Solution:

First, take the figure's location and convert it to the canvas. Note that the figure's bounds are returned by reference, so you need to create a copy to avoid modifying the original bounds. Next, create an SWT Rectangle and convert it to the display's coordinates:

public void example1(Shell shell, Figure figure, Canvas canvas) {
    org.eclipse.draw2d.geometry.Rectangle r;
    org.eclipse.swt.graphics.Rectangle swtRect;

    r = figure.getBounds().getCopy();
    figure.translateToAbsolute(r);

    swtRect = new org.eclipse.swt.graphics.Rectangle(r.x, r.y, r.width, r.height);
    shell.setBounds(canvas.getDisplay().map(canvas, null, swtRect));
}

Example: How to Position a Connection using an Anchor

Given a ConnectionAnchor, what is the proper way to set the endpoint of a connection?

Solution:

A connection anchor is a helper object that returns a Point in absolute coordinates. The connection figure can be inside a figure such as a viewport or layer that has its own coordinate system. The following code makes the necessary conversion:

public void example2(Connection connection,
        ConnectionAnchor sourceAnchor, Point reference)
{
    Point anchorpoint = sourceAnchor.getLocation(reference);
    connection.translateToRelative(anchorpoint);

    PointList list = connection.getPoints();
    list.setPoint(anchorpoint, 0);
    connection.setPoints(list);
}
eclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/guide/guide.html000066400000000000000000000025131166301720600237300ustar00rootroot00000000000000 Draw2d Guide

Draw2d Programmer's Guide
org.eclipse.draw2d
 

  • Overview - the big picture
  • Painting - details of the paint process and how nesting affects painting
  • Layout - preferred size, layout, validating figures
  • Hit Testing - finding figures, correcting coordinates, modifying the space occupied by a figure
  • Connections and Routing - connections, anchors, decorations, and routing
  • Coordinate Systems - absolute and relative coordinates, working with absolute coordinates
eclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/guide/hittest.html000066400000000000000000000054541166301720600243260ustar00rootroot00000000000000 Hit Testing

Hit Testing

There are several situations which require finding a figure for a mouse location. For example, determining which tooltip to display when the mouse pauses on top of a figure canvas. Another example is interactive graphical applications, which must interpret dragging one figure on top of another.

There are four methods available on IFigure which perform hit testing, three of which are actually just convenience methods which call the fourth.

Hit testing must be done exactly the same way as painting. Clipping and coordinate changes must be duplicated in both. As an optimizations, branches of the figure composition tree are pruned by calling containsPoint(). If a figure does not contain the location, it returns NULL and does not search its children. By default, all figures are considered to be the rectangular region defined by their bounds, regardless of how or if they paint. This can be overridden as it is in Polyline, Ellipse, and other figures.

eclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/guide/images/000077500000000000000000000000001166301720600232115ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/guide/images/chopbox.gif000066400000000000000000000064001166301720600253420ustar00rootroot00000000000000GIF89a33f3333f333ff3fffff3f3f̙3f3333f3333333333f3333333f3f33ff3f3f3f3333f3333333f3̙333333f333ff3ffffff3f33f3ff3f3f3ffff3fffffffffff3fffffff3fff̙ffff3fffff3f̙3333f33̙3ff3ffff̙f3f̙3f̙̙3f̙3f3333f333ff3fffff̙̙3̙f̙̙̙3f̙3f3f3333f333ff3fffff3f3f̙3f,3H*\ȰÇ#JHŋ3jȱǏ CIɓ(S\ɲ˗0cʜI͛8s$z JTE*]zPJUH #(Rz@֭`VկLtݻ <5k_?%/z=Sx#KVb/+TS㌨k(0⥎Pe!A$@#@ccHҔaOӛdaCF =T9H HR1-'P d fI[`##b*EƓ& b)fL * ()r2p)l\-%  G6I&4\uD s:vDkVo.t7YƲC5gu&Rr:w߃G$TcFτ=cN qZŌz^Z8+-#ԉ25NVLN]⡎qhȡ*(DʖfRԤ#'MލEd>Pz.GmSGԦ$U$@gO XULJ܌G7R!AiA8TѴCI*Ub),I>|ظr5%XWZ$;Jx*z)l[0؏,VAA+LeXj&([%r7rmUc ng6uiۦvt kwߢFcV,\ms;׉s|K]A=hɮr+dܒPsN,)ˑcݣv i`CԨN5B-jUհfgMZָ5G; ^"5K~m%NƵAmHȥ,I(v /6KR+P]L~;,T7ZQ? ^R 1ztg`F\_?#n>ʒ$?Bb‚ ^HRodfdīr>G3.FcWO$wXܪ!6Ak~Cؐ,$fGQ cr(e;!65Vܟէ? Oؙz)˫V{jml wC/nz)})}.]&{DĄo\r~Dsd@^)/R!(7$h]P' )TNO+4iP_~1m1L[s@l=)rMc{эӺ|`Efd7ʼM~XRc u6NCv2j@2~sVGO $@1xA  FQ/Hy.× Tp`c"ϳx@0RWz{1BfCT wOae _Q_m8|hH]LyPuMRUwWQԅAH_bHGSHcMg(H`Gk؅epr8tXe;eclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/guide/images/decorations.gif000066400000000000000000000041651166301720600262200ustar00rootroot00000000000000GIF89a_1$$$<<he-G T,iD@n*hTݪkゥ滐 5 @ !pp,  Uc{K#00,D0@v.+ mKB @B @B1lV4/?X̐ ' = 5*]M+t;3$uHTr$K6to @ mpw%}M7 ͷ vUs4 ,-Vti/y 'B ?eS8;ǵl,n \?@" U.OB7c,;n<jƯik+j)kѢP+! ЊVAҲy-\F>@Tl|Pr" Pj;WB`^@@ GC ¹ ` p"8`;u ?\Sb UĵQsXITƄt FyOL+u(!!w3@X*H&C"DƱ Xd)Ѣր@x]L['eHCK$ )2ޅC3(6e1]Qe1?i5j0w%*pa B,@b,vR&D?`/iDW1Py9='GRO3seW PQ-4PS(E mP4rhG.ЅZksa~0mh]r!DFVpf֯uM`F-CokwMs_ݣI|(nFnq\wN%~r zKԮSbn;ӧ3DzE6W:yN1`';tIߞ @ǝ;> ݬsm|'$5o4c=C܏K3Yûo^j?MR0=QUj`Z%~HE*GTkG>dz{{‚ AX @/{GQ$20nu8T( bć"SfA$.`1;~΄B00H0Nđ0  xiԒƋs@ Q \R A]sjċ1df8>04#I|rs,%,HJ<^p? @ȦUd9K`Ж 'NtHrd$0N",\2iG>Ѥ&y„xL @S B͜M9q1B:QH"$<8">4=&Ŏ1Ӂ !C‡TbnN$#8nQ ,62~n-B-ӗ{0Sh [EWfM[MRU\u% ]hVjvӫkX}*NzFG*igؒNe]"Ήe*bVԉqZs%e#QʮKg?K[míN.ŊJ*eK(!rZ{*cǨ&&J]@qt\$w=Ys 2Z%uc5aiNWdmsޘ(Uu#nImH}ݶ0IX2 {;&! n}{W" zkYG<N҇BPXeN{#R4C4#S[LÙ,ƱDc?βBEDzDq$eQy}=I*:{~|%grG B9`oЎt$?'6?YW_ t:%g[w׋JD%{,N~!y̥k&˝no{u׽Mlr\GOz\ӏui9q/zo;^uCX<-k})mIl0¾ /!fʽD([ >EY<9$n`X>ޙrw[0f GsMNg˶mr~(ex2|vWl8W]!GYi8)u ajGSyIJX a9#@ф=RӏHƍDVw y##T}$AeLIG_DzB; DR+YjD~cf&H EusCwX#CEDzDMD$S=OCed3K Wxh)2DGD=tJGyG$C0B9h5,v%/\)>;CLTGDg=#3X䏈_ vJj9is͔)M[6Y;Jvo6)Ϧi$2əٗ T3tV'J r噓F9!EiDDievȖ薱yfL:TVIA&H5R$L1EZ8:cc4:pc}C+Yhŏ-:9=.oX9iH,HLڥU6 SbeꗥǙn^ڦo dUUJ[E*.fnp9Sv+w\*%ڠcGqR,qV/l&j+HJLC[ӪgB!.I۵7+qHS |V1g 9Yzn }*9(ѳe 5| {~[>:ws;~(/x[{[J*|)~HbAZ{{_dO/[.Z;[: |wbȼ Q‹7hu[IJnѻi)2b5 kI:pѕ8rۯ 軋k׫ګ˷ [u\*Ee~" *,=E1[hy7J[ٸ- % ['œ n%H5l\7=zw@"<$\;t J9Ċ#!T-:=:`M-J՝R`b ][R\(^]cp@V2A\$&;3~;M؂v#׊R|"=ٔٚٙuטMΜڢm͞Hڦe ٪ڢ-=. ۶*<۵S۠ۅc=]Eʽ̍_,܅#}؝ڽ=]}=)6O=Gy;)QEFCKߌ!~Їj8* 3~/a*Y1L+d/j1V*Vyf<nڃS@@ S (R=@ 5>@?X#E9ghb}nAjRH\u&4sgS]`!jbúc~ qJ soL%֣.o-ó}P2dT@$*3?K"+h>2 ?* 'az B- ZȨ-)­r0UL;Ѻ'b?( 0d9 @;0K%1[<(̦\ʬ*銛@SDLhMд3xrtj쬻@K|0<m8PeTDcDZs0\EȥfY]Iթl]UJkJIh6 %dSh;nnʔZڭVŌQtd}" 2?DwHG;奈z49TW$'HFR[F> /uQ*(<8<cbΊWbE.^4]cC1ьgDcq.)#8G:2:ucƐje9H+*AW7xHF ,ld$%Fi%59u $'E qDe*UJVҕe,e9KZҖe.\}{r!ŽZғtPbĒ.dqF2e kW3I%YFzQKxњXU +-l˦ d~dZTvh<2p$qY-8\24*oaslU\،"e|BvH]y+_GflQ}%(^] "-"o l]Ӏ$iy9KDƻՋ0 ŤXM&oa~S6(3,Ȏ`tW1+]2T5d(ԥ={xR 4a|G*K`"<`p"f/qLrǀbꚶ/O۬6xٔWVCSp5fmˠqcn:=Ԡ 5S-̀ԥ>{tdFA^Z48:}KhbLGKE~,\lN &U)9yEi:/q3-(RS[SS!هbZZ3H͙wv^Zb-lBF2̽nN)tusMu+֕[= vzf,D.˟5&`a^x$(2Kͅ,Rq(nZ ^/񫗌Y)kM>su!Jzxx5+ҩx\gf,d^loF3fwih)K(t\]][@xx髳t̻l:+ľKхwlỹp76S>)! ^gwa,Dhlc`j4p)ZE&u^p#x'JOIur uV7i`7=uSE*:ϫX  .ɎH"`c+ ҡ* d"ʪz12(b +u{A A8!{)硫J+@ -`ޫ!Dϐh≺E!H~0(#0A%㏧ٸbGhHZ( 5:Tr&$Qd\ve*`B#Fch9ٕbZp)#,~YPfԣ|Rɦ)砄rX'ṣ}6柈B$(U.Z#tFR:*ꔐzФ_Y(qz(9(jBvYҢrvijޚP\uTX5W~L[_hA_~Rs{쮗1A[Z-@}Zk.wŠ^ W.ɋ$A{U}!# >揂$H4KI&7ɶGY $'IHJ4KJRT,,JR+9-mRr 0R]Z-4&Lzh-&T)SjZ̦6nzؤc*Y钜˜bB<?IOD 8IzsDgThU!iMh8Ϧd-lJIÆG%B7ySKHSBƨ@II͎HPDt$)i+e"P;*Se H)Rcԑt1 B|Ry -jSEmU$OuB~֤"VzO~5(]}Sy1T;e\$YV\R&+`'M',Zk ^U)eGMj6'=F;JS2$GOig[Mm m Y4 liKZv&=.izKƫHz"nqܛ$en{VJV5.vW.׏dv7"9Mkխ24qN~ ]6&L wFOAWG qj]N/VQ_nh ఖƂl鍇[ln1#LKEqUyr_e*O_SJ?U*VհgMZָfuw"g]k1֕{4bJmz*ܩ}IV"ў aqkDԔ\6^Ks%Ӷs술[BܔN Fq߅}vTo!׾Md3XhʄW$M\}?Lbp A~oN-N&9Mndvͭ|,ov#(s"ق);ys+=L6͐Eљ.մ-X^"09E!]\n7]:v :|T#V_F'I ϼ)l {B|:Eh<º=w(H_W!=Wu:εzƫ$j`^OZ(2\ _\w= W϶ί3:A_29*r^)҇ӱ͌>RY6G'zC0G:}CxC|Ew~AtV!w#ė߲zz8#Hx} *G W#)W݂GllioyyGsYQu/@1>rl&H3(R8qQl'mS75(2h\2~t/'txqN7ex!%3b1Zx|](SS/%t7hm1lȃn(ȈG~H{5t췇.H煉S|_@R(xX0;H5n[wvt1Qx p-#Si>bȉ~83y>3|qR+Q~s(Th X vo9b/:[B8 x- h-hKEXHP (|G0/xԃq!wG2.t0Z9o'p'WPؑUE!gEO9pRsWAua%ci2YMȕ ŔD_bofN4k"Dk۩yF{rB"MۦO }*S!UKW[!]k^_ *q2349k 9*ᓴ%C(QRutKvKx8=p r;[<;R!XZxw2X˸:+,€X5`q;Q!q"G8ۏ35WہKjK)qQ3j:8hh+˛7"|!"=9Ⱥ~Ȼҽs3k[ȶo+ !AP㻂C8iW L;2͛*|Y8R%H\AaiӅ{;Ҹj3A9r$,{(@7G~]:z=ړz5D|RQmʖO2*RL\NŮcc;a,lDe_|\imo[q,ǢDug yǰy;w|[̚ȊDe} 2{Œl$(+PBcPbMrleM#]=!}3+;{EYBUJ"HQQ$a+L(/'&JMSMnB6XE}Q+RJvNf|.a23O2ЅRvm$jiQ#2ҕa.LV^|_Vw|"r(nTK&wjGj ھj1EFiJ[=Uz$n(# ]Jme]}T-R-:C٭-@M-Q׳ٛk](׃_tʬ ۟FDП1I} J!22~u&_"kT NmU-:92"]ׇ*U'P2"Weχ2<~ aPl֞au7qʏG~|tSiE0JGD$*UdwNU*ه5a%W޽ទ?=嬄y-|[^5O%!MVfNA]U{w_l=KPQS9")>(n]l&X@N51|d\~Zm7 J%E١EQb~NnO\kKUʃ]e&QR$pW1 3;~;rQ)ϋ""^3#T3׾$)WJ1UZ)]Z^S!폎̷:#ٮa#XyЅK>UG!g K!.IX+>%  C^&wU)W~)==qqDT]E$r5DԞ:hZ-(mQWR(Z->zJ]҉B5W])Ho&>*:LI\T^e}N?43'|T:LuQoW(OET竆gT%Mu uR?JoNuRur{nx'r|;b~l?3]]4A 0@?>@0R9|p@)X!Dq#B "aʁS*qisf&5|ǟIT&͗g(J9Z%CJG6sB4@!g~?6)poF1<Ĭ?*9ȈFEEB}{q˶"I+Ĩ FqyV]kx\i%y˗{oxD:K?qkH83/|秿~*qTJlHDL24Ѐrdc2E,r X D`5HVD,R#+k(LO Ѕ/<`8C0sB˟ uCMk=b8D"шGDbD&6щOb8E*VъWR@;eclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/guide/images/revalidate.gif000066400000000000000000000132411166301720600260210ustar00rootroot00000000000000GIF89aM1$$$$$$$,,4<<<<$<<,<<H-xb)>'"4v"t8: 8X\aX0g$X>s DbB~SRiehZ]dEiDkYY@Cb@t]buީhCy`0<%ҕޕ*(sЀ?)u QMt&J5h,psV-{"A «;xZ;rV-usSz +zaAi'Q0@5/t݂;og󛬿f0g2]HG'ԫ#MC-r\.=b4@^mc#!}UK70=udC7}-X|dx_UCg>3y9#9Q~BN뇹NnzB/mrG(35:GWʧ|jzO#$6I?0n`Aߌk6 qR÷@ ʖ@F-7;@ l y㺠ovMaHFf4 ‹[ n V=Pj`xbkD(r_+8ذ\8 .0#}F/ns a2D@8K|i 6vK 8:"<@,ׇ7·a@}:ŞnB:hPc rR&oPFOMR<~7ijE2Td{cZ`yGCw",0)zrC VִRU V|gmP'unr~J5tHV_S$;zDhF <=,&#C@WTPwF+=>(t=$$|PF6uHȄVrX؄j0iF~31[qZXSBb7Wwr;ג?b4Gs;gXvh}_5{d(X wF?s#(0nR4U8qp!EH=4!H:x~XSOq`$T!PARo3+OaTaE#JAD6Ži:؏6Sx &Y=P)h8i P+A>VW1ْe 16&9!Y-+ _;ɑ4)%RҨNP$O)1&0"IM9Y"S9Sٓ5"=5M7Uay[dYv= d8cAqaJɌYWwyQ~nq LyYASl9siYZ9㙀J_)97|7ItI;;ۺm|1% '`f;Z$ |J** 3ЬifPS C1n'֭k2xwƱ-P*;zjʚi1<3i &:}աbYة}>z%@*3-W#xԱ3r*00i},8tD "kb6@)묯\)P-!͛:*P"}|$QB\ぺС2LrzK7Z}!/qRrn)0??$(?D.\@,p"R1@Z₅32N  CC'VT s Cp 0ǏNqUY"zhϞ<< L;ⴺ.׹1 P?>PJM*7/ NV#e̘č9.'ψa͹#^ Thڳc4 b݊q甪cHsWmw޽#( gөKf9u:.w&(*K,*6X`0-v[*;0=:D>ct2 p-OH<y껩 C0|Ȯɩ*'0lļ"qM6a\ Mn5rK*¥4q'/rTHD15"Nœġ$ͲQGD#SHR9GoVc  E@Uӈ@+ Y$%4wU(qCJ6%h/~@ lw_C˹tdƺ۟X4,W@I%ϭ2% *PϻfJ\gC-.W'}S100&0v08 ʮ@xYWAd^fe%EuB~& 0Xu؛jg]U\ɲI0cd͛^3fM@ٳQ?*]ӧJիR(֯`qiJװh,˖Yp>۶r-D׮_vx ᆃ+TXᅁkb\ӷ+.dDٴm41Aղ @@^ 0@ D^a`_ (``j 2!_w@|q6`hЉo._RރYR 6Ln[A@~ h_A@qAhc:B!$b@@JƸ .J@ 0p S$]7 cK9 d0z"G$qً嗀&_Bĥ؋@1pfF AM›w懯@ܖJ 詇O'-娓 }XbEڋ˨,[p'.*gPgէ_Y&&i_/ fITHk*컔@VKNu_Xcb-& V\%!wvlv1ԁgJD!l ֮*J1sZDis~}&M1fiTyTl81l:,1_::k.**]Y10:=Ԁcv(*L YC Q!V0@@tښ捋$nK|aS$s$8'x$ ` [2V4"a^^Q%P""ݲQ+A`U B'\ bh|Regoٲ NtoW3!aaa6%6UC 9 &Jf'|b,lň kz.by u Q_}h!|R$|bh1 i0xWt"0XXF1%0&Ee)ԡ[ׄBZ@'0HESAQs {b/r@t[K{/(!Ph/|*WcӨ[yX0XD#du}VY7FQ5S#>/EXӑ^GR= =2 (xmPL"9;9c#)+CRFEgЅg>`>䌕#ӱ}^}6ُ e=>vye "㇘Ԕz3&;Z} @S鏘 =ٙvDOdT᠚Ě蚯I:d$(dD)OØiI3ٜpy2ȹPCɳۥ#6pa ȰN%H⪅3j!,Ċɓ@*ɲ%’(cM˛8ɳg.J4NHjʊiѧPM)JSUWjzשYQJeׯh{%[gEVۻnݫn"x˷0C ^\Ӱc EfL&'ҼϠCMӨS^ͺן1Om۳s_򬻷ڷ {qq ?8j*9뺒7.:g[ާwKߞ8c{;_w }>_ X ^ w &C9H!uZvaRn\La<8*΅b1,N2"A5ێ<@)$kM 0@c$(TiXy%'x%& U.U*eNSzbhU9|y0I0"XH x yj§,h$Yfڨ(g2s2` 0k  d:i]J K@:@#xڈ++# 츏k@# 62b૤h*}ڥ ȣ.,w)&¢ڈŸ6k ,P1v Flm#V*&) pq%)(GsX Lf').g~>ͭ]r$ 9m@ԸHCV#Bƍ<5B dKڎlhɧj>'@:,5"eʚmK»rZHwxP3v l޼ eҠaя4PXS̺fo9)k hO|-YP{鱭PUKR @KV֮@kIҟ',umnG VxS6C(ܤVֲ 2@])f̢viz pvp|h)LNm7 ]lK@\u-;54JQL(i5Ao\=Xj ?&-9P jVr}FP(y?A-f$Gu,qsdK*%" Z2@ 4>c Rcd2.\@D/\gl,7ZEM^]1uy/zzz7)*)#I<ك:u.Uh$%Q$=Qρ\Y?ySU3h`I8ԕ@%pLGwÑ%"iIM&r#K[Ҿԣ3% Ek G*:)mf*SjeBEOajW 5<#jSՆ0Վ˪VM3ՠT08y*ڎZ+#V.%j%kS0>r]W({uh_1WlMb[3Xص}S[Z6~f5;Yl,O E3!iWθ@E-d`Kۛ5lustp$!EMn2a+e'oK]eVSgxe'L%3y*Eo-W8%}qWrK`OW ]1fɤƪ9@1a[b{IUƹiJֻڈ9;pT%,<qP;!S` lx"C֒7q&I1 @GxE^8\HW=N|XO ?-ua;,:ؚ"sgG@m׫qe j( @Lƌ) -tU_dG }-P.}OƟpa\ u!hJx_7zP_ uj[nWc:B``,2e cɤT%&E$ygpQ_jEefO5Rx9& &zhHz:hkkv7%]S}.뻃5(a |gUa°.|垭sW& `K1g fFi]bS'= 1ceN}k=SU/v3?/cIڊ1%؁\m>Tq1pZ/ʾg'|`] =%MXg@Cnhs4I((;P`@$u1 vfX١gvÂ`ڗmzqY BDHtBXQ5Ob?I"^XFx&E82mx9Fv=я9Hr?|F Jd$7IT2Fc$!5Ofd(IAҔbCQT9K?-%G\֤ G,3]Τ0#aƤ2ǣeə+w9M4@7pDGinS0 a;NxsG=cO|3:?}Ot3%AcP.* eCUPN4!EbQnGAR%5IQRFSPL3wS>~(DZ5Y*SxHtjUIvhj:UmӜ$8yVpU+4MVj&|+gR,wmF\SNǮ~%_9WRӰsX^6VUNd%KL:6kf YJX8Dk ǴcjZ~V-mdدjwZַmbiX5i8Wn/*hnrH,['b^YA$ӝwAy/|K`w0$Bֿp^bs*$0`Em;8IqN$ť K02즮1xI]aCT41Y襢1i) :Xޗ jUE8TWC_*|jِ/ד")Ӫ`_]e]3|%$Fe (@P"&2XYu5\ژL 5ι:E x"i=}F_X5*eT0N+z\DkUvmZrP1@Vʳf+ +Ƿd>L ָbk`c`猐'eoXoxrC rZ5$<{w&p,\pwK`v ׏ `^Wi@ZKR8`".7^1 9F:[ P99ƼO4y14 |зeݪE@VpWd^q S?.1J`'i(8jg JyG&1` f+^fހ {0Ϗ`%@̷PGatpp=aozr^LaE\I>׋o|iOTPǽvw]l>]g?'8HXhx)9IYiY Yx *ʘiz +;9zYj KK\l|,: ]m(ͬ|->J=\>>zNjP>}-;5H:|]…IŚXbÈ;z,1B$Hʕ,K|(!0l3gG5 ׳ODAHV[j4mZ5֭\z 6Űd˚=Ե;eclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/guide/images/validate.gif000066400000000000000000000125751166301720600255030ustar00rootroot00000000000000GIF89a1$$$$$$$,,44$4<mPh& ^Dw)ipgg VEt ($(bG%n`eP@J𙋲P Ah<#$bx-D8zFcldtTBoK%iM> %GUi&W8dDpP@ BJ"@ Ԓ$@w B.$pp*(YRiiiuI 3L)-#R0Aك"̠AA^3mX)krt>dj*j$Ha¸}B&.jCu*-RצjJ&.N.;B+q~郌oG^@a1i<`'JDpE<{xqi.N BJdK2a&+Bh-IxX_ppu9S^whAgz'ڝ zjI;zۧz 0i>v"hC#Õ00==gy 0HtY,Z0"X ܳ%1B"uH ^`EaDXA!PJHD"Ng"HCatȽ2X$ CHD،ǸЅjH"*ЊW"E.#(Dn!Y$GJucW("=u;X8@Ni)a!sDzr% #[D4" }IhrcŠ'g)Zg=I$!aia*?B51@G()"KSD"&wyY` ("`|e* &b#uӛQߦX8-lZWfAL grO|J (Tt:UbJzR\^#cprź Bz4 ӹ~ ldO`r!|fӛ4FQ)H](EFb,6XՙT"JYu qjV-խ^'^*3Vլ]hP ʶ>pP~պx+ֵ節fTT`X4貘lb${ʾ4d,R=Y6m(hC{ZaVLi _{V=-2ֶtKKWq;\ICS@RWͮvBȣ)$n+UW%/j_z^;׻/z _o}^*d8YZw>&؋^l/wy3@ lE*/B`YMw2=Û f9=cx⒈ F9r-N]G@ @@^Q!  92`V\PϵX!B(r,Lzy\A0 A3|6 %bL2uC0@8hY+~1gQqP% ISsHbLN/4 @i-.^V&6w]%!00~l~ތ*=,P hgԆm"lOGt @>7Tu;HNQ)/]C5AJMf @ _oxܝF@rOQUNVk*~M-9Ϗш{7~t{=]gcXn|XurX| 'wpM91 )e)-f^&ĩ; Sj. ^FV37. _HJthR9$N%/Q J#9@4C&"j:jIƿB㊹v 1+4=OĨ:ߗJ`H$L'Y8yiiB+rFҊ}<=rQ;}(dSۨȋr4E387)ԳŦB,9"2Ȥԃ ʓTI8پtL=ziAp!dſ+#lF3Jx72~A䘃 }+Ĭ,FLy|Ň͉,KȻfɺDEȸ=BЌ |}8L3Ϗܿ#ɼ\- =A:ܓ!!xIL"\Lm=]ޓ"$ǬƖ8T @T$-MPFT -&3\SC,@Mm7=L}`($W9|#!;Lib-=!!o!H,,Ţ!D"|ݓoA'P)2R{9imr'Eiϣf2 -1|3S䘴-Pe"R-FMۊ+1\-FxmM}I\.l-]&M׎ZY۔ΩܭO;_+ޝ[Sޥ t+IݷխkK mcem}Wnzu;eclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/guide/layout.html000066400000000000000000000135661166301720600241620ustar00rootroot00000000000000 Layout

Layout

Layout is the process of determining the locations of figures in a drawing. This two step process includes marking figures as invalid (needing layout), and then validating the "branches" of figures that are invalid. Multiple updates to a drawing can result in multiple figures becoming invalid. To prevent intermediate states from being displayed to the user, Draw2d provides a deferred update strategy which integrates layout with native paint requests as well as figures requesting repaints.  The result is that layouts occur all at once, after which the results are painted.

Figure delegates the task of placing children to their LayoutManager. This allows layouts to be swapped and is also just good separation of concerns. Layouts cannot be shared because they may cache information about their owner.

Validation

Validation is almost synonymous with layout. A figure that needs to layout is marked as invalid. All figures start in the invalid state when constructed.  At some point later when validate() is called, they mark themselves as valid and perform their layout. After layout, the figure will then validate its children. Draw2d only uses validate to perform layouts, but in theory it could be extended to perform any sort of potentially expensive calculation that needs to be integrated with the update manager.

Preferred Size

Most layouts need to query the children for their size constraints. IFigure provides methods for querying the minimum, preferred, and maximum sizes. A figure such as Label will have a preferred size based on its text or icon being displayed. If a figure contains other figures, then its preferred size will be based on how it would like to arrange its children. In this case, the size requests are forwarded to the layout manager.

Hints can be used when querying preferred and minimum size. For example, if the amount of available width is known, this width can be passed to a figure which may be wrapping a paragraph of text. The figure would then return the height and width necessary to wrap the paragraph to the given amount of space.

Changes that cause Layouts

When a figure is changed in a way that affects its preferred size or layout, it calls revalidate(). Revalidation is the process of marking yourself as invalid and requesting revalidate on your parent figure. This process continues up the parent chain until the root figure (or some validation root) adds itself to the update managers list of invalid figures. At a later time, the update manager will go through its collection of invalid figures and call validate() on them. In some situations, invalid figures may be added or re-added during validation. This is fine as long as the dependencies do not result in a never-ending cycle. The following image shows the chain of events:

A changes happens to Fig 4 that affects its preferred size. It calls revalidate(), which walks up the parent chain marking figures as invalid until a "root" is reached which is reported to the update manager. The update manager validates the invalid branches. Layout happens top-down. Note the Fig 5 was not invalid, but if Fig 2 changes its size as a result of laying out, the Fig 5 will mark itself as invalid and get validated as part of the same pass.

In the above example, Fig 5 may have its size changed when Fig 2 performs its layout.

Top-Down Layout

Normally figures layout in a top-down fashion. This means that figure has its bounds set before it lays out its children. Also, after it places its children, it then calls validate() on them in case their size changed, making them invalid. This is the same way that Composites work in SWT.

Special-Purpose Layout Techniques

In some cases, the top-down process is modified. A common example is figures whose bounds must wrap around the bounds of their children. Connections

The other special layout case is found in the text package. Text figures must layout in two steps. First, they contribute fragments into paragraphs or blocks. These fragments may get reordered for bidirectional text. Also, their baselines and the overall alignment of each line may also be adjusted. The end of a line or block may only occur after a figure has finished its layout. So, the second layout pass is simply a finalization step in which the figures are told to now update their bounds based on their final fragment locations. Understanding this layout is no necessary for using the text package, but it does help in appreciating some of the problems solved by Draw2d's approach to layouts and coordinate systems.

eclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/guide/overview.html000066400000000000000000000047461166301720600245130ustar00rootroot00000000000000 Draw2d Architecture

Draw2d Overview

Draw2d is a lightweight toolkit of graphical components called figures. Lightweight means that a figure is simply a java object, with no corresponding resource in the operating system. Figures can be composed via a parent-child relationship. Every figure has a rectangular bounds inside which it, and its children, paint. A layout manager can be used to place children based on their index and/or constraint.

A LightweightSystem associates a figure composition with an SWT Canvas. The lightweight system hooks listeners for most SWT events, and forwards most of them to an EventDispatcher, which translates them into events on the appropriate figure.

Paint events, however, are forwarded to the UpdateManager, which coordinates painting and layout. Figures can be updated in ways which affect their appearance or size, and the update manager ensures that only one layout occurs, followed by a repaint of only the region which was updated.

Any type of diagram, document, or drawing can be easily constructed and efficiently updated by combining the provided figure and layout implementations along with the use of custom figures or layouts when needed.

Additional topics:

  • Painting - details of the paint process and how nesting affects painting
  • Layout - preferred size, layout, validating figures
  • Hit Testing - finding figures, correcting coordinates, modifying the space occupied by a figure
  • Connections and Routing - connections, anchors, decorations, and routing
  • Coordinate Systems - absolute and relative coordinates, working with absolute coordinates
eclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/guide/painting.html000066400000000000000000000071161166301720600244500ustar00rootroot00000000000000 Painting

Painting of Figures

Figures are painted using a Graphics. The Graphics abstraction allows Draw2d to wrapper an SWT GC for extended functionality as well as performance optimizations. For example, Graphics supports pushing and popping of the current state. A figure paints using the following process:

  • Figure#paint() - This method is declared on the interface, and kicks off the painting process. First, properties are set on the Graphics that would be inherited by children, including Font, background, and foreground Color. Then the Graphics state is pushed so that just these inherited settings can be restored when painting children. Next, the following methods are called:
    • Figure#paintFigure() - The figure paints itself. Figures are not required to paint at all. A simple form of painting would be to fill in the bounding box with the figure's background color.
    • Figure#paintClientArea() - The client area is where children appear. This method should apply any changes to the Graphics which affect only children, such as coordinate system modifications like translating the graphics to the client area. This method also clips the graphics two the region where children are allowed to appear.
      • Figure#paintChildren() - Now that the client area is setup, children are painted. After each child paints, the graphics state is restored to the incoming state so that children do not overwrite the inherited graphics settings from the parent
    • Figure#paintBorder() - Finally, the figure paints decorations which should appear on top of the children. If a Border has been set on the figure, it paints now.

Z-Order

The result of this process is that a figure composition (which structurally is a tree) paints in a pre-order, depth-first manner. The exception being the borders which are painted post-order. Using push and pop, changes made to the Graphics by one branch of figures have no affect on other branches. The order in which figures paint is often referred to as z-order. This term comes from the fact that the paint order creates the illusion of depth, and the z-axis would be perpendicular to the display's x and y axes. Z-order or paint order is also manifested in the way hit testing is done.

Clipping

When a figure paints its children, it first clips the Graphics to its client area. As each child is painted, the graphics is also clipped to the child's bounds. This prevents the child from painting outside of its bounds or the client area of the parent. Clipping is cumulative based on the entire parent chain. Below, Figure 3 is parented by Figure 2, which is parented by Figure 1.

See Also

eclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/plugin.properties000066400000000000000000000011761166301720600242700ustar00rootroot00000000000000############################################################################### # Copyright (c) 2002, 2009 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # # Contributors: # IBM Corporation - initial API and implementation ############################################################################### Plugin.name=Graphical Editing Framework Draw2d Documentation Plugin.providerName = Eclipse Modeling Project eclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/plugin.xml000066400000000000000000000014321166301720600226670ustar00rootroot00000000000000 eclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/topics_Guide.xml000066400000000000000000000015101166301720600240040ustar00rootroot00000000000000 eclipse-gef-3.7.1/org.eclipse.draw2d.doc.isv/topics_Reference.xml000066400000000000000000000030511166301720600246470ustar00rootroot00000000000000 eclipse-gef-3.7.1/org.eclipse.draw2d/000077500000000000000000000000001166301720600173035ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.draw2d/.checkstyle000066400000000000000000000010251166301720600214400ustar00rootroot00000000000000 eclipse-gef-3.7.1/org.eclipse.draw2d/.classpath000066400000000000000000000005571166301720600212750ustar00rootroot00000000000000 eclipse-gef-3.7.1/org.eclipse.draw2d/.cvsignore000066400000000000000000000000531166301720600213010ustar00rootroot00000000000000bin runtime temp.folder .settings org eclipse-gef-3.7.1/org.eclipse.draw2d/.project000066400000000000000000000016221166301720600207530ustar00rootroot00000000000000 org.eclipse.draw2d org.eclipse.jdt.core.javabuilder org.eclipse.pde.ManifestBuilder org.eclipse.pde.SchemaBuilder org.eclipse.pde.api.tools.apiAnalysisBuilder org.eclipse.jdt.core.javanature com.atlassw.tools.eclipse.checkstyle.CheckstyleNature org.eclipse.pde.PluginNature org.eclipse.pde.api.tools.apiAnalysisNature eclipse-gef-3.7.1/org.eclipse.draw2d/.settings/000077500000000000000000000000001166301720600212215ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.draw2d/.settings/.api_filters000077500000000000000000000007061166301720600235310ustar00rootroot00000000000000 eclipse-gef-3.7.1/org.eclipse.draw2d/.settings/checkstyleAPI.xml000066400000000000000000000013501166301720600244320ustar00rootroot00000000000000 eclipse-gef-3.7.1/org.eclipse.draw2d/.settings/checkstyleGeneric.xml000066400000000000000000000111531166301720600253770ustar00rootroot00000000000000 eclipse-gef-3.7.1/org.eclipse.draw2d/.settings/org.eclipse.jdt.core.prefs000066400000000000000000000644201166301720600262110ustar00rootroot00000000000000#Tue Nov 16 19:49:09 CET 2010 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.4 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.doc.comment.support=enabled org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning org.eclipse.jdt.core.compiler.problem.autoboxing=ignore org.eclipse.jdt.core.compiler.problem.deprecation=ignore org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=protected org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled org.eclipse.jdt.core.compiler.problem.unusedImport=warning org.eclipse.jdt.core.compiler.problem.unusedLocal=warning org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.3 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_assignment=0 org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 org.eclipse.jdt.core.formatter.blank_lines_after_package=1 org.eclipse.jdt.core.formatter.blank_lines_before_field=0 org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 org.eclipse.jdt.core.formatter.blank_lines_before_method=1 org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 org.eclipse.jdt.core.formatter.blank_lines_before_package=0 org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false org.eclipse.jdt.core.formatter.comment.format_block_comments=true org.eclipse.jdt.core.formatter.comment.format_header=false org.eclipse.jdt.core.formatter.comment.format_html=true org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true org.eclipse.jdt.core.formatter.comment.format_line_comments=true org.eclipse.jdt.core.formatter.comment.format_source_code=true org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true org.eclipse.jdt.core.formatter.comment.indent_root_tags=true org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert org.eclipse.jdt.core.formatter.comment.line_length=80 org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true org.eclipse.jdt.core.formatter.compact_else_if=true org.eclipse.jdt.core.formatter.continuation_indentation=2 org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true org.eclipse.jdt.core.formatter.indent_empty_lines=false org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false org.eclipse.jdt.core.formatter.indentation.size=4 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert org.eclipse.jdt.core.formatter.join_lines_in_comments=true org.eclipse.jdt.core.formatter.join_wrapped_lines=true org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false org.eclipse.jdt.core.formatter.lineSplit=80 org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true org.eclipse.jdt.core.formatter.tabulation.char=tab org.eclipse.jdt.core.formatter.tabulation.size=4 org.eclipse.jdt.core.formatter.use_on_off_tags=false org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true eclipse-gef-3.7.1/org.eclipse.draw2d/.settings/org.eclipse.jdt.ui.prefs000066400000000000000000000202411166301720600256670ustar00rootroot00000000000000#Tue Nov 16 19:49:09 CET 2010 eclipse.preferences.version=1 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true formatter_profile=org.eclipse.jdt.ui.default.eclipse_profile formatter_settings_version=11 internal.default.compliance=default org.eclipse.jdt.ui.ignorelowercasenames=true org.eclipse.jdt.ui.importorder=java;org.eclipse.swt;org.eclipse;org.eclipse.draw2d;org.eclipse.gef;org.eclipse.gef.examples; org.eclipse.jdt.ui.javadoc=false org.eclipse.jdt.ui.ondemandthreshold=999 org.eclipse.jdt.ui.text.custom_code_templates= sp_cleanup.add_default_serial_version_id=true sp_cleanup.add_generated_serial_version_id=false sp_cleanup.add_missing_annotations=true sp_cleanup.add_missing_deprecated_annotations=true sp_cleanup.add_missing_methods=false sp_cleanup.add_missing_nls_tags=false sp_cleanup.add_missing_override_annotations=true sp_cleanup.add_missing_override_annotations_interface_methods=true sp_cleanup.add_serial_version_id=false sp_cleanup.always_use_blocks=true sp_cleanup.always_use_parentheses_in_expressions=false sp_cleanup.always_use_this_for_non_static_field_access=false sp_cleanup.always_use_this_for_non_static_method_access=false sp_cleanup.convert_to_enhanced_for_loop=false sp_cleanup.correct_indentation=false sp_cleanup.format_source_code=true sp_cleanup.format_source_code_changes_only=false sp_cleanup.make_local_variable_final=false sp_cleanup.make_parameters_final=false sp_cleanup.make_private_fields_final=true sp_cleanup.make_type_abstract_if_missing_method=false sp_cleanup.make_variable_declarations_final=true sp_cleanup.never_use_blocks=false sp_cleanup.never_use_parentheses_in_expressions=true sp_cleanup.on_save_use_additional_actions=false sp_cleanup.organize_imports=true sp_cleanup.qualify_static_field_accesses_with_declaring_class=false sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true sp_cleanup.qualify_static_member_accesses_with_declaring_class=false sp_cleanup.qualify_static_method_accesses_with_declaring_class=false sp_cleanup.remove_private_constructors=true sp_cleanup.remove_trailing_whitespaces=false sp_cleanup.remove_trailing_whitespaces_all=true sp_cleanup.remove_trailing_whitespaces_ignore_empty=false sp_cleanup.remove_unnecessary_casts=true sp_cleanup.remove_unnecessary_nls_tags=false sp_cleanup.remove_unused_imports=false sp_cleanup.remove_unused_local_variables=false sp_cleanup.remove_unused_private_fields=true sp_cleanup.remove_unused_private_members=false sp_cleanup.remove_unused_private_methods=true sp_cleanup.remove_unused_private_types=true sp_cleanup.sort_members=false sp_cleanup.sort_members_all=false sp_cleanup.use_blocks=false sp_cleanup.use_blocks_only_for_return_and_throw=false sp_cleanup.use_parentheses_in_expressions=false sp_cleanup.use_this_for_non_static_field_access=false sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true sp_cleanup.use_this_for_non_static_method_access=false sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true eclipse-gef-3.7.1/org.eclipse.draw2d/.settings/org.eclipse.pde.api.tools.prefs000066400000000000000000000100541166301720600271520ustar00rootroot00000000000000#Tue Nov 11 17:03:08 EST 2008 ANNOTATION_ELEMENT_TYPE_ADDED_METHOD_WITHOUT_DEFAULT_VALUE=Error ANNOTATION_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error ANNOTATION_ELEMENT_TYPE_REMOVED_FIELD=Error ANNOTATION_ELEMENT_TYPE_REMOVED_METHOD=Error ANNOTATION_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error API_COMPONENT_ELEMENT_TYPE_REMOVED_API_TYPE=Error API_COMPONENT_ELEMENT_TYPE_REMOVED_TYPE=Error CLASS_ELEMENT_TYPE_ADDED_METHOD=Error CLASS_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error CLASS_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error CLASS_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error CLASS_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error CLASS_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error CLASS_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error CLASS_ELEMENT_TYPE_CHANGED_RESTRICTIONS=Error CLASS_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error CLASS_ELEMENT_TYPE_REMOVED_CONSTRUCTOR=Error CLASS_ELEMENT_TYPE_REMOVED_FIELD=Error CLASS_ELEMENT_TYPE_REMOVED_METHOD=Error CLASS_ELEMENT_TYPE_REMOVED_SUPERCLASS=Error CLASS_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error CLASS_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error CONSTRUCTOR_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error CONSTRUCTOR_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error CONSTRUCTOR_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error CONSTRUCTOR_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error ENUM_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error ENUM_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error ENUM_ELEMENT_TYPE_REMOVED_ENUM_CONSTANT=Error ENUM_ELEMENT_TYPE_REMOVED_FIELD=Error ENUM_ELEMENT_TYPE_REMOVED_METHOD=Error ENUM_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error FIELD_ELEMENT_TYPE_ADDED_VALUE=Error FIELD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error FIELD_ELEMENT_TYPE_CHANGED_FINAL_TO_NON_FINAL_STATIC_CONSTANT=Error FIELD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error FIELD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error FIELD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error FIELD_ELEMENT_TYPE_CHANGED_TYPE=Error FIELD_ELEMENT_TYPE_CHANGED_VALUE=Error FIELD_ELEMENT_TYPE_REMOVED_TYPE_ARGUMENT=Error FIELD_ELEMENT_TYPE_REMOVED_VALUE=Error ILLEGAL_EXTEND=Error ILLEGAL_IMPLEMENT=Error ILLEGAL_INSTANTIATE=Error ILLEGAL_OVERRIDE=Error ILLEGAL_REFERENCE=Error INTERFACE_ELEMENT_TYPE_ADDED_FIELD=Error INTERFACE_ELEMENT_TYPE_ADDED_METHOD=Error INTERFACE_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error INTERFACE_ELEMENT_TYPE_ADDED_SUPER_INTERFACE_WITH_METHODS=Error INTERFACE_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error INTERFACE_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error INTERFACE_ELEMENT_TYPE_CHANGED_RESTRICTIONS=Error INTERFACE_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error INTERFACE_ELEMENT_TYPE_REMOVED_FIELD=Error INTERFACE_ELEMENT_TYPE_REMOVED_METHOD=Error INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error INVALID_JAVADOC_TAG=Error LEAK_EXTEND=Error LEAK_FIELD_DECL=Error LEAK_IMPLEMENT=Error LEAK_METHOD_PARAM=Error LEAK_METHOD_RETURN_TYPE=Error METHOD_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error METHOD_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error METHOD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error METHOD_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error METHOD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error METHOD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error METHOD_ELEMENT_TYPE_CHANGED_RESTRICTIONS=Error METHOD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error METHOD_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error METHOD_ELEMENT_TYPE_REMOVED_ANNOTATION_DEFAULT_VALUE=Error METHOD_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error TYPE_PARAMETER_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error TYPE_PARAMETER_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error eclipse.preferences.version=1 incompatible_api_component_version=Error incompatible_api_component_version_include_major_without_breaking_change=Disabled incompatible_api_component_version_include_minor_without_api_change=Disabled invalid_since_tag_version=Error malformed_since_tag=Error missing_since_tag=Error eclipse-gef-3.7.1/org.eclipse.draw2d/META-INF/000077500000000000000000000000001166301720600204435ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.draw2d/META-INF/MANIFEST.MF000066400000000000000000000012451166301720600220770ustar00rootroot00000000000000Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Plugin.name Bundle-SymbolicName: org.eclipse.draw2d Bundle-Version: 3.7.1.qualifier Bundle-Vendor: %Plugin.providerName Bundle-Localization: plugin Import-Package: com.ibm.icu.text;version="[3.8.1,5.0.0)" Export-Package: org.eclipse.draw2d, org.eclipse.draw2d.graph, org.eclipse.draw2d.geometry, org.eclipse.draw2d.images, org.eclipse.draw2d.internal;x-internal:=true, org.eclipse.draw2d.parts, org.eclipse.draw2d.text, org.eclipse.draw2d.widgets Require-Bundle: org.eclipse.swt;visibility:=reexport;bundle-version="[3.2.0,4.0.0)" Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: J2SE-1.4 eclipse-gef-3.7.1/org.eclipse.draw2d/about.html000066400000000000000000000024631166301720600213100ustar00rootroot00000000000000 About

About This Content

June 5, 2007

License

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available at http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, "Program" will mean the Content.

If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party ("Redistributor") and different terms and conditions may apply to your use of any object code in the Content. Check the Redistributor's license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise indicated below, the terms and conditions of the EPL still apply to any source code in the Content and such source code may be obtained at http://www.eclipse.org.

eclipse-gef-3.7.1/org.eclipse.draw2d/about.ini000066400000000000000000000006131166301720600211160ustar00rootroot00000000000000# about.ini # contains information about a feature # java.io.Properties file (ISO 8859-1 with "\" escapes) # "%key" are externalized strings defined in about.properties # This file does not need to be translated. # Property "aboutText" contains blurb for "About" dialog (translated) aboutText=%blurb # Property "featureImage" contains path to feature image (32x32) featureImage=modeling32.png eclipse-gef-3.7.1/org.eclipse.draw2d/about.mappings000066400000000000000000000002501166301720600221520ustar00rootroot00000000000000# about.mappings # contains fill-ins for about.properties # java.io.Properties file (ISO 8859-1 with "\" escapes) # This file does not need to be translated. 0=@build@eclipse-gef-3.7.1/org.eclipse.draw2d/about.properties000066400000000000000000000016661166301720600225440ustar00rootroot00000000000000############################################################################### # Copyright (c) 2007, 2010 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # # Contributors: # IBM Corporation - initial API and implementation ############################################################################### # about.properties # contains externalized strings for about.ini # java.io.Properties file (ISO 8859-1 with "\" escapes) # fill-ins are supplied by about.mappings # This file should be translated. blurb=Eclipse Graphical Editing Framework Draw2d\n\ \n\ Version: {featureVersion}\n\ Build id: {0}\n\ \n\ (c) Copyright Eclipse Contributors and others 2000, 2010. All rights reserved.\n\ Visit http://www.eclipse.org/gef eclipse-gef-3.7.1/org.eclipse.draw2d/build.properties000066400000000000000000000014071166301720600225220ustar00rootroot00000000000000############################################################################### # Copyright (c) 2002, 2009 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # # Contributors: # IBM Corporation - initial API and implementation ############################################################################### bin.includes = about.*,\ modeling32.png,\ META-INF/,\ .,\ plugin.properties bin.excludes = **/doc-files/** source.. = src/ src.includes = src/org/eclipse/draw2d/images/eclipse-gef-3.7.1/org.eclipse.draw2d/modeling32.png000066400000000000000000000045561166301720600217660ustar00rootroot00000000000000PNG  IHDR szzgAMAOX2tEXtSoftwareAdobe ImageReadyqe< IDATxڬW}l{޶MGL'Yܔ9$fKYE "p7ee٬ f(ks6%˶==<FhAԡk$e! ć8b@t3lF=?!+xq\͐&)\y XJP,A8/g54ř4JmUZ-|n`%/HpĤquB# LH0EsB_ex^(yH0 AƬ/Yeќ9P o4bmdٷ?§0,F42,BLa6nX~}O}a@]Y |^ C^$jYfӅNc4*Mt4&ɲ42E(r3*+Z}{[w+r }P# -p45z ] Ma[ʔ'}{ţ+7oߎK,Ob8Nu<$|Q%Pi&:MǛg|o?Z7o ۶;w+ se:Z9OF'y\!C~*G2wdh u6/u(zF>z{1[<󂁚x /WJbmԜ`rݚ&uޒyfffjn%QkAb,dG/D ‘}._)2'/J_>$ ҆8mٲ^?E~ zAhit&{;dm6k$S u_{%m-KWW֬k%=zUXKs6#!"<26Tyx}8/\0}7詇H&쳯ѥKYiuϞ~};  1t#W#p ::Zܾ}G<o|a߾~7soOӮ=J>v~JŲLAWtq~78k]dXOo_]]뵷4+y4OѴ(0P.XPc~n\`4| g\# [h5nk+Лc轡Zª%,\b>474)݅rvF>ᑑhOpx`jHƺ3\R0 U_(Б%6,sGQgFvJrꗽ@\2+4AAxB `F3pM&n#J27Oz+Aj_ ʘWvoIENDB`eclipse-gef-3.7.1/org.eclipse.draw2d/plugin.properties000066400000000000000000000011601166301720600227150ustar00rootroot00000000000000############################################################################### # Copyright (c) 2007, 2009 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # # Contributors: # IBM Corporation - initial API and implementation ############################################################################### Plugin.name=Graphical Editing Framework Draw2d Plugin.providerName = Eclipse Modeling Project eclipse-gef-3.7.1/org.eclipse.draw2d/src/000077500000000000000000000000001166301720600200725ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/000077500000000000000000000000001166301720600206615ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/000077500000000000000000000000001166301720600223055ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/000077500000000000000000000000001166301720600234705ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/AbsoluteBendpoint.java000066400000000000000000000025661166301720600277650ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Point; /** * AbsoluteBendpoint is a Bendpoint that defines its location simply as its X * and Y coordinates. It is used by bendable {@link Connection Connections}. */ public class AbsoluteBendpoint extends Point implements Bendpoint { /** * Creates a new AbsoluteBendpoint at the Point p. * * @param p * The absolute location of the bendpoint * @since 2.0 */ public AbsoluteBendpoint(Point p) { super(p); } /** * Creates a new AbsoluteBendpoint at the Point (x,y). * * @param x * The X coordinate * @param y * The Y coordinate * @since 2.0 */ public AbsoluteBendpoint(int x, int y) { super(x, y); } /** * @see org.eclipse.draw2d.Bendpoint#getLocation() */ public Point getLocation() { return this; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/AbstractBackground.java000066400000000000000000000035741166301720600301070ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2007, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Insets; /** * A special border which can paint both underneath and on top of a Figure. * Normal borders only paint on top of a figure and its children. A background * has the opportunity to paint both first, and optionally last. *

* WARNING: Experimental for 3.3. Clients should help validate the use cases of * this new function. * * @since 3.3 */ public class AbstractBackground extends AbstractBorder { /** * {@inheritDoc} */ public Insets getInsets(IFigure figure) { return IFigure.NO_INSETS; } /** * {@inheritDoc} By default, this method is stubbed out for backgrounds * which only paint underneath a figure. */ public void paint(IFigure figure, Graphics graphics, Insets insets) { } /** * Called when this Background should paint. If the background is being * painted inside another border or background, the insets indicate how far * inside the target figure the background should be painted. In most cases, * the insets will be all zero. * * @param figure * The figure on which the background is being painted * @param graphics * The graphics * @param insets * Amount to inset from the figure's bounds * @since 3.2 */ public void paintBackground(IFigure figure, Graphics graphics, Insets insets) { } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/AbstractBorder.java000066400000000000000000000035011166301720600272330ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Insets; import org.eclipse.draw2d.geometry.Rectangle; /** * Provides generic support for borders. * * @author hudsonr */ public abstract class AbstractBorder implements Border { private static final Dimension EMPTY = new Dimension(); /** A temporary Rectangle */ protected static Rectangle tempRect = new Rectangle(); /** * Returns a temporary rectangle representing the figure's bounds cropped by * the specified insets. This method exists for convenience and performance; * the method does not new any Objects and returns a rectangle which the * caller can manipulate. * * @since 2.0 * @param figure * Figure for which the paintable rectangle is needed * @param insets * The insets * @return The paintable region on the Figure f */ protected static final Rectangle getPaintRectangle(IFigure figure, Insets insets) { tempRect.setBounds(figure.getBounds()); return tempRect.crop(insets); } /** * @see org.eclipse.draw2d.Border#getPreferredSize(IFigure) */ public Dimension getPreferredSize(IFigure f) { return EMPTY; } /** * @see org.eclipse.draw2d.Border#isOpaque() */ public boolean isOpaque() { return false; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/AbstractConnectionAnchor.java000066400000000000000000000071241166301720600312550ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Point; /** * Provides support for anchors which depend on a figure for thier location. * * @author hudsonr */ public abstract class AbstractConnectionAnchor extends ConnectionAnchorBase implements AncestorListener { private IFigure owner; /** * Constructs an AbstractConnectionAnchor with no owner. * * @since 2.0 */ public AbstractConnectionAnchor() { } /** * Constructs an AbstractConnectionAnchor with the owner supplied as input. * * @since 2.0 * @param owner * Owner of this anchor */ public AbstractConnectionAnchor(IFigure owner) { setOwner(owner); } /** * Adds the given listener to the listeners to be notified of anchor * location changes. * * @since 2.0 * @param listener * Listener to be added * @see #removeAnchorListener(AnchorListener) */ public void addAnchorListener(AnchorListener listener) { if (listener == null) return; if (listeners.size() == 0) getOwner().addAncestorListener(this); super.addAnchorListener(listener); } /** * Notifies all the listeners of this anchor's location change. * * @since 2.0 * @param figure * Anchor-owning Figure which has moved * @see org.eclipse.draw2d.AncestorListener#ancestorMoved(IFigure) */ public void ancestorMoved(IFigure figure) { fireAnchorMoved(); } /** * @see org.eclipse.draw2d.AncestorListener#ancestorAdded(IFigure) */ public void ancestorAdded(IFigure ancestor) { } /** * @see org.eclipse.draw2d.AncestorListener#ancestorRemoved(IFigure) */ public void ancestorRemoved(IFigure ancestor) { } /** * Returns the owner Figure on which this anchor's location is dependent. * * @since 2.0 * @return Owner of this anchor * @see #setOwner(IFigure) */ public IFigure getOwner() { return owner; } /** * Returns the point which is used as the reference by this * AbstractConnectionAnchor. It is generally dependent on the Figure which * is the owner of this AbstractConnectionAnchor. * * @since 2.0 * @return The reference point of this anchor * @see org.eclipse.draw2d.ConnectionAnchor#getReferencePoint() */ public Point getReferencePoint() { if (getOwner() == null) return null; else { Point ref = getOwner().getBounds().getCenter(); getOwner().translateToAbsolute(ref); return ref; } } /** * Removes the given listener from this anchor. If all the listeners are * removed, then this anchor removes itself from its owner. * * @since 2.0 * @param listener * Listener to be removed from this anchors listeners list * @see #addAnchorListener(AnchorListener) */ public void removeAnchorListener(AnchorListener listener) { super.removeAnchorListener(listener); if (listeners.size() == 0) getOwner().removeAncestorListener(this); } /** * Sets the owner of this anchor, on whom this anchors location is * dependent. * * @since 2.0 * @param owner * Owner of this anchor */ public void setOwner(IFigure owner) { this.owner = owner; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/AbstractHintLayout.java000066400000000000000000000103141166301720600301160ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Dimension; /** * The foundation for layout managers which are sensitive to width and/or height * hints. This class will cache preferred and minimum sizes for a given set of * hints. If the hints change in a meaningful way, the cached size is thrown out * and redetermined. *

* Subclasses may be sensitive to one or both hints. By default, this class * assumes both hints are important. Subclasses may override this behavior in * {@link #isSensitiveHorizontally(IFigure)} and * {@link #isSensitiveVertically(IFigure)}. At least one of these method should * return true. * * @author hudsonr * @since 2.0 */ public abstract class AbstractHintLayout extends AbstractLayout { private Dimension minimumSize = null; private Dimension cachedPreferredHint = new Dimension(-1, -1); private Dimension cachedMinimumHint = new Dimension(-1, -1); /** * Calculates the minimum size using the given width and height hints. This * method is called from {@link #getMinimumSize(IFigure, int, int)} whenever * the cached minimum size has been flushed. *

* By default, this method just calls * {@link #getPreferredSize(IFigure, int, int)}, meaning minimum and * preferres sizes will be the same unless this method is overridden. * * @param container * the Figure on which this layout is installed * @param wHint * the width hint * @param hHint * the height hint * * @return the layout's minimum size */ protected Dimension calculateMinimumSize(IFigure container, int wHint, int hHint) { return getPreferredSize(container, wHint, hHint); } /** * @see org.eclipse.draw2d.LayoutManager#getMinimumSize(IFigure, int, int) */ public Dimension getMinimumSize(IFigure container, int w, int h) { boolean flush = cachedMinimumHint.width != w && isSensitiveHorizontally(container); flush |= cachedMinimumHint.height != h && isSensitiveVertically(container); if (flush) { minimumSize = null; cachedMinimumHint.width = w; cachedMinimumHint.height = h; } if (minimumSize == null) minimumSize = calculateMinimumSize(container, w, h); return minimumSize; } /** * @see org.eclipse.draw2d.LayoutManager#getPreferredSize(IFigure, int, int) */ public final Dimension getPreferredSize(IFigure container, int w, int h) { boolean flush = cachedPreferredHint.width != w && isSensitiveHorizontally(container); flush |= cachedPreferredHint.height != h && isSensitiveVertically(container); if (flush) { preferredSize = null; cachedPreferredHint.width = w; cachedPreferredHint.height = h; } return super.getPreferredSize(container, w, h); } /** * Extends the superclass implementation to flush the cached minimum size. * * @see org.eclipse.draw2d.LayoutManager#invalidate() */ public void invalidate() { minimumSize = null; super.invalidate(); } /** * Returns whether this layout manager is sensitive to changes in the * horizontal hint. By default, this method returns true. * * @param container * the layout's container * @return true if this layout is sensite to horizontal hint * changes */ protected boolean isSensitiveHorizontally(IFigure container) { return true; } /** * Returns whether this layout manager is sensitive to changes in the * vertical hint. By default, this method returns true. * * @param container * the layout's container * @return true if this layout is sensite to vertical hint * changes */ protected boolean isSensitiveVertically(IFigure container) { return true; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/AbstractImageFigure.java000066400000000000000000000027361166301720600302130ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /** * Abstract implementation of the image figure. Implements attaching/detaching * mechanism for ImageChangedListener * * @author aboyko * @since 3.6 */ public abstract class AbstractImageFigure extends Figure implements IImageFigure { private List imageListeners = new ArrayList(); public final void addImageChangedListener(ImageChangedListener listener) { if (listener == null) { throw new IllegalArgumentException(); } imageListeners.add(listener); } public final void removeImageChangedListener(ImageChangedListener listener) { if (listener == null) { throw new IllegalArgumentException(); } imageListeners.remove(listener); } protected final void notifyImageChanged() { for (Iterator itr = imageListeners.iterator(); itr.hasNext();) { ((ImageChangedListener) itr.next()).imageChanged(); } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/AbstractLabeledBorder.java000066400000000000000000000106031166301720600305050ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Insets; /** * Provides support for a border with a label describing the contents of which * it is surrounding. */ public abstract class AbstractLabeledBorder extends AbstractBorder implements LabeledBorder { private Dimension textExtents; private String label; private Insets insets; private Color textColor = ColorConstants.black; private Font font; /** * Constructs a default AbstractLabeledBorder with the name of this class * set as its label. * * @since 2.0 */ public AbstractLabeledBorder() { String className = getClass().getName(); setLabel(className.substring(className.lastIndexOf('.') + 1, className.length())); } /** * Constructs a border with the label set to the String passed in as input. * * @param s * Label to be set on the border * @since 2.0 */ public AbstractLabeledBorder(String s) { setLabel(s); } /** * Calculates insets based on the current font and other attributes. This * value will be cached until {@link #invalidate()} is called. * * @param figure * The figure to which the border is being applied * @return The Insets */ protected abstract Insets calculateInsets(IFigure figure); /** * Returns the font that this border will use. If no Font has been * specified, the font associated with the input Figure will be used. * * @param f * Figure used to get a default font * @return The font for this border */ protected Font getFont(IFigure f) { if (font == null) return f.getFont(); return font; } /** * Returns the insets, or space associated for this border. Returns any * previously set value if present, else calculates it from the Figure * provided in as input. * * @param fig * Figure used to calculate insets * @return The insets */ public Insets getInsets(IFigure fig) { if (insets == null) insets = calculateInsets(fig); return insets; } /** * @see org.eclipse.draw2d.LabeledBorder#getLabel() */ public String getLabel() { return label; } /** * @see org.eclipse.draw2d.Border#getPreferredSize(IFigure) */ public Dimension getPreferredSize(IFigure fig) { return new Dimension(getTextExtents(fig)); } /** * Returns the text Color of this AbstractLabeledBorder's label. * * @return The text color * @since 2.0 */ public Color getTextColor() { return textColor; } /** * Calculates and returns the size required by this border's label. * * @param f * IFigure on which the calculations are to be made * @return Dimensions required by the text of this border's label * @since 2.0 */ protected Dimension getTextExtents(IFigure f) { if (textExtents == null) textExtents = FigureUtilities.getTextExtents(label, getFont(f)); return textExtents; } /** * Resets the internal values and state so that they can be recalculated. * Called whenever a state change has occurred that effects the insets or * text extents of this border. */ protected void invalidate() { insets = null; textExtents = null; } /** * Sets the Font of this border to the input value, and invalidates the * border forcing an update of internal parameters of insets and text * extents. * * @param font * The font */ public void setFont(Font font) { this.font = font; invalidate(); } /** * @see org.eclipse.draw2d.LabeledBorder#setLabel(String) */ public void setLabel(String s) { label = ((s == null) ? "" : s); //$NON-NLS-1$ invalidate(); } /** * Sets the color for this border's text. * * @param color * Color to be set for this border's text * @since 2.0 */ public void setTextColor(Color color) { textColor = color; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/AbstractLayout.java000066400000000000000000000111641166301720600272770ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Dimension; /** * Provides generic support for LayoutManagers. */ public abstract class AbstractLayout implements LayoutManager { /** * The cached preferred size. */ protected Dimension preferredSize; /** * Whether or not this layout pays attention to visiblity of figures when * calculating its bounds. By default, false. */ protected boolean isObservingVisibility = false; /** * This method is now {@link #calculatePreferredSize(IFigure, int, int)}. * * @param container * the figure */ protected final void calculatePreferredSize(IFigure container) { } /** * Calculates the preferred size of the given figure, using width and height * hints. * * @param container * The figure * @param wHint * The width hint * @param hHint * The height hint * @return The preferred size */ protected abstract Dimension calculatePreferredSize(IFigure container, int wHint, int hHint); /** * Returns the preferred size of the figure's border. * * @param container * The figure that the border is on * @return The border's preferred size */ protected Dimension getBorderPreferredSize(IFigure container) { if (container.getBorder() == null) return new Dimension(); return container.getBorder().getPreferredSize(container); } /** * Returns the constraint for the given figure. * * @param child * The figure * @return The constraint */ public Object getConstraint(IFigure child) { return null; } /** * This method is now {@link #getMinimumSize(IFigure, int, int)}. * * @param container * the figure */ public final void getMinimumSize(IFigure container) { } /** * @see org.eclipse.draw2d.LayoutManager#getMinimumSize(IFigure, int, int) */ public Dimension getMinimumSize(IFigure container, int wHint, int hHint) { return getPreferredSize(container, wHint, hHint); } /** * Returns the preferred size of the given figure, using width and height * hints. If the preferred size is cached, that size is returned. Otherwise, * {@link #calculatePreferredSize(IFigure, int, int)} is called. * * @param container * The figure * @param wHint * The width hint * @param hHint * The height hint * @return The preferred size */ public Dimension getPreferredSize(IFigure container, int wHint, int hHint) { if (preferredSize == null) preferredSize = calculatePreferredSize(container, wHint, hHint); return preferredSize; } /** * This method is now {@link #getPreferredSize(IFigure, int, int)}. * * @param container * the figure */ public final void getPreferredSize(IFigure container) { } /** * @see org.eclipse.draw2d.LayoutManager#invalidate() */ public void invalidate() { preferredSize = null; } /** * Removes any cached information about the given figure. * * @param child * the child that is invalidated */ protected void invalidate(IFigure child) { invalidate(); } /** * Returns whether or not this layout pays attention to visiblity when * calculating its bounds. * * @return true if invisible figures should not contribute to this layout's * bounds. */ public boolean isObservingVisibility() { return isObservingVisibility; } /** * Removes the given figure from this LayoutManager's list of figures. * * @param child * The figure to remove */ public void remove(IFigure child) { invalidate(); } /** * Sets the constraint for the given figure. * * @param child * the child * @param constraint * the child's new constraint */ public void setConstraint(IFigure child, Object constraint) { invalidate(child); } /** * Sets isObservingVisibility to the given value. * * @param newValue * true if visibility should be observed */ public void setObserveVisibility(boolean newValue) { if (isObservingVisibility == newValue) return; isObservingVisibility = newValue; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/AbstractLocator.java000066400000000000000000000076661166301720600274410ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; /** * Places a figure relative to a point determined by the subclass. The figure * may be placed in some location relative to the point with a configurable * amount of spacing. */ public abstract class AbstractLocator implements Locator { private int relativePosition = PositionConstants.CENTER; private int gap; /** * Creates a new AbstractLocator. */ public AbstractLocator() { } /** * Returns the number of pixels to leave between the figure being located * and the reference point. Only used if {@link #getRelativePosition()} * returns something other than {@link PositionConstants#CENTER}. * * @return The gap * @since 2.0 */ public int getGap() { return gap; } /** * Returns the reference point in absolute coordinates used to calculate the * location. * * @return The reference point in absolute coordinates * @since 2.0 */ protected abstract Point getReferencePoint(); /** * Recalculate the location of the figure according to its desired position * relative to the center point. * * @param size * The size of the figure * @param center * The center point * @return The new bounds * @since 2.0 */ protected Rectangle getNewBounds(Dimension size, Point center) { Rectangle bounds = new Rectangle(center, size); bounds.x -= bounds.width / 2; bounds.y -= bounds.height / 2; int xFactor = 0, yFactor = 0; int position = getRelativePosition(); if ((position & PositionConstants.NORTH) != 0) yFactor = -1; else if ((position & PositionConstants.SOUTH) != 0) yFactor = 1; if ((position & PositionConstants.WEST) != 0) xFactor = -1; else if ((position & PositionConstants.EAST) != 0) xFactor = 1; bounds.x += xFactor * (bounds.width / 2 + getGap()); bounds.y += yFactor * (bounds.height / 2 + getGap()); return bounds; } /** * Returns the position of the figure with respect to the center point. * Possible values can be found in {@link PositionConstants} and include * CENTER, NORTH, SOUTH, EAST, WEST, NORTH_EAST, NORTH_WEST, SOUTH_EAST, or * SOUTH_WEST. * * @return An int constant representing the relative position * @since 2.0 */ public int getRelativePosition() { return relativePosition; } /** * Recalculates the position of the figure and returns the updated bounds. * * @param target * The figure to relocate */ public void relocate(IFigure target) { Dimension prefSize = target.getPreferredSize(); Point center = getReferencePoint(); target.translateToRelative(center); target.setBounds(getNewBounds(prefSize, center)); } /** * Sets the gap between the reference point and the figure being placed. * Only used if getRelativePosition() returns something other than * {@link PositionConstants#CENTER}. * * @param i * The gap * @since 2.0 */ public void setGap(int i) { gap = i; } /** * Sets the position of the figure with respect to the center point. * Possible values can be found in {@link PositionConstants} and include * CENTER, NORTH, SOUTH, EAST, WEST, NORTH_EAST, NORTH_WEST, SOUTH_EAST, or * SOUTH_WEST. * * @param pos * The relative position * @since 2.0 */ public void setRelativePosition(int pos) { relativePosition = pos; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/AbstractPointListShape.java000066400000000000000000000116751166301720600307370ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2008, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Alexander Shatalin (Borland) - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.Iterator; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.PointList; /** * Base superclass for all polylines/polygons * * @since 3.5 */ public abstract class AbstractPointListShape extends Shape { PointList points = new PointList(); /** * @see org.eclipse.draw2d.IFigure#containsPoint(int, int) */ public boolean containsPoint(int x, int y) { if (!super.containsPoint(x, y)) { return false; } return shapeContainsPoint(x, y) || childrenContainsPoint(x, y); } /** * Returns true if the point (x, y) is contained * within one of the child figures. * * @param x * The X coordinate * @param y * The Y coordinate * @return true if the point (x,y) is contained in one of the * child figures */ protected boolean childrenContainsPoint(int x, int y) { for (Iterator it = getChildren().iterator(); it.hasNext();) { IFigure nextChild = (IFigure) it.next(); if (nextChild.containsPoint(x, y)) { return true; } } return false; } /** * Returns true if the point (x, y) is contained * within this figure. * * @param x * The X coordinate * @param y * The Y coordinate * @return true if the point (x,y) is contained in this figure */ abstract protected boolean shapeContainsPoint(int x, int y); /** * Adds the passed point to this figure. * * @param pt * the Point to be added to this figure */ public void addPoint(Point pt) { points.addPoint(pt); repaint(); } /** * @return the first point in this figure */ public Point getStart() { return points.getFirstPoint(); } /** * Returns the last point in this Figure. * * @return the last point */ public Point getEnd() { return points.getLastPoint(); } /** * Returns the points in this figure by reference. If the returned * list is modified, this figure must be informed by calling * {@link #setPoints(PointList)}. Failure to do so will result in layout and * paint problems. * * @return this Polyline's points */ public PointList getPoints() { return points; } /** * Inserts a given point at a specified index in this figure. * * @param pt * the point to be added * @param index * the position in this figure where the point is to be added */ public void insertPoint(Point pt, int index) { points.insertPoint(pt, index); repaint(); } /** * Erases this figure and removes all of its {@link Point Points}. */ public void removeAllPoints() { erase(); points.removeAllPoints(); } /** * Removes a point from this figure. * * @param index * the position of the point to be removed */ public void removePoint(int index) { erase(); points.removePoint(index); repaint(); } /** * Sets the start point of this figure * * @param start * the point that will become the first point in this figure */ public void setStart(Point start) { if (points.size() == 0) { addPoint(start); } else { setPoint(start, 0); } } /** * Sets the end point of this figure * * @param end * the point that will become the last point in this figure */ public void setEnd(Point end) { if (points.size() < 2) { addPoint(end); } else { setPoint(end, points.size() - 1); } } /** * Sets the points at both extremes of this figure * * @param start * the point to become the first point in this figure * @param end * the point to become the last point in this figure */ public void setEndpoints(Point start, Point end) { setStart(start); setEnd(end); } /** * Sets the point at index to the Point pt. If * you're going to set multiple Points, use {@link #setPoints(PointList)}. * * @param pt * the point * @param index * the index */ public void setPoint(Point pt, int index) { erase(); points.setPoint(pt, index); repaint(); } /** * Sets the list of points to be used by this figure. Removes any previously * existing points. This figure will hold onto the given list by reference. * * @param points * new set of points */ public void setPoints(PointList points) { erase(); this.points = points; repaint(); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/AbstractRouter.java000066400000000000000000000064371166301720600273110ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Point; /** * Base class for implementing a connection router. This class provides stubs * for constraint usage, and some utility methods. */ public abstract class AbstractRouter implements ConnectionRouter { private static final Point START = new Point(); private static final Point END = new Point(); /** * Returns the constraint for the given Connection. * * @param connection * The connection * @return The constraint * @since 2.0 */ public Object getConstraint(Connection connection) { return null; } /** * A convenience method for obtaining a connection's endpoint. The * connection's endpoint is a point in absolute coordinates obtained by * using its source and target {@link ConnectionAnchor}. The returned Point * is a static singleton that is reused to reduce garbage collection. The * caller may modify this point in any way. However, the point will be * reused and its values overwritten during the next call to this method. * * @param connection * The connection * @return The endpoint * @since 2.0 */ protected Point getEndPoint(Connection connection) { Point ref = connection.getSourceAnchor().getReferencePoint(); return END.setLocation(connection.getTargetAnchor().getLocation(ref)); } /** * A convenience method for obtaining a connection's start point. The * connection's startpoint is a point in absolute coordinates obtained by * using its source and target {@link ConnectionAnchor}. The returned Point * is a static singleton that is reused to reduce garbage collection. The * caller may modify this point in any way. However, the point will be * reused and its values overwritten during the next call to this method. * * @param conn * The connection * @return The start point * @since 2.0 */ protected Point getStartPoint(Connection conn) { Point ref = conn.getTargetAnchor().getReferencePoint(); return START.setLocation(conn.getSourceAnchor().getLocation(ref)); } /** * Causes the router to discard any cached information about the given * Connection. * * @param connection * The connection to invalidate * @since 2.0 */ public void invalidate(Connection connection) { } /** * Removes the given Connection from this routers list of Connections it is * responsible for. * * @param connection * The connection to remove * @since 2.0 */ public void remove(Connection connection) { } /** * Sets the constraint for the given Connection. * * @param connection * The connection * @param constraint * The constraint * @since 2.0 */ public void setConstraint(Connection connection, Object constraint) { } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/AccessibleBase.java000066400000000000000000000023261166301720600271660ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; /** * The base class for accessible objects which provides accesibilty clients with * a unique ID. */ public class AccessibleBase { /** * Returns the id of this accessible object using {@link Object#hashCode()}. * * @return the id */ public final int getAccessibleID() { /* * This assumes that the native implementation of hashCode in Object is * to return the pointer to the Object, which should be U-unique. */ int value = super.hashCode(); /* * Values -3, -2, and -1 are reserved by SWT's ACC class to have special * meaning. Therefore, a child cannot have this value. */ if (value < 0) value -= 4; return value; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ActionEvent.java000066400000000000000000000027101166301720600265520ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; /** * An event that occurs as a result of an action being performed. */ public class ActionEvent extends java.util.EventObject { private String actionName; /** * Constructs a new ActionEvent with source as the source of the * event. * * @param source * The source of the event */ public ActionEvent(Object source) { super(source); } /** * Constructs a new ActionEvent with source as the source of the * event and name as the name of the action that was performed. * * @param source * The source of the event * @param name * The name of the action */ public ActionEvent(Object source, String name) { super(source); actionName = name; } /** * Returns the name of the action that was performed. * * @return String The name of the action */ public String getActionName() { return actionName; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ActionListener.java000066400000000000000000000014661166301720600272650ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; /** * A Listener interface for receiving {@link ActionEvent ActionEvents}. */ public interface ActionListener { /** * Called when the action occurs. * * @param event * The event */ void actionPerformed(ActionEvent event); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/AncestorHelper.java000066400000000000000000000121531166301720600272530ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; /** * A helper object which tracks the parent chain hierarchy. * * @since 2.1 */ class AncestorHelper implements PropertyChangeListener, FigureListener { /** * The base figure whose ancestor chain is being observed. */ protected final IFigure base; /** * The array of ancestor listeners. */ protected AncestorListener[] listeners; /** * Constructs a new helper on the given base figure and starts listening to * figure and property changes on the base figure's parent chain. When no * longer needed, the helper should be disposed. * * @since 2.1 * @param baseFigure */ public AncestorHelper(IFigure baseFigure) { this.base = baseFigure; addAncestors(baseFigure); } /** * Appends a new listener to the list of listeners. * * @param listener * the listener */ public void addAncestorListener(AncestorListener listener) { if (listeners == null) { listeners = new AncestorListener[1]; listeners[0] = listener; } else { int oldSize = listeners.length; AncestorListener newListeners[] = new AncestorListener[oldSize + 1]; System.arraycopy(listeners, 0, newListeners, 0, oldSize); newListeners[oldSize] = listener; listeners = newListeners; } } /** * Hooks up internal listeners used for maintaining the proper figure * listeners. * * @param rootFigure * the root figure */ protected void addAncestors(IFigure rootFigure) { for (IFigure ancestor = rootFigure; ancestor != null; ancestor = ancestor .getParent()) { ancestor.addFigureListener(this); ancestor.addPropertyChangeListener("parent", this); //$NON-NLS-1$ } } /** * Removes all internal listeners. */ public void dispose() { removeAncestors(base); listeners = null; } /** * @see org.eclipse.draw2d.FigureListener#figureMoved(org.eclipse.draw2d.IFigure) */ public void figureMoved(IFigure ancestor) { fireAncestorMoved(ancestor); } /** * Fires notification to the listener list * * @param ancestor * the figure which moved */ protected void fireAncestorMoved(IFigure ancestor) { if (listeners == null) return; for (int i = 0; i < listeners.length; i++) listeners[i].ancestorMoved(ancestor); } /** * Fires notification to the listener list * * @param ancestor * the figure which moved */ protected void fireAncestorAdded(IFigure ancestor) { if (listeners == null) return; for (int i = 0; i < listeners.length; i++) listeners[i].ancestorAdded(ancestor); } /** * Fires notification to the listener list * * @param ancestor * the figure which moved */ protected void fireAncestorRemoved(IFigure ancestor) { if (listeners == null) return; for (int i = 0; i < listeners.length; i++) listeners[i].ancestorRemoved(ancestor); } /** * Returns the total number of listeners. * * @return the number of listeners */ public boolean isEmpty() { return listeners == null; } /** * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent event) { if (event.getPropertyName().equals("parent")) { //$NON-NLS-1$ IFigure oldParent = (IFigure) event.getOldValue(); IFigure newParent = (IFigure) event.getNewValue(); if (oldParent != null) { removeAncestors(oldParent); fireAncestorRemoved(oldParent); } if (newParent != null) { addAncestors(newParent); fireAncestorAdded(newParent); } } } /** * Removes the first occurence of the given listener * * @param listener * the listener to remove */ public void removeAncestorListener(AncestorListener listener) { if (listeners == null) return; for (int index = 0; index < listeners.length; index++) if (listeners[index] == listener) { int newSize = listeners.length - 1; AncestorListener newListeners[] = null; if (newSize != 0) { newListeners = new AncestorListener[newSize]; System.arraycopy(listeners, 0, newListeners, 0, index); System.arraycopy(listeners, index + 1, newListeners, index, newSize - index); } listeners = newListeners; return; } } /** * Unhooks listeners starting at the given figure * * @param rootFigure */ protected void removeAncestors(IFigure rootFigure) { for (IFigure ancestor = rootFigure; ancestor != null; ancestor = ancestor .getParent()) { ancestor.removeFigureListener(this); ancestor.removePropertyChangeListener("parent", this); //$NON-NLS-1$ } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/AncestorListener.java000066400000000000000000000036121166301720600276210ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; /** * Classes which implement this interface provide methods to respond to changes * in the ancestor properties of a Figure. *

* Instances of this class can be added as listeners to a figure using the * addAncestorListener method and removed using the * removeAncestoreListener method. When the parent chain of the * figure being observed changes or moves, the listener will be notified * appropriately. */ public interface AncestorListener { /** * Called when an ancestor has been added into the listening figure's * hierarchy. * * @param ancestor * The ancestor that was added */ void ancestorAdded(IFigure ancestor); /** * Called when an ancestor has moved to a new location. * * @param ancestor * The ancestor that has moved */ void ancestorMoved(IFigure ancestor); /** * Called when an ancestor has been removed from the listening figure's * hierarchy. * * @param ancestor * The ancestor that has been removed */ void ancestorRemoved(IFigure ancestor); /** * An empty implementation of AncestorListener for convenience. */ class Stub implements AncestorListener { public void ancestorMoved(IFigure ancestor) { } public void ancestorAdded(IFigure ancestor) { } public void ancestorRemoved(IFigure ancestor) { } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/AnchorListener.java000066400000000000000000000020671166301720600272600ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; /** * Classes which implement this interface provide a method to notify that an * anchor has moved. *

* Instances of this class can be added as listeners of an Anchor using the * addAnchorListener method and removed using the * removeAnchorListener method. */ public interface AnchorListener { /** * Called when an anchor has moved to a new location. * * @param anchor * The anchor that has moved. */ void anchorMoved(ConnectionAnchor anchor); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/Animation.java000066400000000000000000000172621166301720600262620ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2005, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Set; /** * A utility for coordinating figure animations. During animation, multiple * animators are employed to capture the initial and * final states for one or more figures. The animators then playback * the animation by interpolating the intermediate states for each figure using * the initial and final "keyframes". *

* An animator is usually stateless and represents an specific technique. Any * state information is stored by the Animation utility. Therefore, one instance * can be used with multiple figures. Animators hook into the validation * mechanism for figures and connections. These hooks are used to capture the * states, and to intercept the typical layout process to insert the * interpolated state. *

* To indicate that animation is desired, clients must call {@link #markBegin()} * prior to invalidating any figures that are to be included in the animation. * After this method is called, changes are made, and {@link #run()} is invoked. * The run method will force a validation pass to capture the final states, and * then commence the animation. The animation is synchronous and the method does * not return until the animation has completed. * * @see LayoutAnimator * @since 3.2 */ public class Animation { static class AnimPair { final Animator animator; final IFigure figure; AnimPair(Animator animator, IFigure figure) { this.animator = animator; this.figure = figure; } public boolean equals(Object obj) { AnimPair pair = (AnimPair) obj; return pair.animator == animator && pair.figure == figure; } public int hashCode() { return animator.hashCode() ^ figure.hashCode(); } } private static final int DEFAULT_DELAY = 250; private static Set figureAnimators; private static Map finalStates; private static Map initialStates; private static final int PLAYBACK = 3; private static float progress; private static final int RECORD_FINAL = 2; private static final int RECORD_INITIAL = 1; private static long startTime; private static int state; private static Set toCapture; private static UpdateManager updateManager; private static void capture() { Iterator keys = figureAnimators.iterator(); while (keys.hasNext()) { AnimPair pair = (AnimPair) keys.next(); if (toCapture.contains(pair)) pair.animator.capture(pair.figure); else keys.remove(); } } static void cleanup() { if (figureAnimators != null) { Iterator keys = figureAnimators.iterator(); while (keys.hasNext()) { AnimPair pair = (AnimPair) keys.next(); pair.animator.tearDown(pair.figure); } } state = 0; step(); // Allow layout to occur normally // updateManager.performUpdate(); initialStates = null; finalStates = null; figureAnimators = null; updateManager = null; toCapture = null; state = 0; } private static void doRun(int duration) { state = RECORD_FINAL; findUpdateManager(); updateManager.performValidation(); capture(); state = PLAYBACK; progress = 0.1f; startTime = System.currentTimeMillis(); notifyPlaybackStarting(); while (progress != 0) { step(); updateManager.performUpdate(); if (progress == 1.0) progress = 0; else { int delta = (int) (System.currentTimeMillis() - startTime); if (delta >= duration) progress = 1f; else progress = 0.1f + 0.9f * delta / duration; } } } private static void findUpdateManager() { AnimPair pair = (AnimPair) figureAnimators.iterator().next(); updateManager = pair.figure.getUpdateManager(); } /** * Returns the final animation state for the given figure. * * @param animator * the animator for the figure * @param figure * the figure being animated * @return the final state * @since 3.2 */ public static Object getFinalState(Animator animator, IFigure figure) { return finalStates.get(new AnimPair(animator, figure)); } /** * Returns the initial animation state for the given animator and figure. If * no state was recorded, null is returned. * * @param animator * the animator for the figure * @param figure * the figure being animated * @return the initial state * @since 3.2 */ public static Object getInitialState(Animator animator, IFigure figure) { return initialStates.get(new AnimPair(animator, figure)); } /** * Returns the animation progress, where 0.0 < progress ≤ 1.0. * * @return the progress of the animation * @since 3.2 */ public static float getProgress() { return progress; } static void hookAnimator(IFigure figure, Animator animator) { AnimPair pair = new AnimPair(animator, figure); if (figureAnimators.add(pair)) animator.init(figure); } static void hookNeedsCapture(IFigure figure, Animator animator) { AnimPair pair = new AnimPair(animator, figure); if (figureAnimators.contains(pair)) toCapture.add(pair); } static boolean hookPlayback(IFigure figure, Animator animator) { if (toCapture.contains(new AnimPair(animator, figure))) return animator.playback(figure); return false; } /** * Returns true if animation is in progress. * * @return true when animating * @since 3.2 */ public static boolean isAnimating() { return state == PLAYBACK; } static boolean isFinalRecording() { return state == RECORD_FINAL; } static boolean isInitialRecording() { return state == RECORD_INITIAL; } /** * Marks the beginning of the animation process. If the beginning has * already been marked, this has no effect. * * @return returns true if beginning was not previously marked * @since 3.2 */ public static boolean markBegin() { if (state == 0) { state = RECORD_INITIAL; initialStates = new HashMap(); finalStates = new HashMap(); figureAnimators = new HashSet(); toCapture = new HashSet(); return true; } return false; } private static void notifyPlaybackStarting() { Iterator keys = figureAnimators.iterator(); while (keys.hasNext()) { AnimPair pair = (AnimPair) keys.next(); pair.animator.playbackStarting(pair.figure); } } static void putFinalState(Animator animator, IFigure key, Object state) { finalStates.put(new AnimPair(animator, key), state); } static void putInitialState(Animator animator, IFigure key, Object state) { initialStates.put(new AnimPair(animator, key), state); } /** * Runs animation using the recommended duration: 250 milliseconds. * * @see #run(int) * @since 3.2 */ public static void run() { run(DEFAULT_DELAY); } /** * Captures the final states for the animation and then plays the animation. * * @param duration * the length of animation in milliseconds * @since 3.2 */ public static void run(int duration) { if (state == 0) return; try { if (!figureAnimators.isEmpty()) doRun(duration); } finally { cleanup(); } } private static void step() { Iterator iter = initialStates.keySet().iterator(); while (iter.hasNext()) ((AnimPair) iter.next()).figure.revalidate(); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/Animator.java000066400000000000000000000067201166301720600261120ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2005, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; /** * Animates some aspect of a figure. Each animator will capture some of the * effects of validation of the figures. *

* Animators must be hooked to figure in special ways. Refer to each * implementation for the specific requirements. Animators are generally * stateless, which allows them to be shared and prevents them from leaking * memory. * * @since 3.2 */ public abstract class Animator { Animator() { } /** * Captures the final state of the given figure. This method is called once * after the update manager has completed validation of all invalid figures. * * @param figure * the container * @since 3.2 */ public void capture(IFigure figure) { recordFinalState(figure); } /** * Returns an object encapsulating the current state of the figure. This * method is called to capture both the initial and final states. * * @param figure * the figure * @return the current state * @since 3.2 */ protected abstract Object getCurrentState(IFigure figure); /** * Plays back the animation for the given figure and returns * true if successful. This method does nothing by default and * return false. * * @param figure * the figure being animated * @return true if playback was successful * @since 3.2 */ protected boolean playback(IFigure figure) { return false; } /** * Sent as playback is starting for a given figure. * * @param figure * the figure * @since 3.2 */ public void playbackStarting(IFigure figure) { } /** * Records the final state information for a figure. * * @param figure * the figure * @since 3.2 */ protected void recordFinalState(IFigure figure) { Animation.putFinalState(this, figure, getCurrentState(figure)); } /** * Records initial state information for the given figure. * * @param figure * the container. * @since 3.2 */ protected void recordInitialState(IFigure figure) { Animation.putInitialState(this, figure, getCurrentState(figure)); } /** * Sets up the animator for the given figure to be animated. This method is * called exactly once time prior to any layouts happening. The animator can * capture the figure's current state, and set any animation-time settings * for the figure. Changes made to the figure should be reverted in * {@link #tearDown(IFigure)}. * * @param figure * the animated figure * @since 3.2 */ public void init(IFigure figure) { recordInitialState(figure); } /** * Reverts any temporary changes made to the figure during animation. This * method is called exactly once after all animation has been completed. * Subclasses should extend this method to revert any changes. * * @param figure * the animated figure * @since 3.2 * @see #init(IFigure) */ public void tearDown(IFigure figure) { } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ArrowButton.java000066400000000000000000000040471166301720600266260ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Insets; /** * A Button which displays a triangle pointing in a specified direction. This * class is used by the {@link ScrollBar} figure. */ public class ArrowButton extends Button implements Orientable { { createTriangle(); setRequestFocusEnabled(false); setFocusTraversable(false); } /** * Constructs a default ArrowButton with the arrow pointing north. * * @since 2.0 */ public ArrowButton() { } /** * Constructs an ArrowButton with the arrow having the direction given in * the input. The direction can be one of many directional constants defined * in {@link PositionConstants}. * * @param direction * Direction of the arrow * @since 2.0 */ public ArrowButton(int direction) { setDirection(direction); } /** * Contructs a triangle with a black background pointing north, and sets it * as the contents of the button. * * @since 2.0 */ protected void createTriangle() { Triangle tri = new Triangle(); tri.setOutline(true); tri.setBackgroundColor(ColorConstants.listForeground); tri.setForegroundColor(ColorConstants.listForeground); tri.setBorder(new MarginBorder(new Insets(2))); setContents(tri); } /** * @see org.eclipse.draw2d.Orientable#setDirection(int) */ public void setDirection(int value) { setChildrenDirection(value); } /** * @see org.eclipse.draw2d.Orientable#setOrientation(int) */ public void setOrientation(int value) { setChildrenOrientation(value); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ArrowLocator.java000066400000000000000000000037041166301720600267550ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.PointList; /** * Locator used to place a {@link RotatableDecoration} on a {@link Connection}. * The decoration can be placed at the source or target end of the connection * figure. The default connection implementation uses a {@link DelegatingLayout} * which requires locators. */ public class ArrowLocator extends ConnectionLocator { /** * Constructs an ArrowLocator associated with passed connection and tip * location (either {@link ConnectionLocator#SOURCE} or * {@link ConnectionLocator#TARGET}). * * @param connection * The connection associated with the locator * @param location * Location of the arrow decoration * @since 2.0 */ public ArrowLocator(Connection connection, int location) { super(connection, location); } /** * Relocates the passed in figure (which must be a * {@link RotatableDecoration}) at either the start or end of the * connection. * * @param target * The RotatableDecoration to relocate */ public void relocate(IFigure target) { PointList points = getConnection().getPoints(); RotatableDecoration arrow = (RotatableDecoration) target; arrow.setLocation(getLocation(points)); if (getAlignment() == SOURCE) arrow.setReferencePoint(points.getPoint(1)); else if (getAlignment() == TARGET) arrow.setReferencePoint(points.getPoint(points.size() - 2)); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/AutomaticRouter.java000066400000000000000000000144241166301720600274670ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.ArrayList; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.PointList; import org.eclipse.draw2d.internal.MultiValueMap; /** * An abstract router implementation which detects when multiple connections are * overlapping. Two connections overlap if the combination of source and target * anchors are equal. Subclasses must implement * {@link #handleCollision(PointList, int)} to determine how to avoid the * overlap. *

* This router can delegate to another connection router. The wrappered router * will route the connections first, after which overlapping will be determined. */ public abstract class AutomaticRouter extends AbstractRouter { private ConnectionRouter nextRouter; private MultiValueMap connections = new MultiValueMap(); private class HashKey { private ConnectionAnchor anchor1, anchor2; HashKey(Connection conn) { anchor1 = conn.getSourceAnchor(); anchor2 = conn.getTargetAnchor(); } public boolean equals(Object object) { boolean isEqual = false; HashKey hashKey; if (object instanceof HashKey) { hashKey = (HashKey) object; ConnectionAnchor hkA1 = hashKey.getFirstAnchor(); ConnectionAnchor hkA2 = hashKey.getSecondAnchor(); isEqual = (hkA1.equals(anchor1) && hkA2.equals(anchor2)) || (hkA1.equals(anchor2) && hkA2.equals(anchor1)); } return isEqual; } public ConnectionAnchor getFirstAnchor() { return anchor1; } public ConnectionAnchor getSecondAnchor() { return anchor2; } public int hashCode() { return anchor1.hashCode() ^ anchor2.hashCode(); } } /** * @see org.eclipse.draw2d.ConnectionRouter#getConstraint(Connection) */ public Object getConstraint(Connection connection) { if (next() != null) return next().getConstraint(connection); return null; } /** * Handles collisions between 2 or more Connections. Collisions are * currently defined as 2 connections with no bendpoints and whose start and * end points coincide. In other words, the 2 connections are the exact same * line. * * @param list * The PointList of a connection that collides with another * connection * @param index * The index of the current connection in the list of colliding * connections */ protected abstract void handleCollision(PointList list, int index); /** * @see org.eclipse.draw2d.ConnectionRouter#invalidate(Connection) */ public void invalidate(Connection conn) { if (next() != null) next().invalidate(conn); if (conn.getSourceAnchor() == null || conn.getTargetAnchor() == null) return; HashKey connectionKey = new HashKey(conn); ArrayList connectionList = connections.get(connectionKey); int affected = connections.remove(connectionKey, conn); if (affected != -1) { for (int i = affected; i < connectionList.size(); i++) ((Connection) connectionList.get(i)).revalidate(); } else connections.removeValue(conn); } /** * Returns the next router in the chain. * * @return The next router * @since 2.0 */ protected ConnectionRouter next() { return nextRouter; } /** * @see org.eclipse.draw2d.ConnectionRouter#remove(Connection) */ public void remove(Connection conn) { if (conn.getSourceAnchor() == null || conn.getTargetAnchor() == null) return; HashKey connectionKey = new HashKey(conn); ArrayList connectionList = connections.get(connectionKey); if (connectionList != null) { int index = connections.remove(connectionKey, conn); for (int i = index + 1; i < connectionList.size(); i++) ((Connection) connectionList.get(i)).revalidate(); } if (next() != null) next().remove(conn); } /** * Routes the given connection. Calls the 'next' router first (if one * exists) and if no bendpoints were added by the next router, collisions * are dealt with by calling {@link #handleCollision(PointList, int)}. * * @param conn * The connection to route */ public void route(Connection conn) { if (next() != null) next().route(conn); else { conn.getPoints().removeAllPoints(); setEndPoints(conn); } if (conn.getPoints().size() == 2) { PointList points = conn.getPoints(); HashKey connectionKey = new HashKey(conn); ArrayList connectionList = connections.get(connectionKey); if (connectionList != null) { int index; if (connectionList.contains(conn)) { index = connectionList.indexOf(conn) + 1; } else { index = connectionList.size() + 1; connections.put(connectionKey, conn); } handleCollision(points, index); conn.setPoints(points); } else { connections.put(connectionKey, conn); } } } /** * An AutomaticRouter needs no constraints for the connections it routes. * This method invalidates the connections and calls * {@link #setConstraint(Connection, Object)} on the {@link #next()} router. * * @see org.eclipse.draw2d.ConnectionRouter#setConstraint(Connection, * Object) */ public void setConstraint(Connection connection, Object constraint) { invalidate(connection); if (next() != null) next().setConstraint(connection, constraint); } /** * Sets the start and end points for the given connection. * * @param conn * The connection */ protected void setEndPoints(Connection conn) { PointList points = conn.getPoints(); points.removeAllPoints(); Point start = getStartPoint(conn); Point end = getEndPoint(conn); conn.translateToRelative(start); conn.translateToRelative(end); points.addPoint(start); points.addPoint(end); conn.setPoints(points); } /** * Sets the next router. * * @param router * The ConnectionRouter * @since 2.0 */ public void setNextRouter(ConnectionRouter router) { nextRouter = router; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/Bendpoint.java000066400000000000000000000025431166301720600262610ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Point; /** * A helper used to calculate the point at which a * {@link org.eclipse.draw2d.Connection} should bend. A bendpoint returns a * point relative to the connection figure on which it is being used. * This was chosen so that fixed bendpoints would be easy to implement. A fixed * bendpoint will have a fixed x and y value. Although the absolute x and y * location change during zoom and scrolling, the relative values stay the same. */ public interface Bendpoint { /** * Returns the location of the bendpoint relative to the * connection. The returned value may be by reference. The caller should NOT * modify the returned value. * * @return the location of the bendpoint relative to the Connection */ Point getLocation(); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/BendpointConnectionRouter.java000066400000000000000000000061701166301720600315020ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.PointList; import org.eclipse.draw2d.geometry.PrecisionPoint; /** * Routes {@link Connection}s through a List of {@link Bendpoint * Bendpoints}. */ public class BendpointConnectionRouter extends AbstractRouter { private Map constraints = new HashMap(11); private static final PrecisionPoint A_POINT = new PrecisionPoint(); /** * Gets the constraint for the given {@link Connection}. * * @param connection * The connection whose constraint we are retrieving * @return The constraint */ public Object getConstraint(Connection connection) { return constraints.get(connection); } /** * Removes the given connection from the map of constraints. * * @param connection * The connection to remove */ public void remove(Connection connection) { constraints.remove(connection); } /** * Routes the {@link Connection}. Expects the constraint to be a List of * {@link org.eclipse.draw2d.Bendpoint Bendpoints}. * * @param conn * The connection to route */ public void route(Connection conn) { PointList points = conn.getPoints(); points.removeAllPoints(); List bendpoints = (List) getConstraint(conn); if (bendpoints == null) bendpoints = Collections.EMPTY_LIST; Point ref1, ref2; if (bendpoints.isEmpty()) { ref1 = conn.getTargetAnchor().getReferencePoint(); ref2 = conn.getSourceAnchor().getReferencePoint(); } else { ref1 = new Point(((Bendpoint) bendpoints.get(0)).getLocation()); conn.translateToAbsolute(ref1); ref2 = new Point( ((Bendpoint) bendpoints.get(bendpoints.size() - 1)) .getLocation()); conn.translateToAbsolute(ref2); } A_POINT.setLocation(conn.getSourceAnchor().getLocation(ref1)); conn.translateToRelative(A_POINT); points.addPoint(A_POINT); for (int i = 0; i < bendpoints.size(); i++) { Bendpoint bp = (Bendpoint) bendpoints.get(i); points.addPoint(bp.getLocation()); } A_POINT.setLocation(conn.getTargetAnchor().getLocation(ref2)); conn.translateToRelative(A_POINT); points.addPoint(A_POINT); conn.setPoints(points); } /** * Sets the constraint for the given {@link Connection}. * * @param connection * The connection whose constraint we are setting * @param constraint * The constraint */ public void setConstraint(Connection connection, Object constraint) { constraints.put(connection, constraint); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/BendpointLocator.java000066400000000000000000000037101166301720600276020ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Point; /** * Places a figure relative to a specified bend in a {@link Connection}. A * bendpoint is one of the points returned in the connection's * {@link Connection#getPoints()} method. It is not related to the bendpoint * class used as routing constraints. */ public class BendpointLocator extends ConnectionLocator { private int index; /** * Creates a BendpointLocator associated with passed Connection c and index * i. * * @param c * Connection associated with BendpointLocator * @param i * Index of bendpoint, represents the position of the bendpoint * on Connection c * @since 2.0 */ public BendpointLocator(Connection c, int i) { super(c); index = i; } /** * Returns the index of this BendpointLocator. This index is the position of * the reference point in this BendpointLocator's {@link Connection}. * * @return The index * @since 2.0 */ protected int getIndex() { return index; } /** * Returns reference point associated with the BendpointLocator. This Point * is taken from the BendpointLocator's connection and is point number * 'index'. * * @return The reference point * @since 2.0 */ protected Point getReferencePoint() { Point p = getConnection().getPoints().getPoint(Point.SINGLETON, getIndex()); getConnection().translateToAbsolute(p); return p; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/Border.java000066400000000000000000000045561166301720600255620ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Insets; import org.eclipse.draw2d.geometry.Rectangle; /** * A decoration on a Figure. A border may paint itself within the bounds of a * figure, and it may provide Insets which can affect how the figures children * are posiiton and painted. *

* A border instance may be used with multiple figure instances. */ public interface Border { /** * Returns the Insets for this Border for the given Figure. * * @param figure * The figure this border belongs to * @return The insets */ Insets getInsets(IFigure figure); /** * Returns the preferred width and height that this border would like to * display itself properly. * * @param figure * The figure * @return The preferred size */ Dimension getPreferredSize(IFigure figure); /** * Returns true if the Border completely fills the region * defined in {@link #paint(IFigure, Graphics, Insets)}. * * @return true if this border is opaque */ boolean isOpaque(); /** * Paints the border. The border should paint inside figure's * {@link IFigure#getBounds()}, inset by the parameter insets. The * border generally should not paint inside its own insets. More * specifically, Border b should paint inside the rectangle: * figure.getBounds().getCropped(insets) and outside of the rectangle: * figure.getBounds().getCropped(insets).getCropped(getInsets()) where * inside is defined as {@link Rectangle#contains(int, int)}. * * @param figure * The figure this border belongs to * @param graphics * The graphics object used for painting * @param insets * The insets */ void paint(IFigure figure, Graphics graphics, Insets insets); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/BorderLayout.java000066400000000000000000000232011166301720600267440ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Insets; import org.eclipse.draw2d.geometry.Rectangle; /** * @author Pratik Shah */ public class BorderLayout extends AbstractHintLayout { /** * Constant to be used as a constraint for child figures */ public static final Integer CENTER = new Integer(PositionConstants.CENTER); /** * Constant to be used as a constraint for child figures */ public static final Integer TOP = new Integer(PositionConstants.TOP); /** * Constant to be used as a constraint for child figures */ public static final Integer BOTTOM = new Integer(PositionConstants.BOTTOM); /** * Constant to be used as a constraint for child figures */ public static final Integer LEFT = new Integer(PositionConstants.LEFT); /** * Constant to be used as a constraint for child figures */ public static final Integer RIGHT = new Integer(PositionConstants.RIGHT); private IFigure center, left, top, bottom, right; private int vGap = 0, hGap = 0; /** * @see org.eclipse.draw2d.AbstractHintLayout#calculateMinimumSize(IFigure, * int, int) */ protected Dimension calculateMinimumSize(IFigure container, int wHint, int hHint) { int minWHint = 0, minHHint = 0; if (wHint < 0) { minWHint = -1; } if (hHint < 0) { minHHint = -1; } Insets border = container.getInsets(); wHint = Math.max(minWHint, wHint - border.getWidth()); hHint = Math.max(minHHint, hHint - border.getHeight()); Dimension minSize = new Dimension(); int middleRowWidth = 0, middleRowHeight = 0; int rows = 0, columns = 0; if (top != null && top.isVisible()) { Dimension childSize = top.getMinimumSize(wHint, hHint); hHint = Math.max(minHHint, hHint - (childSize.height + vGap)); minSize.setSize(childSize); rows += 1; } if (bottom != null && bottom.isVisible()) { Dimension childSize = bottom.getMinimumSize(wHint, hHint); hHint = Math.max(minHHint, hHint - (childSize.height + vGap)); minSize.width = Math.max(minSize.width, childSize.width); minSize.height += childSize.height; rows += 1; } if (left != null && left.isVisible()) { Dimension childSize = left.getMinimumSize(wHint, hHint); middleRowWidth = childSize.width; middleRowHeight = childSize.height; wHint = Math.max(minWHint, wHint - (childSize.width + hGap)); columns += 1; } if (right != null && right.isVisible()) { Dimension childSize = right.getMinimumSize(wHint, hHint); middleRowWidth += childSize.width; middleRowHeight = Math.max(childSize.height, middleRowHeight); wHint = Math.max(minWHint, wHint - (childSize.width + hGap)); columns += 1; } if (center != null && center.isVisible()) { Dimension childSize = center.getMinimumSize(wHint, hHint); middleRowWidth += childSize.width; middleRowHeight = Math.max(childSize.height, middleRowHeight); columns += 1; } rows += columns > 0 ? 1 : 0; // Add spacing, insets, and the size of the middle row minSize.height += middleRowHeight + border.getHeight() + ((rows - 1) * vGap); minSize.width = Math.max(minSize.width, middleRowWidth) + border.getWidth() + ((columns - 1) * hGap); return minSize; } /** * @see AbstractLayout#calculatePreferredSize(IFigure, int, int) */ protected Dimension calculatePreferredSize(IFigure container, int wHint, int hHint) { int minWHint = 0, minHHint = 0; if (wHint < 0) minWHint = -1; if (hHint < 0) minHHint = -1; Insets border = container.getInsets(); wHint = Math.max(minWHint, wHint - border.getWidth()); hHint = Math.max(minHHint, hHint - border.getHeight()); Dimension prefSize = new Dimension(); int middleRowWidth = 0, middleRowHeight = 0; int rows = 0, columns = 0; if (top != null && top.isVisible()) { Dimension childSize = top.getPreferredSize(wHint, hHint); hHint = Math.max(minHHint, hHint - (childSize.height + vGap)); prefSize.setSize(childSize); rows += 1; } if (bottom != null && bottom.isVisible()) { Dimension childSize = bottom.getPreferredSize(wHint, hHint); hHint = Math.max(minHHint, hHint - (childSize.height + vGap)); prefSize.width = Math.max(prefSize.width, childSize.width); prefSize.height += childSize.height; rows += 1; } if (left != null && left.isVisible()) { Dimension childSize = left.getPreferredSize(wHint, hHint); middleRowWidth = childSize.width; middleRowHeight = childSize.height; wHint = Math.max(minWHint, wHint - (childSize.width + hGap)); columns += 1; } if (right != null && right.isVisible()) { Dimension childSize = right.getPreferredSize(wHint, hHint); middleRowWidth += childSize.width; middleRowHeight = Math.max(childSize.height, middleRowHeight); wHint = Math.max(minWHint, wHint - (childSize.width + hGap)); columns += 1; } if (center != null && center.isVisible()) { Dimension childSize = center.getPreferredSize(wHint, hHint); middleRowWidth += childSize.width; middleRowHeight = Math.max(childSize.height, middleRowHeight); columns += 1; } rows += columns > 0 ? 1 : 0; // Add spacing, insets, and the size of the middle row prefSize.height += middleRowHeight + border.getHeight() + ((rows - 1) * vGap); prefSize.width = Math.max(prefSize.width, middleRowWidth) + border.getWidth() + ((columns - 1) * hGap); return prefSize; } /** * @see org.eclipse.draw2d.LayoutManager#layout(IFigure) */ public void layout(IFigure container) { Rectangle area = container.getClientArea(); Rectangle rect = new Rectangle(); Dimension childSize; if (top != null && top.isVisible()) { childSize = top.getPreferredSize(area.width, -1); rect.setLocation(area.x, area.y); rect.setSize(childSize); rect.width = area.width; top.setBounds(rect); area.y += rect.height + vGap; area.height -= rect.height + vGap; } if (bottom != null && bottom.isVisible()) { childSize = bottom.getPreferredSize(Math.max(area.width, 0), -1); rect.setSize(childSize); rect.width = area.width; rect.setLocation(area.x, area.y + area.height - rect.height); bottom.setBounds(rect); area.height -= rect.height + vGap; } if (left != null && left.isVisible()) { childSize = left.getPreferredSize(-1, Math.max(0, area.height)); rect.setLocation(area.x, area.y); rect.width = childSize.width; rect.height = Math.max(0, area.height); left.setBounds(rect); area.x += rect.width + hGap; area.width -= rect.width + hGap; } if (right != null && right.isVisible()) { childSize = right.getPreferredSize(-1, Math.max(0, area.height)); rect.width = childSize.width; rect.height = Math.max(0, area.height); rect.setLocation(area.x + area.width - rect.width, area.y); right.setBounds(rect); area.width -= rect.width + hGap; } if (center != null && center.isVisible()) { if (area.width < 0) area.width = 0; if (area.height < 0) area.height = 0; center.setBounds(area); } } /** * @see org.eclipse.draw2d.AbstractLayout#remove(IFigure) */ public void remove(IFigure child) { if (center == child) { center = null; } else if (top == child) { top = null; } else if (bottom == child) { bottom = null; } else if (right == child) { right = null; } else if (left == child) { left = null; } } /** * Sets the location of hte given child in this layout. Valid constraints: *

    *
  • {@link #CENTER}
  • *
  • {@link #TOP}
  • *
  • {@link #BOTTOM}
  • *
  • {@link #LEFT}
  • *
  • {@link #RIGHT}
  • *
  • null (to remove a child's constraint)
  • *
* *

* Ensure that the given Figure is indeed a child of the Figure on which * this layout has been set. Proper behaviour cannot be guaranteed if that * is not the case. Also ensure that every child has a valid constraint. *

*

* Passing a null constraint will invoke * {@link #remove(IFigure)}. *

*

* If the given child was assigned another constraint earlier, it will be * re-assigned to the new constraint. If there is another child with the * given constraint, it will be over-ridden so that the given child now has * that constraint. *

* * @see org.eclipse.draw2d.AbstractLayout#setConstraint(IFigure, Object) */ public void setConstraint(IFigure child, Object constraint) { remove(child); super.setConstraint(child, constraint); if (constraint == null) { return; } switch (((Integer) constraint).intValue()) { case PositionConstants.CENTER: center = child; break; case PositionConstants.TOP: top = child; break; case PositionConstants.BOTTOM: bottom = child; break; case PositionConstants.RIGHT: right = child; break; case PositionConstants.LEFT: left = child; break; default: break; } } /** * Sets the horizontal spacing to be used between the children. Default is * 0. * * @param gap * The horizonal spacing */ public void setHorizontalSpacing(int gap) { hGap = gap; } /** * Sets the vertical spacing ot be used between the children. Default is 0. * * @param gap * The vertical spacing */ public void setVerticalSpacing(int gap) { vGap = gap; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/BufferedGraphicsSource.java000066400000000000000000000076751166301720600307360ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.SWT; import org.eclipse.swt.SWTError; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Caret; import org.eclipse.swt.widgets.Control; import org.eclipse.draw2d.geometry.Rectangle; class BufferedGraphicsSource implements GraphicsSource { private Image imageBuffer; private GC imageGC; private GC controlGC; private Control control; private Rectangle inUse; /** * Constructs a new buffered graphics source using the given control. * * @since 2.1 * @param c * the control */ public BufferedGraphicsSource(Control c) { control = c; } /** * @see org.eclipse.draw2d.GraphicsSource#flushGraphics(org.eclipse.draw2d.geometry.Rectangle) */ public void flushGraphics(Rectangle region) { if (inUse.isEmpty()) return; boolean restoreCaret = false; Canvas canvas = null; if (control instanceof Canvas) { canvas = (Canvas) control; Caret caret = canvas.getCaret(); if (caret != null) restoreCaret = caret.isVisible(); if (restoreCaret) caret.setVisible(false); } /* * The imageBuffer may be null if double-buffering was not successful. */ if (imageBuffer != null) { imageGC.dispose(); controlGC.drawImage(getImage(), 0, 0, inUse.width, inUse.height, inUse.x, inUse.y, inUse.width, inUse.height); imageBuffer.dispose(); imageBuffer = null; imageGC = null; } controlGC.dispose(); controlGC = null; if (restoreCaret) canvas.getCaret().setVisible(true); } /** * @see org.eclipse.draw2d.GraphicsSource#getGraphics(org.eclipse.draw2d.geometry.Rectangle) */ public Graphics getGraphics(Rectangle region) { if (control == null || control.isDisposed()) return null; org.eclipse.swt.graphics.Point ptSWT = control.getSize(); inUse = new Rectangle(0, 0, ptSWT.x, ptSWT.y); inUse.intersect(region); if (inUse.isEmpty()) return null; /* * Bugzilla 53632 - Attempts to create large images on some platforms * will fail. When this happens, do not use double-buffering for * painting. */ try { imageBuffer = new Image(null, inUse.width, inUse.height); } catch (SWTError noMoreHandles) { imageBuffer = null; } catch (IllegalArgumentException tooBig) { imageBuffer = null; } controlGC = new GC(control, control.getStyle() & (SWT.RIGHT_TO_LEFT | SWT.LEFT_TO_RIGHT)); Graphics graphics; if (imageBuffer != null) { imageGC = new GC(imageBuffer, control.getStyle() & (SWT.RIGHT_TO_LEFT | SWT.LEFT_TO_RIGHT)); imageGC.setBackground(controlGC.getBackground()); imageGC.setForeground(controlGC.getForeground()); imageGC.setFont(controlGC.getFont()); imageGC.setLineStyle(controlGC.getLineStyle()); imageGC.setLineWidth(controlGC.getLineWidth()); imageGC.setXORMode(controlGC.getXORMode()); graphics = new SWTGraphics(imageGC); graphics.translate(inUse.getLocation().negate()); } else { graphics = new SWTGraphics(controlGC); } graphics.setClip(inUse); return graphics; } /** * Returns the current image buffer or null. * * @since 2.1 * @return the current image buffer */ protected Image getImage() { return imageBuffer; } /** * Returns the current GC used on the buffer or null. * * @since 2.1 * @return the GC for the image buffer */ protected GC getImageGC() { return imageGC; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/Button.java000066400000000000000000000036051166301720600256120ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.graphics.Image; /** * A Button usually has a border and appears to move up and down in response to * being pressed. It can contain an image and/or text in it. */ public class Button extends Clickable { /** * Constructs a default Button with no icon or text. * * @since 2.0 */ public Button() { super(); setStyle(STYLE_BUTTON); } /** * Contructs a Button containing the icon image. * * @param image * Image to be used by the Button as its icon. * @since 2.0 */ public Button(Image image) { super(new Label(image), STYLE_BUTTON); } /** * Constructs a Button containing the given text. * * @param text * Text for the button. * @since 2.0 */ public Button(String text) { super(new Label(text), STYLE_BUTTON); } /** * Constructs a Button with the given image and text. * * @param text * Text for the button. * @param image * Image for the button. * @since 2.0 */ public Button(String text, Image image) { super(new Label(text, image), STYLE_BUTTON); } /** * Initializes this button by setting its default border and setting its * background color to {@link ColorConstants#button}. * * @since 2.0 */ protected void init() { super.init(); setBackgroundColor(ColorConstants.button); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ButtonBorder.java000066400000000000000000000175131166301720600267530ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.graphics.Color; import org.eclipse.draw2d.ButtonBorder.ButtonScheme; import org.eclipse.draw2d.geometry.Insets; /** * Creates a border for a clickable type of figure, which works in conjunction * with the Figure and its model. This border adjusts itself to the various * states the model of the figure could be. This border uses an extended * {@link SchemeBorder.Scheme Scheme} called {@link ButtonScheme} which provides * more information required by border to handle the the states of the model. * * @see SchemeBorder.Scheme * @see ButtonScheme */ public class ButtonBorder extends SchemeBorder { /** * Default button border. * * @see SCHEMES#BUTTON */ public static final Border BUTTON = new ButtonBorder(SCHEMES.BUTTON); /** * Inverted hightlight colors from BUTTON. * * @see SCHEMES#BUTTON_CONTRAST */ public static final Border BUTTON_CONTRAST = new ButtonBorder( SCHEMES.BUTTON_CONTRAST); /** * Used for scrollbar buttons. * * @see SCHEMES#BUTTON_SCROLLBAR */ public static final Border BUTTON_SCROLLBAR = new ButtonBorder( SCHEMES.BUTTON_SCROLLBAR); /** * Used for toolbar buttons. * * @see SCHEMES#TOOLBAR */ public static final Border TOOLBAR = new ButtonBorder(SCHEMES.TOOLBAR); /** * Provides for a scheme to represent the borders of clickable figures like * buttons. Though similar to the {@link SchemeBorder.Scheme Scheme} it * supports an extra set of borders for the pressed states. */ public static class ButtonScheme extends Scheme { private Color highlightPressed[] = null, shadowPressed[] = null; /** * Constructs a new button scheme where the input colors are the colors * for the top-left and bottom-right sides of the border. These colors * serve as the colors when the border is in a pressed state too. The * width of each side is determined by the number of colors passed in as * input. * * @param highlight * Colors for the top-left sides of the border * @param shadow * Colors for the bottom-right sides of the border * @since 2.0 */ public ButtonScheme(Color[] highlight, Color[] shadow) { highlightPressed = this.highlight = highlight; shadowPressed = this.shadow = shadow; init(); } /** * Constructs a new button scheme where the input colors are the colors * for the top-left and bottom-right sides of the border, for the normal * and pressed states. The width of each side is determined by the * number of colors passed in as input. * * @param hl * Colors for the top-left sides of the border * @param sh * Colors for the bottom-right sides of the border * @param hlp * Colors for the top-left sides of the border when figure is * pressed * @param shp * Colors for the bottom-right sides of the border when * figure is pressed * @since 2.0 */ public ButtonScheme(Color[] hl, Color[] sh, Color[] hlp, Color[] shp) { highlight = hl; shadow = sh; highlightPressed = hlp; shadowPressed = shp; init(); } /** * Calculates and returns the Insets for this border. The calculations * are based on the number of normal and pressed, highlight and shadow * colors. * * @return The insets for this border * @since 2.0 */ protected Insets calculateInsets() { int br = 1 + Math.max(getShadow().length, getHighlightPressed().length); int tl = Math.max(getHighlight().length, getShadowPressed().length); return new Insets(tl, tl, br, br); } /** * Calculates and returns the opaque state of this border. *

* Returns false in the following conditions: *

    *
  • The number of highlight colors is different than the the number * of shadow colors. *
  • The number of pressed highlight colors is different than the * number of pressed shadow colors. *
  • Any of the highlight and shadow colors are set to * null *
  • Any of the pressed highlight and shadow colors are set to * null *
* This is done so that the entire region under the figure is properly * covered. * * @return The opaque state of this border * @since 2.0 */ protected boolean calculateOpaque() { if (!super.calculateOpaque()) return false; if (getHighlight().length != getShadowPressed().length) return false; if (getShadow().length != getHighlightPressed().length) return false; Color[] colors = getHighlightPressed(); for (int i = 0; i < colors.length; i++) if (colors[i] == null) return false; colors = getShadowPressed(); for (int i = 0; i < colors.length; i++) if (colors[i] == null) return false; return true; } /** * Returns the pressed highlight colors of this border. * * @return Colors as an array of Colors * @since 2.0 */ protected Color[] getHighlightPressed() { return highlightPressed; } /** * Returns the pressed shadow colors of this border. * * @return Colors as an array of Colors * @since 2.0 */ protected Color[] getShadowPressed() { return shadowPressed; } } /** * Interface defining commonly used schemes for the ButtonBorder. */ public static interface SCHEMES { /** * Contrast button scheme */ ButtonScheme BUTTON_CONTRAST = new ButtonScheme(new Color[] { button, buttonLightest }, DARKEST_DARKER); /** * Regular button scheme */ ButtonScheme BUTTON = new ButtonScheme(new Color[] { buttonLightest }, DARKEST_DARKER); /** * Toolbar button scheme */ ButtonScheme TOOLBAR = new ButtonScheme(new Color[] { buttonLightest }, new Color[] { buttonDarker }); /** * Scrollbar button scheme */ ButtonScheme BUTTON_SCROLLBAR = new ButtonScheme(new Color[] { button, buttonLightest }, DARKEST_DARKER, new Color[] { buttonDarker }, new Color[] { buttonDarker }); } /** * Constructs a ButtonBorder with a predefined button scheme set as its * default. * * @since 2.0 */ public ButtonBorder() { setScheme(SCHEMES.BUTTON); } /** * Constructs a ButtonBorder with the input ButtonScheme set as its Scheme. * * @param scheme * ButtonScheme for this ButtonBorder. * @since 2.0 */ public ButtonBorder(ButtonScheme scheme) { setScheme(scheme); } /** * Paints this border with the help of the set scheme, the model of the * clickable figure, and other inputs. The scheme is used in conjunction * with the state of the model to get the appropriate colors for the border. * * @param figure * The Clickable that this border belongs to * @param graphics * The graphics used for painting * @param insets * The insets */ public void paint(IFigure figure, Graphics graphics, Insets insets) { Clickable clickable = (Clickable) figure; ButtonModel model = clickable.getModel(); ButtonScheme colorScheme = (ButtonScheme) getScheme(); if (clickable.isRolloverEnabled() && !model.isMouseOver() && !model.isSelected()) return; Color tl[], br[]; if (model.isSelected() || model.isArmed()) { tl = colorScheme.getShadowPressed(); br = colorScheme.getHighlightPressed(); } else { tl = colorScheme.getHighlight(); br = colorScheme.getShadow(); } paint(graphics, figure, insets, tl, br); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ButtonGroup.java000066400000000000000000000144101166301720600266230ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.ArrayList; import java.util.List; /** * A ButtonGroup holds a group of {@link Clickable Clickable's} models and * provides unique selection in them. There is capability to add a default * selection. Models who want to belong to the group should just add themselves * to this group. By doing so they listen to this group for changes. *

* Setting of the default selection results in its being selected any time * {@link #setSelected(ButtonModel, boolean)} is called. If no default selection * is set, the last entry selected is not allowed to deselect. */ public class ButtonGroup { private ButtonModel selectedModel; private ButtonModel defaultModel; private List members = new ArrayList(); private List listeners = new ArrayList(); /** * Constructs a ButtonGroup with no default selection. * * @since 2.0 */ public ButtonGroup() { } /** * Adds the passed ButtonModel to the ButtonGroup. * * @param model * ButtonModel to be added to this group * @since 2.0 */ public void add(ButtonModel model) { if (!members.contains(model)) { model.setGroup(this); members.add(model); } } /** * Adds the passed listener. ButtonGroups use PropertyChangeListeners to * react to selection changes in the ButtonGroup. * * @param listener * Listener to be added to this group * @since 2.0 */ public void addPropertyChangeListener(PropertyChangeListener listener) { listeners.add(listener); } /** * Fires a PropertyChangeEvent to all PropertyChangeListeners added to this * ButtonGroup. * * @param oldValue * Old selection value * @param newValue * New selection value * @since 2.0 */ protected void firePropertyChange(Object oldValue, Object newValue) { PropertyChangeEvent event = new PropertyChangeEvent(this, ButtonModel.SELECTED_PROPERTY, oldValue, newValue); for (int i = 0; i < listeners.size(); i++) ((PropertyChangeListener) listeners.get(i)).propertyChange(event); } /** * Returns the ButtonModel which is selected by default for this * ButtonGroup. * * @return The default ButtonModel * @since 2.0 */ public ButtonModel getDefault() { return defaultModel; } /** * Returns a List which contains all of the {@link ButtonModel ButtonModels} * added to this ButtonGroup. * * @return The List of ButtonModels in this ButtonGroup * @since 2.0 */ public List getElements() { return members; } /** * Returns the ButtonModel for the currently selected button. * * @return The ButtonModel for the currently selected button * @since 2.0 */ public ButtonModel getSelected() { return selectedModel; } /** * Determines if the given ButtonModel is selected or not. * * @param model * Model being tested for selected status * @return Selection state of the given model * @since 2.0 */ public boolean isSelected(ButtonModel model) { return (model == getSelected()); } /** * Removes the given ButtonModel from this ButtonGroup. * * @param model * ButtonModel being removed * @since 2.0 */ public void remove(ButtonModel model) { if (getSelected() == model) setSelected(getDefault(), true); if (defaultModel == model) defaultModel = null; members.remove(model); } /** * Removes the passed PropertyChangeListener from this ButtonGroup. * * @param listener * PropertyChangeListener to be removed * @since 2.0 */ public void removePropertyChangeListener(PropertyChangeListener listener) { listeners.remove(listener); } /** * Sets the passed ButtonModel to be the currently selected ButtonModel of * this ButtonGroup. Fires a property change. * * @param model * ButtonModel to be selected * @since 2.0 */ protected void selectNewModel(ButtonModel model) { ButtonModel oldModel = selectedModel; selectedModel = model; if (oldModel != null) oldModel.setSelected(false); firePropertyChange(oldModel, model); } /** * Sets the default selection of this ButtonGroup. Does nothing if it is not * present in the group. Sets selection to the passed ButtonModel. * * @param model * ButtonModel which is to be the default selection. * @since 2.0 */ public void setDefault(ButtonModel model) { defaultModel = model; if (getSelected() == null && defaultModel != null) defaultModel.setSelected(true); } /** * Sets the button with the given ButtonModel to be selected. * * @param model * The ButtonModel to be selected * @since 2.0 */ public void setSelected(ButtonModel model) { if (model == null) selectNewModel(null); else model.setSelected(true); } /** * Sets model to the passed state. *

* If value is *

    *
  • true: *
      *
    • The passed ButtonModel will own selection. *
    *
  • false: *
      *
    • If the passed model owns selection, it will lose selection, and * selection will be given to the default ButonModel. If no default * ButtonModel was set, selection will remain as it was, as one ButtonModel * must own selection at all times. *
    • If the passed model does not own selection, then selection will * remain as it was. *
    *
* * @param model * The model to be affected * @param value * The selected state * @since 2.0 */ public void setSelected(ButtonModel model, boolean value) { if (value) { if (model == getSelected()) return; selectNewModel(model); } else { if (model != getSelected()) return; if (getDefault() == null) return; getDefault().setSelected(true); } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ButtonModel.java000066400000000000000000000332471166301720600266000ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.Iterator; import java.util.Timer; import java.util.TimerTask; //import org.eclipse.draw2d.internal.Timer; /** * A model for buttons containing several properties, including enabled, * pressed, selected, rollover enabled and mouseover. */ public class ButtonModel { /** Enabled property */ public static final String ENABLED_PROPERTY = "enabled"; //$NON-NLS-1$ /** Pressed property */ public static final String PRESSED_PROPERTY = "pressed"; //$NON-NLS-1$ /** Selected property */ public static final String SELECTED_PROPERTY = "selected"; //$NON-NLS-1$ /** Rollover Enabled property */ public static final String ROLLOVER_ENABLED_PROPERTY = "rollover enabled"; //$NON-NLS-1$ /** Mouseover property */ public static final String MOUSEOVER_PROPERTY = "mouseover"; //$NON-NLS-1$ /** Armed property */ public static final String ARMED_PROPERTY = "armed"; //$NON-NLS-1$ /** Flag for armed button state */ protected static final int ARMED_FLAG = 1; /** Flag for pressed button state */ protected static final int PRESSED_FLAG = 2; /** Flag for mouseOver state */ protected static final int MOUSEOVER_FLAG = 4; /** Flag for selected button state */ protected static final int SELECTED_FLAG = 8; /** Flag for enablement button state */ protected static final int ENABLED_FLAG = 16; /** Flag for rollover enablement button state */ protected static final int ROLLOVER_ENABLED_FLAG = 32; /** Flag that can be used by subclasses to define more states */ protected static final int MAX_FLAG = ROLLOVER_ENABLED_FLAG; private int state = ENABLED_FLAG; private Object data; /** * Action performed events are not fired until the mouse button is released. */ public static final int DEFAULT_FIRING_BEHAVIOR = 0; /** * Action performed events fire repeatedly until the mouse button is * released. */ public static final int REPEAT_FIRING_BEHAVIOR = 1; /** * The name of the action associated with this button. */ protected String actionName; /** * The ButtonGroup this button belongs to (if any). */ protected ButtonGroup group = null; private EventListenerList listeners = new EventListenerList(); /** * Listens to button state transitions and fires action performed events * based on the desired behavior ({@link #DEFAULT_FIRING_BEHAVIOR} or * {@link #REPEAT_FIRING_BEHAVIOR}). */ protected ButtonStateTransitionListener firingBehavior; { installFiringBehavior(); } /** * Registers the given listener as an ActionListener. * * @param listener * The ActionListener to add * @since 2.0 */ public void addActionListener(ActionListener listener) { if (listener == null) throw new IllegalArgumentException(); listeners.addListener(ActionListener.class, listener); } /** * Registers the given listener as a ChangeListener. * * @param listener * The ChangeListener to add * @since 2.0 */ public void addChangeListener(ChangeListener listener) { if (listener == null) throw new IllegalArgumentException(); listeners.addListener(ChangeListener.class, listener); } /** * Registers the given listener as a ButtonStateTransitionListener. * * @param listener * The ButtonStateTransitionListener to add * @since 2.0 */ public void addStateTransitionListener( ButtonStateTransitionListener listener) { if (listener == null) throw new IllegalArgumentException(); listeners.addListener(ButtonStateTransitionListener.class, listener); } /** * Notifies any ActionListeners on this ButtonModel that an action has been * performed. * * @since 2.0 */ protected void fireActionPerformed() { Iterator iter = listeners.getListeners(ActionListener.class); ActionEvent action = new ActionEvent(this); while (iter.hasNext()) ((ActionListener) iter.next()).actionPerformed(action); } /** * Notifies any listening ButtonStateTransitionListener that the pressed * state of this button has been cancelled. * * @since 2.0 */ protected void fireCanceled() { Iterator iter = listeners .getListeners(ButtonStateTransitionListener.class); while (iter.hasNext()) ((ButtonStateTransitionListener) iter.next()).canceled(); } /** * Notifies any listening ButtonStateTransitionListener that this button has * been pressed. * * @since 2.0 */ protected void firePressed() { Iterator iter = listeners .getListeners(ButtonStateTransitionListener.class); while (iter.hasNext()) ((ButtonStateTransitionListener) iter.next()).pressed(); } /** * Notifies any listening ButtonStateTransitionListener that this button has * been released. * * @since 2.0 */ protected void fireReleased() { Iterator iter = listeners .getListeners(ButtonStateTransitionListener.class); while (iter.hasNext()) ((ButtonStateTransitionListener) iter.next()).released(); } /** * Notifies any listening ButtonStateTransitionListeners that this button * has resumed activity. * * @since 2.0 */ protected void fireResume() { Iterator iter = listeners .getListeners(ButtonStateTransitionListener.class); while (iter.hasNext()) ((ButtonStateTransitionListener) iter.next()).resume(); } /** * Notifies any listening ChangeListeners that this button's state has * changed. * * @param property * The name of the property that changed * @since 2.0 */ protected void fireStateChanged(String property) { Iterator iter = listeners.getListeners(ChangeListener.class); ChangeEvent change = new ChangeEvent(this, property); while (iter.hasNext()) ((ChangeListener) iter.next()).handleStateChanged(change); } /** * Notifies any listening ButtonStateTransitionListeners that this button * has suspended activity. * * @since 2.0 */ protected void fireSuspend() { Iterator iter = listeners .getListeners(ButtonStateTransitionListener.class); while (iter.hasNext()) ((ButtonStateTransitionListener) iter.next()).suspend(); } boolean getFlag(int which) { return (state & which) != 0; } /** * Returns the group to which this model belongs. * * @return The ButtonGroup to which this model belongs * @since 2.0 */ public ButtonGroup getGroup() { return group; } /** * Returns an object representing user data. * * @return User data * @since 2.0 */ public Object getUserData() { return data; } /** * Sets the firing behavior for this button. * * @since 2.0 */ protected void installFiringBehavior() { setFiringBehavior(DEFAULT_FIRING_BEHAVIOR); } /** * Returns true if this button is armed. If a button is armed, * it will fire an ActionPerformed when released. * * @return true if this button is armed * @since 2.0 */ public boolean isArmed() { return (state & ARMED_FLAG) != 0; } /** * Returns true if this button is enabled. * * @return true if this button is enabled * @since 2.0 */ public boolean isEnabled() { return (state & ENABLED_FLAG) != 0; } /** * Returns true if the mouse is over this button. * * @return true if the mouse is over this button * @since 2.0 */ public boolean isMouseOver() { return (state & MOUSEOVER_FLAG) != 0; } /** * Returns true if this button is pressed. * * @return true if this button is pressed * @since 2.0 */ public boolean isPressed() { return (state & PRESSED_FLAG) != 0; } /** * Returns the selection state of this model. If this model belongs to any * group, the group is queried for selection state, else the flags are used. * * @return true if this button is selected * @since 2.0 */ public boolean isSelected() { if (group == null) { return (state & SELECTED_FLAG) != 0; } else { return group.isSelected(this); } } /** * Removes the given ActionListener. * * @param listener * The ActionListener to remove * @since 2.0 */ public void removeActionListener(ActionListener listener) { listeners.removeListener(ActionListener.class, listener); } /** * Removes the given ChangeListener. * * @param listener * The ChangeListener to remove * @since 2.0 */ public void removeChangeListener(ChangeListener listener) { listeners.removeListener(ChangeListener.class, listener); } /** * Removes the given ButtonStateTransitionListener. * * @param listener * The ButtonStateTransitionListener to remove * @since 2.0 */ public void removeStateTransitionListener( ButtonStateTransitionListener listener) { listeners.removeListener(ButtonStateTransitionListener.class, listener); } /** * Sets this button to be armed. If a button is armed, it will fire an * ActionPerformed when released. * * @param value * The armed state * @since 2.0 */ public void setArmed(boolean value) { if (isArmed() == value) return; if (!isEnabled()) return; setFlag(ARMED_FLAG, value); fireStateChanged(ARMED_PROPERTY); } /** * Sets this button to be enabled. * * @param value * The enabled state * @since 2.0 */ public void setEnabled(boolean value) { if (isEnabled() == value) return; if (!value) { setMouseOver(false); setArmed(false); setPressed(false); } setFlag(ENABLED_FLAG, value); fireStateChanged(ENABLED_PROPERTY); } /** * Sets the firing behavior for this button. * {@link #DEFAULT_FIRING_BEHAVIOR} is the default behavior, where action * performed events are not fired until the mouse button is released. * {@link #REPEAT_FIRING_BEHAVIOR} causes action performed events to fire * repeatedly until the mouse button is released. * * @param type * The firing behavior type * @since 2.0 * */ public void setFiringBehavior(int type) { if (firingBehavior != null) removeStateTransitionListener(firingBehavior); switch (type) { case REPEAT_FIRING_BEHAVIOR: firingBehavior = new RepeatFiringBehavior(); break; default: firingBehavior = new DefaultFiringBehavior(); } addStateTransitionListener(firingBehavior); } void setFlag(int flag, boolean value) { if (value) state |= flag; else state &= ~flag; } /** * Sets the ButtonGroup to which this model belongs to. Adds this model as a * listener to the group. * * @param bg * The group to which this model belongs. * @since 2.0 */ public void setGroup(ButtonGroup bg) { if (group == bg) return; if (group != null) group.remove(this); group = bg; if (group != null) group.add(this); } /** * Sets the mouseover property of this button. * * @param value * The value the mouseover property will be set to * @since 2.0 */ public void setMouseOver(boolean value) { if (isMouseOver() == value) return; if (isPressed()) if (value) fireResume(); else fireSuspend(); setFlag(MOUSEOVER_FLAG, value); fireStateChanged(MOUSEOVER_PROPERTY); } /** * Sets the pressed property of this button. * * @param value * The value the pressed property will be set to * @since 2.0 */ public void setPressed(boolean value) { if (isPressed() == value) return; setFlag(PRESSED_FLAG, value); if (value) firePressed(); else { if (isArmed()) fireReleased(); else fireCanceled(); } fireStateChanged(PRESSED_PROPERTY); } /** * Sets this button to be selected. * * @param value * The value the selected property will be set to * @since 2.0 */ public void setSelected(boolean value) { if (group == null) { if (isSelected() == value) return; } else { group.setSelected(this, value); if (getFlag(SELECTED_FLAG) == isSelected()) return; } setFlag(SELECTED_FLAG, value); fireStateChanged(SELECTED_PROPERTY); } /** * Sets user data. * * @param data * The user data * @since 2.0 */ public void setUserData(Object data) { this.data = data; } class DefaultFiringBehavior extends ButtonStateTransitionListener { public void released() { fireActionPerformed(); } } class RepeatFiringBehavior extends ButtonStateTransitionListener { protected static final int INITIAL_DELAY = 250, STEP_DELAY = 40; protected int stepDelay = INITIAL_DELAY, initialDelay = STEP_DELAY; protected Timer timer; public void pressed() { fireActionPerformed(); if (!isEnabled()) return; timer = new Timer(); TimerTask runAction = new Task(timer); timer.scheduleAtFixedRate(runAction, INITIAL_DELAY, STEP_DELAY); } public void canceled() { suspend(); } public void released() { suspend(); } public void resume() { timer = new Timer(); TimerTask runAction = new Task(timer); timer.scheduleAtFixedRate(runAction, STEP_DELAY, STEP_DELAY); } public void suspend() { if (timer == null) return; timer.cancel(); timer = null; } } class Task extends TimerTask { private Timer timer; public Task(Timer timer) { this.timer = timer; } public void run() { org.eclipse.swt.widgets.Display.getDefault().syncExec( new Runnable() { public void run() { if (!isEnabled()) timer.cancel(); fireActionPerformed(); } }); } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ButtonStateTransitionListener.java000066400000000000000000000017061166301720600323740ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; class ButtonStateTransitionListener { protected final void cancel() throws Exception { } public void canceled() { } final void cancelled() throws Exception { } protected final void press() throws Exception { } public void pressed() { } protected final void release() throws Exception { } public void released() { } public void resume() { } public void suspend() { } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ChangeEvent.java000066400000000000000000000032451166301720600265260ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; /** * An event for property changes. Includes the source of the event as well as * the name of the property that has changed. */ public class ChangeEvent extends java.util.EventObject { private String property; /** * Constructs a new ChangeEvent with the given object as the source of the * event. * * @param source * The source of the event */ public ChangeEvent(Object source) { super(source); } /** * Constructs a new ChangeEvent with the given source object and property * name. * * @param source * The source of the event * @param property * The property name */ public ChangeEvent(Object source, String property) { super(source); setPropertyName(property); } /** * Returns the name of the property that has changed. * * @return String the name of the property that has changed */ public String getPropertyName() { return property; } /** * Sets the name of the property that has changed. * * @param string * The property name */ protected void setPropertyName(String string) { property = string; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ChangeListener.java000066400000000000000000000014541166301720600272320ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; /** * A generic state listener */ public interface ChangeListener { /** * Called when the listened to object's state has changed. * * @param event * the ChangeEvent */ void handleStateChanged(ChangeEvent event); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/CheckBox.java000066400000000000000000000045221166301720600260240ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.io.IOException; import java.io.InputStream; import org.eclipse.swt.graphics.Image; /** * A Checkbox is a toggle figure which toggles between the checked and unchecked * figures to simulate a check box. A check box contains a text label to * represent it. */ public final class CheckBox extends Toggle { private Label label = null; static final Image UNCHECKED = createImage("images/checkboxenabledoff.gif"), //$NON-NLS-1$ CHECKED = createImage("images/checkboxenabledon.gif"); //$NON-NLS-1$ private static Image createImage(String name) { InputStream stream = CheckBox.class.getResourceAsStream(name); Image image = new Image(null, stream); try { stream.close(); } catch (IOException ioe) { } return image; } /** * Constructs a CheckBox with no text. * * @since 2.0 */ public CheckBox() { this(""); //$NON-NLS-1$ } /** * Constructs a CheckBox with the passed text in its label. * * @param text * The label text * @since 2.0 */ public CheckBox(String text) { setContents(label = new Label(text, UNCHECKED)); } /** * Adjusts CheckBox's icon depending on selection status. * * @since 2.0 */ protected void handleSelectionChanged() { if (isSelected()) label.setIcon(CHECKED); else label.setIcon(UNCHECKED); } /** * Initializes this Clickable by setting a default model and adding a * clickable event handler for that model. Also adds a ChangeListener to * update icon when selection status changes. * * @since 2.0 */ protected void init() { super.init(); addChangeListener(new ChangeListener() { public void handleStateChanged(ChangeEvent changeEvent) { if (changeEvent.getPropertyName().equals( ButtonModel.SELECTED_PROPERTY)) handleSelectionChanged(); } }); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ChopboxAnchor.java000066400000000000000000000072661166301720600271030ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; /** * The ChopboxAnchor's location is found by calculating the intersection of a * line drawn from the center point of its owner's box to a reference point on * that box. Thus {@link Connection Connections} using the ChopBoxAnchor will be * oriented such that they point to their owner's center. */ public class ChopboxAnchor extends AbstractConnectionAnchor { /** * Constructs a new ChopboxAnchor. */ protected ChopboxAnchor() { } /** * Constructs a ChopboxAnchor with the given owner figure. * * @param owner * The owner figure * @since 2.0 */ public ChopboxAnchor(IFigure owner) { super(owner); } /** * Gets a Rectangle from {@link #getBox()} and returns the Point where a * line from the center of the Rectangle to the Point reference * intersects the Rectangle. * * @param reference * The reference point * @return The anchor location */ public Point getLocation(Point reference) { Rectangle r = Rectangle.SINGLETON; r.setBounds(getBox()); r.translate(-1, -1); r.resize(1, 1); getOwner().translateToAbsolute(r); float centerX = r.x + 0.5f * r.width; float centerY = r.y + 0.5f * r.height; if (r.isEmpty() || (reference.x == (int) centerX && reference.y == (int) centerY)) return new Point((int) centerX, (int) centerY); // This avoids // divide-by-zero float dx = reference.x - centerX; float dy = reference.y - centerY; // r.width, r.height, dx, and dy are guaranteed to be non-zero. float scale = 0.5f / Math.max(Math.abs(dx) / r.width, Math.abs(dy) / r.height); dx *= scale; dy *= scale; centerX += dx; centerY += dy; return new Point(Math.round(centerX), Math.round(centerY)); } /** * Returns the bounds of this ChopboxAnchor's owner. Subclasses can override * this method to adjust the box the anchor can be placed on. For instance, * the owner figure may have a drop shadow that should not be included in * the box. * * @return The bounds of this ChopboxAnchor's owner * @since 2.0 */ protected Rectangle getBox() { return getOwner().getBounds(); } /** * Returns the anchor's reference point. In the case of the ChopboxAnchor, * this is the center of the anchor's owner. * * @return The reference point */ public Point getReferencePoint() { Point ref = getBox().getCenter(); getOwner().translateToAbsolute(ref); return ref; } /** * Returns true if the other anchor has the same owner and box. * * @param obj * the other anchor * @return true if equal */ public boolean equals(Object obj) { if (obj instanceof ChopboxAnchor) { ChopboxAnchor other = (ChopboxAnchor) obj; return other.getOwner() == getOwner() && other.getBox().equals(getBox()); } return false; } /** * The owning figure's hashcode is used since equality is approximately * based on the owner. * * @return the hash code. */ public int hashCode() { if (getOwner() != null) return getOwner().hashCode(); else return super.hashCode(); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/Clickable.java000066400000000000000000000336251166301720600262150ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.Iterator; import org.eclipse.draw2d.geometry.Rectangle; /** * A Clickable responds to mouse clicks in some way (determined by a * ClickBehavior) and fires action events. No visual appearance of feedback is * offered. Depends on a model holder and an event handler which understands the * model and updates the model accordingly. {@link ButtonModel} is used by * default. Any figure can be set as contents to a Clickable. * Clickable->EventHandler->Model->ModelObserver->Listeners of actions. */ public class Clickable extends Figure { private static final int ROLLOVER_ENABLED_FLAG = Figure.MAX_FLAG << 1, STYLE_BUTTON_FLAG = Figure.MAX_FLAG << 2, STYLE_TOGGLE_FLAG = Figure.MAX_FLAG << 3; /** * The highest reserved flag used by this class */ protected static int MAX_FLAG = STYLE_TOGGLE_FLAG; /** * Style constant that defines a push button. The button will be pressed * when the mouse is pressed on top of it. The button will be released when * the mouse is released or is move off of the button. * */ public static final int STYLE_BUTTON = STYLE_BUTTON_FLAG; /** * Style constant that defines a toggle button. The button will toggle * between 2 states when the mouse is clicked on the button. */ public static final int STYLE_TOGGLE = STYLE_TOGGLE_FLAG; /** * An action is performed every time the mouse is released. */ public static final int DEFAULT_FIRING = 0; /** * Firing starts as soon as the mouse is pressed on this Clickable, and * keeps firing at prefixed intervals until the mouse is released. */ public static final int REPEAT_FIRING = 1; /** * Observes the model for action and state changes. * * @see ActionListener * @see ChangeListener */ static interface ModelObserver extends ActionListener, ChangeListener { } private ClickableEventHandler eventHandler; private ButtonModel model; private ModelObserver modelObserver; { init(); setRequestFocusEnabled(true); setFocusTraversable(true); } /** * Constructs a Clickable with no contents. */ public Clickable() { } /** * Constructs a Clickable whose contents are provided as input. The content * figure occupies the entire region of the Clickable. * * @param contents * The content figure */ public Clickable(IFigure contents) { this(contents, 0); } /** * Constructs a Clickable whose contents are provided as input. The content * figure occupies the entire region of the Clickable. Sets the style to the * given style (either {@link #STYLE_BUTTON} or {@link #STYLE_TOGGLE} * ). * * @param contents * The content figure * @param style * The button style */ public Clickable(IFigure contents, int style) { setContents(contents); setStyle(style); } /** * Adds the given listener to the list of action listeners of this Figure. * Listener is called whenever an action is performed. * * @param listener * The ActionListener to be added * @since 2.0 */ public void addActionListener(ActionListener listener) { addListener(ActionListener.class, listener); } /** * Adds the given listener to the list of state change listeners of this * figure. A ChangeListener is informed if there is any state change in the * model requiring action by the listener. * * @param listener * The ChangeListener to be added * @since 2.0 */ public void addChangeListener(ChangeListener listener) { addListener(ChangeListener.class, listener); } /** * Returns a newly created ButtonModel as the default model to be used by * this Clickable based on the button style. * * @return The model to be used by default * @since 2.0 */ protected ButtonModel createDefaultModel() { if (isStyle(STYLE_TOGGLE)) return new ToggleModel(); else return new ButtonModel(); } /** * Returns a newly created event handler for this Clickable and its model. * * @return The event handler * @since 2.0 */ protected ClickableEventHandler createEventHandler() { return new ClickableEventHandler(); } /** * Returns a newly created model observer which listens to the model, and * fires any action or state changes. A ModelObserver holds both an action * listener and a state change listener. * * @return The newly created model observer * @since 2.0 */ protected ModelObserver createModelObserver() { return new ModelObserver() { public void actionPerformed(ActionEvent action) { fireActionPerformed(); } public void handleStateChanged(ChangeEvent change) { fireStateChanged(change); } }; } /** * Fires an action performed event. * * @since 2.0 */ public void doClick() { fireActionPerformed(); } /** * Called when there has been an action performed by this Clickable, which * is determined by the model. Notifies all ActionListener type listeners of * an action performed. * * @since 2.0 */ protected void fireActionPerformed() { ActionEvent action = new ActionEvent(this); Iterator listeners = getListeners(ActionListener.class); while (listeners.hasNext()) ((ActionListener) listeners.next()) // Leave newline for debug // stepping .actionPerformed(action); } /** * Called when there has been a change of state in the model of this * clickable. Notifies all ChangeListener type listeners of the state * change. * * @param modelChange * The ChangeEvent * @since 2.0 */ protected void fireStateChanged(ChangeEvent modelChange) { ChangeEvent change = new ChangeEvent(this, modelChange.getPropertyName()); Iterator listeners = getListeners(ChangeListener.class); while (listeners.hasNext()) ((ChangeListener) listeners.next()) // Leave newline for debug // stepping .handleStateChanged(change); } /** * Returns the behavior model used by this Clickable. * * @return The model used by this Clickable * @since 2.0 */ public ButtonModel getModel() { return model; } /** * Adds the given ClickableEventHandler to this clickable. A * ClickableEventHandler should be a MouseListener, MouseMotionListener, * ChangeListener, KeyListener, and FocusListener. * * @param handler * The new event handler * @since 2.0 */ protected void hookEventHandler(ClickableEventHandler handler) { if (handler == null) return; addMouseListener(handler); addMouseMotionListener(handler); addChangeListener(handler); addKeyListener(handler); addFocusListener(handler); } /** * Initializes this Clickable by setting a default model and adding a * clickable event handler for that model. * * @since 2.0 */ protected void init() { setModel(createDefaultModel()); setEventHandler(createEventHandler()); } /** * Returns true if rollover feedback is enabled. * * @return true rollover feedback is enabled * @since 2.0 */ public boolean isRolloverEnabled() { return (flags & ROLLOVER_ENABLED_FLAG) != 0; } /** * Returns true if this Clickable is in a selected state. The * model is the one which holds all this state based information. * * @return true if this Clickable is in a selected state * @since 2.0 */ public boolean isSelected() { return getModel().isSelected(); } /** * Returns true if this Clickable's style is the same as the * passed style. * * @param style * The style to be checked * @return true if this Clickable's style is the same as the * passed style * @since 2.0 */ public boolean isStyle(int style) { return ((style & flags) == style); } /** * If this Clickable has focus, this method paints a focus rectangle. * * @param graphics * Graphics handle for painting */ protected void paintBorder(Graphics graphics) { super.paintBorder(graphics); if (hasFocus()) { graphics.setForegroundColor(ColorConstants.black); graphics.setBackgroundColor(ColorConstants.white); Rectangle area = getClientArea(); if (isStyle(STYLE_BUTTON)) graphics.drawFocus(area.x, area.y, area.width, area.height); else graphics.drawFocus(area.x, area.y, area.width - 1, area.height - 1); } } /** * Paints the area of this figure excluded by the borders. Induces a (1,1) * pixel shift in the painting if the mouse is armed, giving it the pressed * appearance. * * @param graphics * Graphics handle for painting * @since 2.0 */ protected void paintClientArea(Graphics graphics) { if (isStyle(STYLE_BUTTON) && (getModel().isArmed() || getModel().isSelected())) { graphics.translate(1, 1); graphics.pushState(); super.paintClientArea(graphics); graphics.popState(); graphics.translate(-1, -1); } else super.paintClientArea(graphics); } /** * Removes the given listener from the list of ActionListener's of this * Clickable. * * @param listener * Listener to be removed from this figure * @since 2.0 */ public void removeActionListener(ActionListener listener) { removeListener(ActionListener.class, listener); } /** * Removes the given listener from the list of ChangeListener's of this * clickable. * * @param listener * Listener to be removed from this figure * @since 2.0 */ public void removeChangeListener(ChangeListener listener) { removeListener(ChangeListener.class, listener); } /** * Sets the Figure which is the contents of this Clickable. This Figure * occupies the entire clickable region. * * @param contents * Contents of the clickable * @since 2.0 */ protected void setContents(IFigure contents) { setLayoutManager(new StackLayout()); if (getChildren().size() > 0) remove((IFigure) getChildren().get(0)); add(contents); } /** * @see org.eclipse.draw2d.IFigure#setEnabled(boolean) */ public void setEnabled(boolean value) { if (isEnabled() == value) return; super.setEnabled(value); getModel().setEnabled(value); setChildrenEnabled(value); } /** * Sets the event handler which interacts with the model to determine the * behavior of this Clickable. * * @param h * Event handler for this clickable * @since 2.0 */ public void setEventHandler(ClickableEventHandler h) { if (eventHandler != null) unhookEventHandler(eventHandler); eventHandler = h; if (eventHandler != null) hookEventHandler(eventHandler); } /** * Determines how this clickable is to fire notifications to its listeners. * In the default firing method ({@link #DEFAULT_FIRING}), an action is * performed every time the mouse is released. In the repeat firing method ( * {@link #REPEAT_FIRING}), firing starts as soon as it is pressed on this * clickable, and keeps firing at prefixed intervals until the mouse is * released. * * @param type * Type of firing * @since 2.0 */ public void setFiringMethod(int type) { getModel().setFiringBehavior(type); } /** * Sets the model to be used by this clickable for its state and behavior * determination. This clickable removes any observers from the previous * model before adding new ones to the new model. * * @param model * The new model of this Clickable * @since 2.0 */ public void setModel(ButtonModel model) { if (this.model != null) { this.model.removeChangeListener(modelObserver); this.model.removeActionListener(modelObserver); modelObserver = null; } this.model = model; if (model != null) { modelObserver = createModelObserver(); model.addActionListener(modelObserver); model.addChangeListener(modelObserver); } } /** * Enables or disables rollover feedback of this figure. Generally used in * conjunction with the model to determine if feedback is to be shown. * * @param value * The rollover state to be set * @since 2.0 */ public void setRolloverEnabled(boolean value) { if (isRolloverEnabled() == value) return; setFlag(ROLLOVER_ENABLED_FLAG, value); repaint(); } /** * Sets the selected state of this Clickable. Since the model is responsible * for all state based information, it is informed of the state change. * Extending classes can choose selection information, if they do not * represent any selection. * * @param value * New selected state of this clickable. * @see #isSelected() * @since 2.0 */ public void setSelected(boolean value) { getModel().setSelected(value); } /** * Sets this Clickable's style to the passed value, either * {@link #STYLE_BUTTON} or {@link #STYLE_TOGGLE}. * * @param style * The button style * @since 2.0 */ public void setStyle(int style) { if ((style & STYLE_BUTTON) != 0) { setFlag(STYLE_BUTTON_FLAG, true); if (!(getBorder() instanceof ButtonBorder)) setBorder(new ButtonBorder()); setOpaque(true); } else { setFlag(STYLE_BUTTON_FLAG, false); setOpaque(false); } if ((style & STYLE_TOGGLE) != 0) { setFlag(STYLE_TOGGLE_FLAG, true); setModel(createDefaultModel()); } } /** * Removes the given ClickableEventHandler containing listeners from this * Clickable. * * @param handler * The event handler to be removed * @since 2.0 */ protected void unhookEventHandler(ClickableEventHandler handler) { if (handler == null) return; removeMouseListener(handler); removeMouseMotionListener(handler); removeChangeListener(handler); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ClickableEventHandler.java000066400000000000000000000060361166301720600305110ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; class ClickableEventHandler extends MouseMotionListener.Stub implements MouseListener, FigureListener, ChangeListener, KeyListener, FocusListener { private MouseEvent lastEvent; public void focusLost(FocusEvent fe) { Clickable loser = (Clickable) fe.loser; loser.repaint(); loser.getModel().setArmed(false); loser.getModel().setPressed(false); } public void focusGained(FocusEvent fe) { Clickable clickable = (Clickable) fe.gainer; clickable.repaint(); } public void figureMoved(IFigure source) { if (lastEvent == null) return; mouseDragged(lastEvent); } public void handleStateChanged(ChangeEvent change) { Clickable clickable = (Clickable) change.getSource(); if (change.getPropertyName() == ButtonModel.MOUSEOVER_PROPERTY && !clickable.isRolloverEnabled()) return; clickable.repaint(); } public void mouseDoubleClicked(MouseEvent me) { } public void mouseDragged(MouseEvent me) { lastEvent = me; Clickable click = (Clickable) me.getSource(); ButtonModel model = click.getModel(); if (model.isPressed()) { boolean over = click.containsPoint(me.getLocation()); model.setArmed(over); model.setMouseOver(over); } } public void mouseEntered(MouseEvent me) { Clickable click = (Clickable) me.getSource(); click.getModel().setMouseOver(true); click.addFigureListener(this); } public void mouseExited(MouseEvent me) { Clickable click = (Clickable) me.getSource(); click.getModel().setMouseOver(false); click.removeFigureListener(this); } public void mouseMoved(MouseEvent me) { } public void mousePressed(MouseEvent me) { if (me.button != 1) return; lastEvent = me; Clickable click = (Clickable) me.getSource(); ButtonModel model = click.getModel(); click.requestFocus(); model.setArmed(true); model.setPressed(true); me.consume(); } public void mouseReleased(MouseEvent me) { if (me.button != 1) return; ButtonModel model = ((Clickable) me.getSource()).getModel(); if (!model.isPressed()) return; model.setPressed(false); model.setArmed(false); me.consume(); } public void keyPressed(KeyEvent ke) { ButtonModel model = ((Clickable) ke.getSource()).getModel(); if (ke.character == ' ' || ke.character == '\r') { model.setPressed(true); model.setArmed(true); } } public void keyReleased(KeyEvent ke) { ButtonModel model = ((Clickable) ke.getSource()).getModel(); if (ke.character == ' ' || ke.character == '\r') { model.setPressed(false); model.setArmed(false); } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ColorConstants.java000066400000000000000000000117051166301720600273120ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.widgets.Display; /** * A collection of color-related constants. */ public interface ColorConstants { class SystemColorFactory { private static Color getColor(final int which) { Display display = Display.getCurrent(); if (display != null) return display.getSystemColor(which); display = Display.getDefault(); final Color result[] = new Color[1]; display.syncExec(new Runnable() { public void run() { synchronized (result) { result[0] = Display.getCurrent().getSystemColor(which); } } }); synchronized (result) { return result[0]; } } } /** * @see SWT#COLOR_WIDGET_HIGHLIGHT_SHADOW */ Color buttonLightest = SystemColorFactory .getColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW); /** * @see SWT#COLOR_WIDGET_BACKGROUND */ Color button = SystemColorFactory.getColor(SWT.COLOR_WIDGET_BACKGROUND); /** * @see SWT#COLOR_WIDGET_NORMAL_SHADOW */ Color buttonDarker = SystemColorFactory .getColor(SWT.COLOR_WIDGET_NORMAL_SHADOW); /** * @see SWT#COLOR_WIDGET_DARK_SHADOW */ Color buttonDarkest = SystemColorFactory .getColor(SWT.COLOR_WIDGET_DARK_SHADOW); /** * @see SWT#COLOR_LIST_BACKGROUND */ Color listBackground = SystemColorFactory .getColor(SWT.COLOR_LIST_BACKGROUND); /** * @see SWT#COLOR_LIST_FOREGROUND */ Color listForeground = SystemColorFactory .getColor(SWT.COLOR_LIST_FOREGROUND); /** * @see SWT#COLOR_WIDGET_BACKGROUND */ Color menuBackground = SystemColorFactory .getColor(SWT.COLOR_WIDGET_BACKGROUND); /** * @see SWT#COLOR_WIDGET_FOREGROUND */ Color menuForeground = SystemColorFactory .getColor(SWT.COLOR_WIDGET_FOREGROUND); /** * @see SWT#COLOR_LIST_SELECTION */ Color menuBackgroundSelected = SystemColorFactory .getColor(SWT.COLOR_LIST_SELECTION); /** * @see SWT#COLOR_LIST_SELECTION_TEXT */ Color menuForegroundSelected = SystemColorFactory .getColor(SWT.COLOR_LIST_SELECTION_TEXT); /** * @see SWT#COLOR_TITLE_BACKGROUND */ Color titleBackground = SystemColorFactory .getColor(SWT.COLOR_TITLE_BACKGROUND); /** * @see SWT#COLOR_TITLE_BACKGROUND_GRADIENT */ Color titleGradient = SystemColorFactory .getColor(SWT.COLOR_TITLE_BACKGROUND_GRADIENT); /** * @see SWT#COLOR_TITLE_FOREGROUND */ Color titleForeground = SystemColorFactory .getColor(SWT.COLOR_TITLE_FOREGROUND); /** * @see SWT#COLOR_TITLE_INACTIVE_FOREGROUND */ Color titleInactiveForeground = SystemColorFactory .getColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND); /** * @see SWT#COLOR_TITLE_INACTIVE_BACKGROUND */ Color titleInactiveBackground = SystemColorFactory .getColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND); /** * @see SWT#COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT */ Color titleInactiveGradient = SystemColorFactory .getColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT); /** * @see SWT#COLOR_INFO_FOREGROUND */ Color tooltipForeground = SystemColorFactory .getColor(SWT.COLOR_INFO_FOREGROUND); /** * @see SWT#COLOR_INFO_BACKGROUND */ Color tooltipBackground = SystemColorFactory .getColor(SWT.COLOR_INFO_BACKGROUND); /* * Misc. colors */ /** One of the pre-defined colors */ Color white = new Color(null, 255, 255, 255); /** One of the pre-defined colors */ Color lightGray = new Color(null, 192, 192, 192); /** One of the pre-defined colors */ Color gray = new Color(null, 128, 128, 128); /** One of the pre-defined colors */ Color darkGray = new Color(null, 64, 64, 64); /** One of the pre-defined colors */ Color black = new Color(null, 0, 0, 0); /** One of the pre-defined colors */ Color red = new Color(null, 255, 0, 0); /** One of the pre-defined colors */ Color orange = new Color(null, 255, 196, 0); /** One of the pre-defined colors */ Color yellow = new Color(null, 255, 255, 0); /** One of the pre-defined colors */ Color green = new Color(null, 0, 255, 0); /** One of the pre-defined colors */ Color lightGreen = new Color(null, 96, 255, 96); /** One of the pre-defined colors */ Color darkGreen = new Color(null, 0, 127, 0); /** One of the pre-defined colors */ Color cyan = new Color(null, 0, 255, 255); /** One of the pre-defined colors */ Color lightBlue = new Color(null, 127, 127, 255); /** One of the pre-defined colors */ Color blue = new Color(null, 0, 0, 255); /** One of the pre-defined colors */ Color darkBlue = new Color(null, 0, 0, 127); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/CompoundBorder.java000066400000000000000000000067211166301720600272630ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Insets; /** * CompoundBorder allows for the nesting of two borders. The nested borders are * referred to as the inner and outer borders. */ public class CompoundBorder extends AbstractBorder { /** The inner Border. */ protected Border inner; /** The outer Border. */ protected Border outer; /** * Constructs a default CompoundBorder with no borders under it. * * @since 2.0 */ public CompoundBorder() { } /** * Constructs a CompoundBorder with the two borders specified as input. * * @param outer * Border which is drawn on the outside * @param inner * Border which is drawn inside the outer border * * @since 2.0 */ public CompoundBorder(Border outer, Border inner) { this.outer = outer; this.inner = inner; } /** * Returns the inner border of this CompoundBorder. * * @return The inner border * @since 2.0 */ public Border getInnerBorder() { return inner; } /** * Returns the total insets required to hold both the inner and outer * borders of this CompoundBorder. * * @param figure * Figure for which this is the border * @return The total insets for this border * @since 2.0 */ public Insets getInsets(IFigure figure) { Insets insets = null; if (inner != null) insets = inner.getInsets(figure); else insets = new Insets(); if (outer != null) { Insets moreInsets = outer.getInsets(figure); insets = insets.getAdded(moreInsets); } return insets; } /** * @see org.eclipse.draw2d.Border#getPreferredSize(IFigure) */ public Dimension getPreferredSize(IFigure fig) { Dimension prefSize = new Dimension(inner.getPreferredSize(fig)); Insets outerInsets = outer.getInsets(fig); prefSize.expand(outerInsets.getWidth(), outerInsets.getHeight()); prefSize.union(outer.getPreferredSize(fig)); return prefSize; } /** * Returns the outer border of this CompoundBorder. * * @return The outer border * @since 2.0 */ public Border getOuterBorder() { return outer; } /** * Returns true if this border is opaque. Return value is * dependent on the opaque state of both the borders it contains. Both * borders have to be opaque for this border to be opaque. In the absence of * any of the borders, this border is not opaque. * * @return true if this border is opaque */ public boolean isOpaque() { return ((inner != null) ? inner.isOpaque() : false) && ((outer != null) ? outer.isOpaque() : false); } /** * @see org.eclipse.draw2d.Border#paint(IFigure, Graphics, Insets) */ public void paint(IFigure figure, Graphics g, Insets insets) { if (outer != null) { g.pushState(); outer.paint(figure, g, insets); g.popState(); insets = insets.getAdded(outer.getInsets(figure)); } if (inner != null) inner.paint(figure, g, insets); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/Connection.java000066400000000000000000000056361166301720600264440ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.PointList; /** * A Connection is a figure that connects two objects. */ public interface Connection extends IFigure { /** * The connection router property. Used to signify that the ConnectionRouter * has changed. */ String PROPERTY_CONNECTION_ROUTER = "connectionRouter"; //$NON-NLS-1$ /** * The points property. Used to signify the points in the Connection have * changed. */ String PROPERTY_POINTS = "points"; //$NON-NLS-1$ /** * Returns the ConnectionRouter used to route this Connection. Does not * return null. * * @return The ConnectionRouter for this Connection */ ConnectionRouter getConnectionRouter(); /** * Sets the ConnectionRouter for this Connection. * * @param router * The ConnectionRouter to set for this Connection */ void setConnectionRouter(ConnectionRouter router); /** * Returns the ConnectionAnchor at the source end of this Connection. * * @return The ConnectionAnchor at the source end of this Connection */ ConnectionAnchor getSourceAnchor(); /** * Returns the ConnectionAnchor at the target end of this Connection. * * @return The ConnectionAnchor at the target end of this Connection */ ConnectionAnchor getTargetAnchor(); /** * Returns the routing constraint. May be null. * * @return The routing constraint */ Object getRoutingConstraint(); /** * Sets the routing constraint used by the router. * * @param cons * The routing constraint */ void setRoutingConstraint(Object cons); /** * Sets the ConnectionAnchor to be used at the source end of this * Connection. * * @param anchor * The source anchor */ void setSourceAnchor(ConnectionAnchor anchor); /** * Sets the ConnectionAnchor to be used at the target end of this * Connection. * * @param anchor * The target anchor */ void setTargetAnchor(ConnectionAnchor anchor); /** * Returns the PointList containing the Points that make up this Connection. * This may be returned by reference. * * @return The points for this Connection */ PointList getPoints(); /** * Sets the PointList containing the Points that make up this Connection. * * @param list * The points for this Connection */ void setPoints(PointList list); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ConnectionAnchor.java000066400000000000000000000036631166301720600275750ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Point; /** * An object to which a {@link Connection} will be anchored. If the * ConnectionAnchor moves, the Connection should move with it. */ public interface ConnectionAnchor { /** * Adds a listener interested in the movement of this ConnectionAnchor. * * @param listener * The AnchorListener to be added */ void addAnchorListener(AnchorListener listener); /** * Returns the location where the Connection should be anchored in absolute * coordinates. The anchor may use the given reference Point to calculate * this location. * * @param reference * The reference Point in absolute coordinates * @return The anchor's location */ Point getLocation(Point reference); /** * Returns the IFigure that contains this ConnectionAnchor. Moving this * figure will cause the anchor to move with it. * * @return The IFigure that contains this ConnectionAnchor */ IFigure getOwner(); /** * Returns the reference point for this anchor in absolute coordinates. This * might be used by another anchor to determine its own location (i.e. * {@link ChopboxAnchor}). * * @return The reference Point */ Point getReferencePoint(); /** * Removes the listener. * * @param listener * The AnchorListener to be removed */ void removeAnchorListener(AnchorListener listener); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ConnectionAnchorBase.java000066400000000000000000000032721166301720600303640ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /** * Provides support for a ConnectionAnchor. A ConnectionAnchor is one of the end * points of a {@link Connection}. It holds listeners and notifies them if the * anchor is moved. */ public abstract class ConnectionAnchorBase implements ConnectionAnchor { /** * The list of listeners */ protected List listeners = new ArrayList(1); /** * @see org.eclipse.draw2d.ConnectionAnchor#addAnchorListener(AnchorListener) */ public void addAnchorListener(AnchorListener listener) { listeners.add(listener); } /** * @see org.eclipse.draw2d.ConnectionAnchor#removeAnchorListener(AnchorListener) */ public void removeAnchorListener(AnchorListener listener) { listeners.remove(listener); } /** * Notifies all the listeners in the list of a change in position of this * anchor. This is called from one of the implementing anchors when its * location is changed. * * @since 2.0 */ protected void fireAnchorMoved() { Iterator iter = listeners.iterator(); while (iter.hasNext()) ((AnchorListener) iter.next()).anchorMoved(this); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ConnectionEndpointLocator.java000066400000000000000000000172371166301720600314710ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.draw2d.geometry.Transposer; /** * Used to place IFigures along the endpoint or starting point of a * {@link Connection}. uDistance represents the distance from the * Connection's owner to the IFigure. vDistance represents the * distance from the IFigure to the Connection itself. */ public class ConnectionEndpointLocator implements Locator { private boolean end; private Connection conn; private int uDistance; private int vDistance; private static Rectangle figureBounds; /** * Transposes the location if the connection point is along the top or * bottom of its owner figure. */ protected Transposer transposer = new Transposer(); /** * Constructs a ConnectionEndpointLocator using the given {@link Connection} * . If isEnd is true, the location is relative to the * Connection's end (or target) point. If isEnd is false * , the location is relative to the Connection's start (or source) point. * * @param c * The Connection * @param isEnd * true is location is relative to end point * @since 2.0 */ public ConnectionEndpointLocator(Connection c, boolean isEnd) { end = isEnd; conn = c; uDistance = 14; vDistance = 4; figureBounds = new Rectangle(); } /* * Returns an integer representing the side of the passed Rectangle that a * point lies on. 1 == Top 2 == Right 3 == Bottom 4 == Left * * @param loc The point that is to be located */ private int calculateConnectionLocation(Point loc, Point topLeft, Point center) { double m1, m2 = 0; m1 = (double) (topLeft.y - center.y) / (double) (topLeft.x - center.x); if (loc.x - center.x != 0) m2 = (double) (loc.y - center.y) / (double) (loc.x - center.x); if (loc.x == center.x) { // Case where m2 is vertical if (loc.y < center.y) return 3; else return 1; } else if (Math.abs(m2) <= Math.abs(m1)) { // Connection start point along left or right side if (loc.x < center.x) return 4; else return 2; } else { // Connection start point along top or bottom if (loc.y < center.y) return 3; else return 1; } } /* * This method is used to calculate the "quadrant" value of a connection * that does not have an owner on its starting point. * * 1 == Top 2 == Right 3 == Bottom 4 == Left * * @param startPoint The starting point of the connection. * * @param endPoint The end point of the connection. */ private int calculateConnectionLocation(Point startPoint, Point endPoint) { if (Math.abs(endPoint.x - startPoint.x) > Math.abs(endPoint.y - startPoint.y)) { if (endPoint.x > startPoint.x) return 2; else return 4; } else { if (endPoint.y > startPoint.y) return 1; else return 3; } } /* * Calculates 'tan' which is used as a factor for y adjustment when placing * the connection label. 'tan' is capped at 1.0 in the positive direction * and -1.0 in the negative direction. * * @param startPoint The starting point of the connection. * * @param endPoint The end point of the connection. * * @since 2.0 */ private double calculateTan(Point startPoint, Point endPoint) { double tan = 0; if (endPoint.x == startPoint.x) tan = 1.0; else tan = (double) (endPoint.y - startPoint.y) / (double) (endPoint.x - startPoint.x); if (tan > 1) tan = 1.0; else if (tan < -1) tan = -1.0; return tan; } private int calculateYShift(int figureWidth, int figureHeight) { int yShift = 0; if (vDistance < 0) yShift = -figureHeight; else if (vDistance == 0) yShift = -figureHeight / 2; return yShift; } private Connection getConnection() { return conn; } private IFigure getConnectionOwner() { IFigure connOwner; if (isEnd()) connOwner = conn.getTargetAnchor().getOwner(); else connOwner = conn.getSourceAnchor().getOwner(); return connOwner; } /** * Returns the distance in pixels from the anchor's owner. * * @return the offset distance from the endpoint figure */ public int getUDistance() { return uDistance; } /** * Returns the distance in pixels from the connection * * @return the offset from the connection itself */ public int getVDistance() { return vDistance; } private boolean isEnd() { return end; } /** * Relocates the given IFigure at either the source or target end of the * Connection, based on the boolean given in the constructor * {@link #ConnectionEndpointLocator(Connection, boolean)}. * * @param figure * The figure to relocate */ public void relocate(IFigure figure) { Connection conn = getConnection(); Point startPoint = Point.SINGLETON; Point endPoint = new Point(); int startPointPosition = 0; int endPointPosition = 1; if (isEnd()) { startPointPosition = conn.getPoints().size() - 1; endPointPosition = startPointPosition - 1; } conn.getPoints().getPoint(startPoint, startPointPosition); conn.getPoints().getPoint(endPoint, endPointPosition); IFigure connOwner = getConnectionOwner(); int quadrant; if (connOwner != null) { Rectangle connOwnerBounds = connOwner.getBounds(); Point connOwnerCenter = connOwnerBounds.getCenter(); Point connOwnerTL = connOwnerBounds.getTopLeft(); quadrant = calculateConnectionLocation(startPoint, connOwnerTL, connOwnerCenter); } else quadrant = calculateConnectionLocation(startPoint, endPoint); int cos = 1; transposer.setEnabled(false); /* * Label placement calculations are done as if the connection point is * along the left or right side of the figure. If the connection point * is along the top or bottom, values are transposed. */ if (quadrant == 1 || quadrant == 3) transposer.setEnabled(true); if (quadrant == 3 || quadrant == 4) cos = -1; Dimension figureSize = transposer.t(figure.getPreferredSize()); startPoint = transposer.t(startPoint); endPoint = transposer.t(endPoint); double tan = calculateTan(startPoint, endPoint); int figureWidth = figureSize.width; int figureHeight = figureSize.height; int yShift = calculateYShift(figureWidth, figureHeight); Point figurePoint = new Point(startPoint.x + (uDistance * cos) + figureWidth * ((cos - 1) / 2), (int) (startPoint.y + cos * uDistance * tan + vDistance + yShift)); figureBounds.setSize(transposer.t(figureSize)); figureBounds.setLocation(transposer.t(figurePoint)); figure.setBounds(figureBounds); } /** * Sets the distance in pixels from the Connection's owner. * * @param distance * Number of pixels to place the ConnectionEndpointLocator from * its owner. * @since 2.0 */ public void setUDistance(int distance) { uDistance = distance; } /** * Sets the distance in pixels from the Connection. * * @param distance * Number of pixels to place the ConnectionEndpointLocator from * its Connection. * @since 2.0 */ public void setVDistance(int distance) { vDistance = distance; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ConnectionLayer.java000066400000000000000000000067751166301720600274460ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation * Research Group Software Construction, * RWTH Aachen University, Germany - Contribution for Bugzilla 195527 *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.SWT; /** * Layer designed specifically to handle the presence of connections. This is * done due to the necessity of having a router for the connections added. */ public class ConnectionLayer extends FreeformLayer { int antialias = SWT.DEFAULT; /** * The ConnectionRouter used to route all connections on this layer. */ protected ConnectionRouter connectionRouter; /** * Adds the given figure with the given contraint at the given index. If the * figure is a {@link Connection}, its {@link ConnectionRouter} is set. * * @param figure * Figure being added * @param constraint * Constraint of the figure being added * @param index * Index where the figure is to be added * @since 2.0 */ public void add(IFigure figure, Object constraint, int index) { super.add(figure, constraint, index); // If the connection layout manager is set, then every // figure added should use this layout manager. if (figure instanceof Connection && getConnectionRouter() != null) ((Connection) figure).setConnectionRouter(getConnectionRouter()); } /** * Returns the ConnectionRouter being used by this layer. * * @return ConnectionRouter being used by this layer * @since 2.0 */ public ConnectionRouter getConnectionRouter() { return connectionRouter; } /** * @see IFigure#paint(Graphics) */ public void paint(Graphics graphics) { if (antialias != SWT.DEFAULT) graphics.setAntialias(antialias); super.paint(graphics); } /** * Removes the figure from this Layer. If the figure is a {@link Connection} * , that Connection's {@link ConnectionRouter} is set to null. * * @param figure * The figure to remove */ public void remove(IFigure figure) { if (figure instanceof Connection) ((Connection) figure).setConnectionRouter(null); super.remove(figure); } /** * Sets the ConnectionRouter for this layer. This router is set as the * ConnectionRouter for all the child connections of this Layer. * * @param router * The ConnectionRouter to set for this Layer * @since 2.0 */ public void setConnectionRouter(ConnectionRouter router) { connectionRouter = router; FigureIterator iter = new FigureIterator(this); IFigure figure; while (iter.hasNext()) { figure = iter.nextFigure(); if (figure instanceof Connection) ((Connection) figure).setConnectionRouter(router); } } /** * Sets whether antialiasing should be enabled for the connection layer. If * this value is set to something other than {@link SWT#DEFAULT}, * {@link Graphics#setAntialias(int)} will be called with the given value * when painting this layer. * * @param antialias * the antialias setting * @since 3.1 */ public void setAntialias(int antialias) { this.antialias = antialias; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ConnectionLocator.java000066400000000000000000000106531166301720600277630ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.PointList; /** * Repositions a {@link Figure} attached to a {@link Connection} when the * Connection is moved. Provides for alignment at the start (source), middle, or * end (target) of the Connection. */ public class ConnectionLocator extends AbstractLocator { /** @deprecated Use {@link #SOURCE} */ public static final int START = 2; /** The start (or source) of the Connection */ public static final int SOURCE = 2; /** @deprecated Use {@link #TARGET} */ public static final int END = 3; /** The end (or target) of the Connection */ public static final int TARGET = 3; /** * @deprecated Use {@link #MIDDLE} instead, since the location is not the * midpoint of a line-segment, but the middle of a polyline. */ public static final int MIDPOINT = 4; /** The middle of the Connection */ public static final int MIDDLE = 4; private Connection connection; private int alignment; /** * Constructs a ConnectionLocator with the passed connection and * {@link #MIDDLE} alignment. * * @param connection * The Connection * @since 2.0 */ public ConnectionLocator(Connection connection) { this(connection, MIDDLE); } /** * Constructs a ConnectionLocator with the passed Connection and alignment. * Valid values for the alignment are integer constants {@link #SOURCE}, * {@link #MIDDLE}, and {@link #TARGET}. * * @param connection * The Connection * @param align * The alignment * * @since 2.0 */ public ConnectionLocator(Connection connection, int align) { setConnection(connection); setAlignment(align); } /** * Returns the alignment of ConnectionLocator. * * @return The alignment * @since 2.0 */ public int getAlignment() { return alignment; } /** * Returns connection associated with ConnectionLocator. * * @return The Connection * @since 2.0 */ protected Connection getConnection() { return connection; } /** * Returns ConnectionLocator's reference point in absolute coordinates. * * @return The reference point * @since 2.0 */ protected Point getReferencePoint() { Point p = getLocation(getConnection().getPoints()); getConnection().translateToAbsolute(p); return p; } /** * Returns a point from the passed PointList, dependent on * ConnectionLocator's alignment. If the alignment is {@link #SOURCE}, it * returns the first point in points. If {@link #TARGET}, it returns * the last point in points. If {@link #MIDDLE}, it returns the * middle of line represented by points. * * @param points * The points in the Connection * @return The location * @since 2.0 */ protected Point getLocation(PointList points) { switch (getAlignment()) { case SOURCE: return points.getPoint(Point.SINGLETON, 0); case TARGET: return points.getPoint(Point.SINGLETON, points.size() - 1); case MIDDLE: if (points.size() % 2 == 0) { int i = points.size() / 2; int j = i - 1; Point p1 = points.getPoint(j); Point p2 = points.getPoint(i); Dimension d = p2.getDifference(p1); return Point.SINGLETON.setLocation(p1.x + d.width / 2, p1.y + d.height / 2); } int i = (points.size() - 1) / 2; return points.getPoint(Point.SINGLETON, i); default: return new Point(); } } /** * Sets the alignment. Possible values are {@link #SOURCE}, {@link #MIDDLE}, * and {@link #TARGET}. * * @param align * The alignment * @since 2.0 */ protected void setAlignment(int align) { alignment = align; } /** * Sets the Connection to be associated with this ConnectionLocator. * * @param connection * The Connection * @since 2.0 */ protected void setConnection(Connection connection) { this.connection = connection; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ConnectionRouter.java000066400000000000000000000047021166301720600276360ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.PointList; /** * Routes a {@link Connection}, possibly using a constraint. */ public interface ConnectionRouter { /** * The default router for Connections. */ ConnectionRouter NULL = new NullConnectionRouter(); /** * Returns the constraint for the Connection. * * @param connection * The connection * @return The constraint */ Object getConstraint(Connection connection); /** * Invalidates the given Connection. * * @param connection * The connection to be invalidated */ void invalidate(Connection connection); /** * Routes the Connection. * * @param connection * The Connection to route */ void route(Connection connection); /** * Removes the Connection from this router. * * @param connection * The Connection to remove */ void remove(Connection connection); /** * Maps the given constraint to the given Connection. * * @param connection * The Connection * @param constraint * The constraint */ void setConstraint(Connection connection, Object constraint); /** * Routes Connections directly from the source anchor to the target anchor * with no bendpoints in between. */ class NullConnectionRouter extends AbstractRouter { /** * Constructs a new NullConnectionRouter. */ NullConnectionRouter() { } /** * Routes the given Connection directly between the source and target * anchors. * * @param conn * the connection to be routed */ public void route(Connection conn) { PointList points = conn.getPoints(); points.removeAllPoints(); Point p; conn.translateToRelative(p = getStartPoint(conn)); points.addPoint(p); conn.translateToRelative(p = getEndPoint(conn)); points.addPoint(p); conn.setPoints(points); } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/CoordinateListener.java000066400000000000000000000016201166301720600301270ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; /** * @since 3.1 */ public interface CoordinateListener { /** * Indicates that the coordinate system has changed in a way that affects * the absolute locations of contained figures. * * @param source * the figure whose coordinate system changed * @since 3.1 */ void coordinateSystemChanged(IFigure source); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/Cursors.java000066400000000000000000000126431166301720600260010ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Cursor; /** * A collection of cursors. */ public class Cursors { /** * Returns the cursor corresponding to the given direction, defined in * {@link PositionConstants}. Note that * {@link #getDirectionalCursor(int, boolean)} should be used for * applications which want to run properly when running in a mirrored * environment. The behavior is the same as calling * {@link #getDirectionalCursor(int, boolean) * getDirectionalCursor(direction, false)}. * * @param direction * the relative direction of the desired cursor * @return The appropriate directional cursor */ public static Cursor getDirectionalCursor(int direction) { return getDirectionalCursor(direction, false); } /** * Returns the cursor corresponding to the given direction and mirroring. * The direction must be one of: *
    *
  • {@link PositionConstants#NORTH} *
  • {@link PositionConstants#SOUTH} *
  • {@link PositionConstants#EAST} *
  • {@link PositionConstants#WEST} *
  • {@link PositionConstants#NORTH_EAST} *
  • {@link PositionConstants#NORTH_WEST} *
  • {@link PositionConstants#SOUTH_EAST} *
  • {@link PositionConstants#SOUTH_WEST} *
*

* The behavior is undefined for other values. If isMirrored is * set to true, EAST and WEST will be inverted. * * @param direction * the relative direction of the desired cursor * @param isMirrored * true if EAST and WEST should be inverted * @return The appropriate directional cursor */ public static Cursor getDirectionalCursor(int direction, boolean isMirrored) { if (isMirrored && (direction & PositionConstants.EAST_WEST) != 0) direction = direction ^ PositionConstants.EAST_WEST; switch (direction) { case PositionConstants.NORTH: return SIZEN; case PositionConstants.SOUTH: return SIZES; case PositionConstants.EAST: return SIZEE; case PositionConstants.WEST: return SIZEW; case PositionConstants.SOUTH_EAST: return SIZESE; case PositionConstants.SOUTH_WEST: return SIZESW; case PositionConstants.NORTH_EAST: return SIZENE; case PositionConstants.NORTH_WEST: return SIZENW; default: break; } return null; } /** * @see SWT#CURSOR_ARROW */ public static final Cursor ARROW; /** * @see SWT#CURSOR_SIZEN */ public static final Cursor SIZEN; /** * @see SWT#CURSOR_SIZENE */ public static final Cursor SIZENE; /** * @see SWT#CURSOR_SIZEE */ public static final Cursor SIZEE; /** * @see SWT#CURSOR_SIZESE */ public static final Cursor SIZESE; /** * @see SWT#CURSOR_SIZES */ public static final Cursor SIZES; /** * @see SWT#CURSOR_SIZESW */ public static final Cursor SIZESW; /** * @see SWT#CURSOR_SIZEW */ public static final Cursor SIZEW; /** * @see SWT#CURSOR_SIZENW */ public static final Cursor SIZENW; /** * @see SWT#CURSOR_APPSTARTING */ public static final Cursor APPSTARTING; /** * @see SWT#CURSOR_CROSS */ public static final Cursor CROSS; /** * @see SWT#CURSOR_HAND */ public static final Cursor HAND; /** * @see SWT#CURSOR_HELP */ public static final Cursor HELP; /** * @see SWT#CURSOR_IBEAM */ public static final Cursor IBEAM; /** * @see SWT#CURSOR_NO */ public static final Cursor NO; /** * @see SWT#CURSOR_SIZEALL */ public static final Cursor SIZEALL; /** * @see SWT#CURSOR_SIZENESW */ public static final Cursor SIZENESW; /** * @see SWT#CURSOR_SIZENWSE */ public static final Cursor SIZENWSE; /** * @see SWT#CURSOR_SIZEWE */ public static final Cursor SIZEWE; /** * @see SWT#CURSOR_SIZENS */ public static final Cursor SIZENS; /** * @see SWT#CURSOR_UPARROW */ public static final Cursor UPARROW; /** * @see SWT#CURSOR_WAIT */ public static final Cursor WAIT; static { ARROW = new Cursor(null, SWT.CURSOR_ARROW); SIZEN = new Cursor(null, SWT.CURSOR_SIZEN); SIZENE = new Cursor(null, SWT.CURSOR_SIZENE); SIZEE = new Cursor(null, SWT.CURSOR_SIZEE); SIZESE = new Cursor(null, SWT.CURSOR_SIZESE); SIZES = new Cursor(null, SWT.CURSOR_SIZES); SIZESW = new Cursor(null, SWT.CURSOR_SIZESW); SIZEW = new Cursor(null, SWT.CURSOR_SIZEW); SIZENW = new Cursor(null, SWT.CURSOR_SIZENW); SIZENS = new Cursor(null, SWT.CURSOR_SIZENS); SIZEWE = new Cursor(null, SWT.CURSOR_SIZEWE); APPSTARTING = new Cursor(null, SWT.CURSOR_APPSTARTING); CROSS = new Cursor(null, SWT.CURSOR_CROSS); HAND = new Cursor(null, SWT.CURSOR_HAND); HELP = new Cursor(null, SWT.CURSOR_HELP); IBEAM = new Cursor(null, SWT.CURSOR_IBEAM); NO = new Cursor(null, SWT.CURSOR_NO); SIZEALL = new Cursor(null, SWT.CURSOR_SIZEALL); SIZENESW = new Cursor(null, SWT.CURSOR_SIZENESW); SIZENWSE = new Cursor(null, SWT.CURSOR_SIZENWSE); UPARROW = new Cursor(null, SWT.CURSOR_UPARROW); WAIT = new Cursor(null, SWT.CURSOR_WAIT); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/DefaultRangeModel.java000066400000000000000000000124711166301720600276620ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; /** * Generic implementation for a RangeModel. * * *

 *                    |<----extent--->|                     
 *    ----|-----------|---------------|---------------|----
 *       min          |                              max
 *                  value
 * 
*/ public class DefaultRangeModel implements RangeModel { /** * Listeners interested in the range model's property changes. */ protected PropertyChangeSupport propertyListeners = new PropertyChangeSupport( this); private int minimum = 0; private int maximum = 100; private int extent = 20; private int value = 0; /** * Registers the given listener as a PropertyChangeListener. * * @param listener * the listener to be added * @since 2.0 */ public void addPropertyChangeListener(PropertyChangeListener listener) { propertyListeners.addPropertyChangeListener(listener); } /** * Notifies any listening PropertyChangeListeners that the property with the * given id has changed. * * @param string * the property name * @param oldValue * the old value * @param newValue * the new value * @since 2.0 */ protected void firePropertyChange(String string, int oldValue, int newValue) { propertyListeners.firePropertyChange(string, oldValue, newValue); } /** * @return the extent */ public int getExtent() { return extent; } /** * @return the maximum value */ public int getMaximum() { return maximum; } /** * @return the minimum value */ public int getMinimum() { return minimum; } /** * @return the current value */ public int getValue() { return value; } /** * @return whether the extent is between the minimum and maximum values */ public boolean isEnabled() { return (getMaximum() - getMinimum()) > getExtent(); } /** * Removes the given PropertyChangeListener from the list of listeners. * * @param listener * the listener to be removed */ public void removePropertyChangeListener(PropertyChangeListener listener) { propertyListeners.removePropertyChangeListener(listener); } /** * @see org.eclipse.draw2d.RangeModel#setAll(int, int, int) */ public void setAll(int min, int ext, int max) { int oldMin = minimum; int oldExtent = extent; int oldMax = maximum; maximum = max; minimum = min; extent = ext; if (oldMax != max) firePropertyChange(PROPERTY_MAXIMUM, oldMax, max); if (oldExtent != ext) firePropertyChange(PROPERTY_EXTENT, oldExtent, ext); if (oldMin != min) firePropertyChange(PROPERTY_MINIMUM, oldMin, min); setValue(getValue()); } /** * Sets this RangeModel's extent and fires a property change if the given * value is different from the current extent. * * @param extent * the new extent value */ public void setExtent(int extent) { if (this.extent == extent) return; int oldValue = this.extent; this.extent = extent; firePropertyChange(PROPERTY_EXTENT, oldValue, extent); setValue(getValue()); } /** * Sets this RangeModel's maximum value and fires a property change if the * given value is different from the current maximum value. * * @param maximum * the new maximum value */ public void setMaximum(int maximum) { if (this.maximum == maximum) return; int oldValue = this.maximum; this.maximum = maximum; firePropertyChange(PROPERTY_MAXIMUM, oldValue, maximum); setValue(getValue()); } /** * Sets this RangeModel's minimum value and fires a property change if the * given value is different from the current minimum value. * * @param minimum * the new minumum value */ public void setMinimum(int minimum) { if (this.minimum == minimum) return; int oldValue = this.minimum; this.minimum = minimum; firePropertyChange(PROPERTY_MINIMUM, oldValue, minimum); setValue(getValue()); } /** * Sets this RangeModel's current value. If the given value is greater than * the maximum, the maximum value is used. If the given value is less than * the minimum, the minimum value is used. If the adjusted value is * different from the current value, a property change is fired. * * @param value * the new value */ public void setValue(int value) { value = Math.max(getMinimum(), Math.min(getMaximum() - getExtent(), value)); if (this.value == value) return; int oldValue = this.value; this.value = value; firePropertyChange(PROPERTY_VALUE, oldValue, value); } /** * @see java.lang.Object#toString() */ public String toString() { return super.toString() + " (" + minimum + ", " + maximum //$NON-NLS-2$ //$NON-NLS-1$ + ", " + extent + ", " + value + ")"; //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/DeferredUpdateManager.java000066400000000000000000000211611166301720600305120ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import org.eclipse.swt.SWT; import org.eclipse.swt.SWTException; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.widgets.Display; import org.eclipse.draw2d.geometry.Rectangle; /** * An UpdateManager that asynchronously updates the affected figures. */ public class DeferredUpdateManager extends UpdateManager { /** * Calls {@link DeferredUpdateManager#performUpdate()}. */ protected class UpdateRequest implements Runnable { public UpdateRequest() { super(); } /** * Calls {@link DeferredUpdateManager#performUpdate()}. */ public void run() { performUpdate(); } } private Rectangle damage; private Map dirtyRegions = new HashMap(); private GraphicsSource graphicsSource; private List invalidFigures = new ArrayList(); private IFigure root; private boolean updateQueued; private boolean updating; private boolean validating; private RunnableChain afterUpdate; private static class RunnableChain { RunnableChain next; Runnable run; RunnableChain(Runnable run, RunnableChain next) { this.run = run; this.next = next; } void run() { if (next != null) next.run(); run.run(); } } /** * Empty constructor. */ public DeferredUpdateManager() { } /** * Constructs a new DererredUpdateManager with the given GraphicsSource. * * @param gs * the graphics source */ public DeferredUpdateManager(GraphicsSource gs) { setGraphicsSource(gs); } /** * Adds a dirty region (defined by the rectangle x, y, w, h) to the * update queue. If the figure isn't visible or either the width or height * are 0, the method returns without queueing the dirty region. * * @param figure * the figure that contains the dirty region * @param x * the x coordinate of the dirty region * @param y * the y coordinate of the dirty region * @param w * the width of the dirty region * @param h * the height of the dirty region */ public synchronized void addDirtyRegion(IFigure figure, int x, int y, int w, int h) { if (w == 0 || h == 0 || !figure.isShowing()) return; Rectangle rect = (Rectangle) dirtyRegions.get(figure); if (rect == null) { rect = new Rectangle(x, y, w, h); dirtyRegions.put(figure, rect); } else rect.union(x, y, w, h); queueWork(); } /** * Adds the given figure to the update queue. Invalid figures will be * validated before the damaged regions are repainted. * * @param f * the invalid figure */ public synchronized void addInvalidFigure(IFigure f) { if (invalidFigures.contains(f)) return; queueWork(); invalidFigures.add(f); } /** * Returns a Graphics object for the given region. * * @param region * the region to be repainted * @return the Graphics object */ protected Graphics getGraphics(Rectangle region) { if (graphicsSource == null) return null; return graphicsSource.getGraphics(region); } void paint(GC gc) { if (!validating) { SWTGraphics graphics = new SWTGraphics(gc); if (!updating) { /** * If a paint occurs not as part of an update, we should notify * that the region is being painted. Otherwise, notification * already occurs in repairDamage(). */ Rectangle rect = graphics.getClip(new Rectangle()); HashMap map = new HashMap(); map.put(root, rect); firePainting(rect, map); } performValidation(); root.paint(graphics); graphics.dispose(); } else { /* * If figures are being validated then we can simply add a dirty * region here and update will repaint this region with other dirty * regions when it gets to painting. We can't paint if we're not * sure that all figures are valid. */ addDirtyRegion(root, new Rectangle(gc.getClipping())); } } /** * Performs the update. Validates the invalid figures and then repaints the * dirty regions. * * @see #validateFigures() * @see #repairDamage() */ public synchronized void performUpdate() { if (isDisposed() || updating) return; updating = true; try { performValidation(); updateQueued = false; repairDamage(); if (afterUpdate != null) { RunnableChain chain = afterUpdate; afterUpdate = null; chain.run(); // chain may queue additional Runnable. if (afterUpdate != null) queueWork(); } } finally { updating = false; } } /** * @see UpdateManager#performValidation() */ public synchronized void performValidation() { if (invalidFigures.isEmpty() || validating) return; try { IFigure fig; validating = true; fireValidating(); for (int i = 0; i < invalidFigures.size(); i++) { fig = (IFigure) invalidFigures.get(i); invalidFigures.set(i, null); fig.validate(); } } finally { invalidFigures.clear(); validating = false; } } /** * Adds the given exposed region to the update queue and then performs the * update. * * @param exposed * the exposed region */ public synchronized void performUpdate(Rectangle exposed) { addDirtyRegion(root, exposed); performUpdate(); } /** * Posts an {@link UpdateRequest} using {@link Display#asyncExec(Runnable)}. * If work has already been queued, a new request is not needed. */ protected void queueWork() { if (!updateQueued) { sendUpdateRequest(); updateQueued = true; } } /** * Fires the UpdateRequest to the current display * asynchronously. * * @since 3.2 */ protected void sendUpdateRequest() { Display display = Display.getCurrent(); if (display == null) { throw new SWTException(SWT.ERROR_THREAD_INVALID_ACCESS); } display.asyncExec(new UpdateRequest()); } /** * Releases the graphics object, which causes the GraphicsSource to flush. * * @param graphics * the graphics object */ protected void releaseGraphics(Graphics graphics) { graphics.dispose(); graphicsSource.flushGraphics(damage); } /** * Repaints the dirty regions on the update queue and calls * {@link UpdateManager#firePainting(Rectangle, Map)}, unless there are no * dirty regions. */ protected void repairDamage() { Iterator keys = dirtyRegions.keySet().iterator(); Rectangle contribution; IFigure figure; IFigure walker; while (keys.hasNext()) { figure = (IFigure) keys.next(); walker = figure.getParent(); contribution = (Rectangle) dirtyRegions.get(figure); // A figure can't paint beyond its own bounds contribution.intersect(figure.getBounds()); while (!contribution.isEmpty() && walker != null) { walker.translateToParent(contribution); contribution.intersect(walker.getBounds()); walker = walker.getParent(); } if (damage == null) damage = new Rectangle(contribution); else damage.union(contribution); } if (!dirtyRegions.isEmpty()) { Map oldRegions = dirtyRegions; dirtyRegions = new HashMap(); firePainting(damage, oldRegions); } if (damage != null && !damage.isEmpty()) { // ystem.out.println(damage); Graphics graphics = getGraphics(damage); if (graphics != null) { root.paint(graphics); releaseGraphics(graphics); } } damage = null; } /** * Adds the given runnable and queues an update if an update is not under * progress. * * @param runnable * the runnable */ public synchronized void runWithUpdate(Runnable runnable) { afterUpdate = new RunnableChain(runnable, afterUpdate); if (!updating) queueWork(); } /** * Sets the graphics source. * * @param gs * the graphics source */ public void setGraphicsSource(GraphicsSource gs) { graphicsSource = gs; } /** * Sets the root figure. * * @param figure * the root figure */ public void setRoot(IFigure figure) { root = figure; } /** * Validates all invalid figures on the update queue and calls * {@link UpdateManager#fireValidating()} unless there are no invalid * figures. */ protected void validateFigures() { performValidation(); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/DelegatingLayout.java000066400000000000000000000057501166301720600276030ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.HashMap; import java.util.List; import java.util.Map; import org.eclipse.draw2d.geometry.Dimension; /** * Figures using a DelegatingLayout as their layout manager give location * responsibilities to their children. The children of a Figure using a * DelegatingLayout should have a {@link Locator Locator} as a constraint whose * {@link Locator#relocate(IFigure target) relocate} method is responsible for * placing the child. */ public class DelegatingLayout extends AbstractLayout { private Map constraints = new HashMap(); /** * Calculates the preferred size of the given Figure. For the * DelegatingLayout, this is the largest width and height values of the * passed Figure's children. * * @param parent * the figure whose preferred size is being calculated * @param wHint * the width hint * @param hHint * the height hint * @return the preferred size * @since 2.0 */ protected Dimension calculatePreferredSize(IFigure parent, int wHint, int hHint) { List children = parent.getChildren(); Dimension d = new Dimension(); for (int i = 0; i < children.size(); i++) { IFigure child = (IFigure) children.get(i); d.union(child.getPreferredSize()); } return d; } /** * @see org.eclipse.draw2d.LayoutManager#getConstraint(org.eclipse.draw2d.IFigure) */ public Object getConstraint(IFigure child) { return constraints.get(child); } /** * Lays out the given figure's children based on their {@link Locator} * constraint. * * @param parent * the figure whose children should be layed out */ public void layout(IFigure parent) { List children = parent.getChildren(); for (int i = 0; i < children.size(); i++) { IFigure child = (IFigure) children.get(i); Locator locator = (Locator) constraints.get(child); if (locator != null) { locator.relocate(child); } } } /** * Removes the locator for the given figure. * * @param child * the child being removed */ public void remove(IFigure child) { constraints.remove(child); } /** * Sets the constraint for the given figure. * * @param figure * the figure whose contraint is being set * @param constraint * the new constraint */ public void setConstraint(IFigure figure, Object constraint) { super.setConstraint(figure, constraint); if (constraint != null) constraints.put(figure, constraint); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/Ellipse.java000066400000000000000000000043101166301720600257260ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation * Alex Selkov - Fix for Bug# 22701 *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Rectangle; /** * An figure that draws an ellipse filling its bounds. */ public class Ellipse extends Shape { /** * Constructs a new Ellipse with the default values of a Shape. * * @since 2.0 */ public Ellipse() { } /** * Returns true if the given point (x,y) is contained within * this ellipse. * * @param x * the x coordinate * @param y * the y coordinate * @return trueif the given point is contained */ public boolean containsPoint(int x, int y) { if (!super.containsPoint(x, y)) { return false; } else { Rectangle r = getBounds(); long ux = x - r.x - r.width / 2; long uy = y - r.y - r.height / 2; return ((ux * ux) << 10) / (r.width * r.width) + ((uy * uy) << 10) / (r.height * r.height) <= 256; } } /** * Fills the ellipse. * * @see org.eclipse.draw2d.Shape#fillShape(org.eclipse.draw2d.Graphics) */ protected void fillShape(Graphics graphics) { graphics.fillOval(getOptimizedBounds()); } /** * Outlines the ellipse. * * @see org.eclipse.draw2d.Shape#outlineShape(org.eclipse.draw2d.Graphics) */ protected void outlineShape(Graphics graphics) { graphics.drawOval(getOptimizedBounds()); } private Rectangle getOptimizedBounds() { float lineInset = Math.max(1.0f, getLineWidthFloat()) / 2.0f; int inset1 = (int) Math.floor(lineInset); int inset2 = (int) Math.ceil(lineInset); Rectangle r = Rectangle.SINGLETON.setBounds(getBounds()); r.x += inset1; r.y += inset1; r.width -= inset1 + inset2; r.height -= inset1 + inset2; return r; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/EllipseAnchor.java000066400000000000000000000042011166301720600270600ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; /** * Similar to a {@link org.eclipse.draw2d.ChopboxAnchor}, except this anchor is * located on the ellipse defined by the owners bounding box. * * @author Alex Selkov Created 31.08.2002 23:11:43 */ public class EllipseAnchor extends AbstractConnectionAnchor { /** * @see org.eclipse.draw2d.AbstractConnectionAnchor#AbstractConnectionAnchor() */ public EllipseAnchor() { } /** * @see org.eclipse.draw2d.AbstractConnectionAnchor#AbstractConnectionAnchor(IFigure) */ public EllipseAnchor(IFigure owner) { super(owner); } /** * Returns a point on the ellipse (defined by the owner's bounding box) * where the connection should be anchored. * * @see org.eclipse.draw2d.ConnectionAnchor#getLocation(Point) */ public Point getLocation(Point reference) { Rectangle r = Rectangle.SINGLETON; r.setBounds(getOwner().getBounds()); r.translate(-1, -1); r.resize(1, 1); getOwner().translateToAbsolute(r); Point ref = r.getCenter().negate().translate(reference); if (ref.x == 0) return new Point(reference.x, (ref.y > 0) ? r.bottom() : r.y); if (ref.y == 0) return new Point((ref.x > 0) ? r.right() : r.x, reference.y); float dx = (ref.x > 0) ? 0.5f : -0.5f; float dy = (ref.y > 0) ? 0.5f : -0.5f; // ref.x, ref.y, r.width, r.height != 0 => safe to proceed float k = (float) (ref.y * r.width) / (ref.x * r.height); k = k * k; return r.getCenter().translate((int) (r.width * dx / Math.sqrt(1 + k)), (int) (r.height * dy / Math.sqrt(1 + 1 / k))); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/EventDispatcher.java000066400000000000000000000121021166301720600274170ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.accessibility.AccessibleControlEvent; import org.eclipse.swt.accessibility.AccessibleControlListener; import org.eclipse.swt.accessibility.AccessibleListener; import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.TraverseEvent; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Event; /** * Listens to various SWT events and dispatches these events to interested * Draw2d objects. */ public abstract class EventDispatcher { /** * Combines {@link AccessibleControlListener} and {@link AccessibleListener} * . Implements * {@link AccessibleControlListener#getChild(AccessibleControlEvent)} to do * nothing. */ public abstract static class AccessibilityDispatcher implements AccessibleControlListener, AccessibleListener { /** @see AccessibleControlListener#getChild(AccessibleControlEvent) */ public void getChild(AccessibleControlEvent e) { } } /** * Dispatches a focus gained event. * * @param e * the event */ public abstract void dispatchFocusGained(FocusEvent e); /** * Dispatches a focus lost event. * * @param e * the event */ public abstract void dispatchFocusLost(FocusEvent e); /** * Dispatches a key pressed event. * * @param e * the event */ public abstract void dispatchKeyPressed(KeyEvent e); /** * Dispatches a key released event. * * @param e * the event */ public abstract void dispatchKeyReleased(KeyEvent e); /** * Dispatches a key traversed event. * * @param e * the event */ public abstract void dispatchKeyTraversed(TraverseEvent e); /** * Dispatches a mouse double clicked event. * * @param me * the event */ public abstract void dispatchMouseDoubleClicked(MouseEvent me); /** * Dispatches a mouse entered event. * * @param e * the event */ public abstract void dispatchMouseEntered(MouseEvent e); /** * Dispatches a mouse exited event. * * @param e * the event */ public abstract void dispatchMouseExited(MouseEvent e); /** * Dispatches a mouse hover event. * * @param me * the event */ public abstract void dispatchMouseHover(MouseEvent me); /** * Dispatches a moved event event. * * @param me * the event */ public abstract void dispatchMouseMoved(MouseEvent me); /** * Dispatches a mouse pressed event. * * @param me * the event */ public abstract void dispatchMousePressed(MouseEvent me); /** * Dispatches a mouse released event. * * @param me * the event */ public abstract void dispatchMouseReleased(MouseEvent me); /** * Dispatches a MouseWheel event. Does nothing by default. * * @param event * the SWT event * @since 3.1 */ public void dispatchMouseWheelScrolled(Event event) { } /** * Returns the AccessibilityDispatcher. * * @return the AccessibilityDispatcher */ protected abstract AccessibilityDispatcher getAccessibilityDispatcher(); /** * Returns the IFigure that currently has focus. * * @return the IFigure that currently has focus * @since 3.6 */ public abstract IFigure getFocusOwner(); /** * @return whether events are captured by a figure */ public abstract boolean isCaptured(); /** * Releases capture initiated by {@link #setCapture(IFigure)}. */ protected abstract void releaseCapture(); /** * Requests focus for the given figure. * * @param fig * the figure requesting focus */ public abstract void requestFocus(IFigure fig); /** * Requests focus to be removed from the given figure. * * @param fig * the figure requesting focus be removed */ public abstract void requestRemoveFocus(IFigure fig); /** * Sets capture to the given figure. All subsequent events will be sent to * the given figure until {@link #releaseCapture()} is called. * * @param figure * the figure capturing the events */ protected abstract void setCapture(IFigure figure); /** * Sets the contol associated with this event dispatcher. * * @param control * the control */ public abstract void setControl(Control control); /** * Sets the root figure for this dispatcher. * * @param figure * the root figure */ public abstract void setRoot(IFigure figure); /** * Updates the cursor. */ protected abstract void updateCursor(); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/EventListenerList.java000066400000000000000000000066771166301720600277760ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.Iterator; /** * This class is intended for internal use only. TODO: If this is for internal * use only, we should move it to the internal package. */ public final class EventListenerList { private volatile Object array[]; /** * Adds a listener of type c to the list. * * @param c * the class * @param listener * the listener */ public synchronized void addListener(Class c, Object listener) { if (listener == null || c == null) throw new IllegalArgumentException(); int oldSize = (array == null) ? 0 : array.length; Object[] newArray = new Object[oldSize + 2]; if (oldSize != 0) System.arraycopy(array, 0, newArray, 0, oldSize); newArray[oldSize++] = c; newArray[oldSize] = listener; array = newArray; } /** * Returns true if this list of listeners contains a listener * of type c. * * @param c * the type * @return whether this list contains a listener of type c */ public synchronized boolean containsListener(Class c) { if (array == null) return false; for (int i = 0; i < array.length; i += 2) if (array[i] == c) return true; return false; } static class TypeIterator implements Iterator { private final Object[] items; private final Class type; private int index; TypeIterator(Object items[], Class type) { this.items = items; this.type = type; } public Object next() { Object result = items[index + 1]; index += 2; return result; } public boolean hasNext() { if (items == null) return false; while (index < items.length && items[index] != type) index += 2; return index < items.length; } public void remove() { throw new UnsupportedOperationException( "Iterator removal not supported"); //$NON-NLS-1$ } } /** * Returns an Iterator of all the listeners of type c. * * @param listenerType * the type * @return an Iterator of all the listeners of type c */ public synchronized Iterator getListeners(final Class listenerType) { return new TypeIterator(array, listenerType); } /** * Removes the first listener of the specified type by identity. * * @param c * the type * @param listener * the listener */ public synchronized void removeListener(Class c, Object listener) { if (array == null || array.length == 0) return; if (listener == null || c == null) throw new IllegalArgumentException(); int index = 0; while (index < array.length) { if (array[index] == c && array[index + 1] == listener) break; index += 2; } if (index == array.length) return; // listener was not found Object newArray[] = new Object[array.length - 2]; System.arraycopy(array, 0, newArray, 0, index); System.arraycopy(array, index + 2, newArray, index, array.length - index - 2); array = newArray; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ExclusionSearch.java000066400000000000000000000026711166301720600274400ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.Collection; /** * A TreeSearch that excludes figures contained in a * {@link java.util.Collection}. * * @author hudsonr * @since 2.1 */ public class ExclusionSearch implements TreeSearch { private final Collection c; /** * Constructs an Exclusion search using the given collection. * * @param collection * the exclusion set */ public ExclusionSearch(Collection collection) { this.c = collection; } /** * @see org.eclipse.draw2d.TreeSearch#accept(IFigure) */ public boolean accept(IFigure figure) { // Prune is called before accept, so there is no reason to check the // collection again. return true; } /** * Returns true if the figure is a member of the Collection. * * @see org.eclipse.draw2d.TreeSearch#prune(IFigure) */ public boolean prune(IFigure f) { return c.contains(f); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/FanRouter.java000066400000000000000000000050111166301720600262350ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.PointList; import org.eclipse.draw2d.geometry.Ray; /** * Automatic router that spreads its {@link Connection Connections} in a * fan-like fashion upon collision. */ public class FanRouter extends AutomaticRouter { private int separation = 10; /** * Returns the separation in pixels between fanned connections. * * @return the separation * @since 2.0 */ public int getSeparation() { return separation; } /** * Modifies a given PointList that collides with some other PointList. The * given index indicates that this it the ith PointList in * a group of colliding points. * * @param points * the colliding points * @param index * the index */ protected void handleCollision(PointList points, int index) { Point start = points.getFirstPoint(); Point end = points.getLastPoint(); if (start.equals(end)) return; Point midPoint = new Point((end.x + start.x) / 2, (end.y + start.y) / 2); int position = end.getPosition(start); Ray ray; if (position == PositionConstants.SOUTH || position == PositionConstants.EAST) ray = new Ray(start, end); else ray = new Ray(end, start); double length = ray.length(); double xSeparation = separation * ray.x / length; double ySeparation = separation * ray.y / length; Point bendPoint; if (index % 2 == 0) { bendPoint = new Point( midPoint.x + (index / 2) * (-1 * ySeparation), midPoint.y + (index / 2) * xSeparation); } else { bendPoint = new Point(midPoint.x + (index / 2) * ySeparation, midPoint.y + (index / 2) * (-1 * xSeparation)); } if (!bendPoint.equals(midPoint)) points.insertPoint(bendPoint, 1); } /** * Sets the colliding {@link Connection Connection's} separation in pixels. * * @param value * the separation * @since 2.0 */ public void setSeparation(int value) { separation = value; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/Figure.java000066400000000000000000001461751166301720600255720ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.List; import org.eclipse.swt.SWT; import org.eclipse.swt.SWTException; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Cursor; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.widgets.Display; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Insets; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.draw2d.geometry.Translatable; /** * The base implementation for graphical figures. */ public class Figure implements IFigure { private static final Rectangle PRIVATE_RECT = new Rectangle(); private static final Point PRIVATE_POINT = new Point(); private static final int FLAG_VALID = new Integer(1).intValue(), FLAG_OPAQUE = new Integer(1 << 1).intValue(), FLAG_VISIBLE = new Integer(1 << 2).intValue(), FLAG_FOCUSABLE = new Integer(1 << 3).intValue(), FLAG_ENABLED = new Integer(1 << 4).intValue(), FLAG_FOCUS_TRAVERSABLE = new Integer(1 << 5).intValue(); static final int FLAG_REALIZED = 1 << 31; /** * The largest flag defined in this class. If subclasses define flags, they * should declare them as larger than this value and redefine MAX_FLAG to be * their largest flag value. *

* This constant is evaluated at runtime and will not be inlined by the * compiler. */ protected static int MAX_FLAG = FLAG_FOCUS_TRAVERSABLE; /** * The rectangular area that this Figure occupies. */ protected Rectangle bounds = new Rectangle(0, 0, 0, 0); private LayoutManager layoutManager; /** * The flags for this Figure. */ protected int flags = FLAG_VISIBLE | FLAG_ENABLED; private IFigure parent; private IClippingStrategy clippingStrategy = null; private Cursor cursor; private PropertyChangeSupport propertyListeners; private EventListenerList eventListeners = new EventListenerList(); private List children = Collections.EMPTY_LIST; /** * This Figure's preferred size. */ protected Dimension prefSize; /** * This Figure's minimum size. */ protected Dimension minSize; /** * This Figure's maximum size. */ protected Dimension maxSize; /** * @deprecated access using {@link #getLocalFont()} */ protected Font font; /** * @deprecated access using {@link #getLocalBackgroundColor()}. */ protected Color bgColor; /** * @deprecated access using {@link #getLocalForegroundColor()}. */ protected Color fgColor; /** * @deprecated access using {@link #getBorder()} */ protected Border border; /** * @deprecated access using {@link #getToolTip()} */ protected IFigure toolTip; private AncestorHelper ancestorHelper; /** * Calls {@link #add(IFigure, Object, int)} with -1 as the index. * * @see IFigure#add(IFigure, Object) */ public final void add(IFigure figure, Object constraint) { add(figure, constraint, -1); } /** * @see IFigure#add(IFigure, Object, int) */ public void add(IFigure figure, Object constraint, int index) { if (children == Collections.EMPTY_LIST) children = new ArrayList(2); if (index < -1 || index > children.size()) throw new IndexOutOfBoundsException("Index does not exist"); //$NON-NLS-1$ // Check for Cycle in hierarchy for (IFigure f = this; f != null; f = f.getParent()) if (figure == f) throw new IllegalArgumentException( "Figure being added introduces cycle"); //$NON-NLS-1$ // Detach the child from previous parent if (figure.getParent() != null) figure.getParent().remove(figure); if (index == -1) children.add(figure); else children.add(index, figure); figure.setParent(this); if (layoutManager != null) layoutManager.setConstraint(figure, constraint); revalidate(); if (getFlag(FLAG_REALIZED)) figure.addNotify(); figure.repaint(); } /** * Calls {@link #add(IFigure, Object, int)} with null as the * constraint and -1 as the index. * * @see IFigure#add(IFigure) */ public final void add(IFigure figure) { add(figure, null, -1); } /** * Calls {@link #add(IFigure, Object, int)} with null as the * constraint. * * @see IFigure#add(IFigure, int) */ public final void add(IFigure figure, int index) { add(figure, null, index); } /** * @see IFigure#addAncestorListener(AncestorListener) */ public void addAncestorListener(AncestorListener ancestorListener) { if (ancestorHelper == null) ancestorHelper = new AncestorHelper(this); ancestorHelper.addAncestorListener(ancestorListener); } /** * @see IFigure#addCoordinateListener(CoordinateListener) */ public void addCoordinateListener(CoordinateListener listener) { eventListeners.addListener(CoordinateListener.class, listener); } /** * @see IFigure#addFigureListener(FigureListener) */ public void addFigureListener(FigureListener listener) { eventListeners.addListener(FigureListener.class, listener); } /** * @see IFigure#addFocusListener(FocusListener) */ public void addFocusListener(FocusListener listener) { eventListeners.addListener(FocusListener.class, listener); } /** * @see IFigure#addKeyListener(KeyListener) */ public void addKeyListener(KeyListener listener) { eventListeners.addListener(KeyListener.class, listener); } /** * Appends the given layout listener to the list of layout listeners. * * @since 3.1 * @param listener * the listener being added */ public void addLayoutListener(LayoutListener listener) { if (layoutManager instanceof LayoutNotifier) { LayoutNotifier notifier = (LayoutNotifier) layoutManager; notifier.listeners.add(listener); } else layoutManager = new LayoutNotifier(layoutManager, listener); } /** * Adds a listener of type clazz to this Figure's list of event * listeners. * * @param clazz * The listener type * @param listener * The listener */ protected void addListener(Class clazz, Object listener) { eventListeners.addListener(clazz, listener); } /** * @see IFigure#addMouseListener(MouseListener) */ public void addMouseListener(MouseListener listener) { eventListeners.addListener(MouseListener.class, listener); } /** * @see IFigure#addMouseMotionListener(MouseMotionListener) */ public void addMouseMotionListener(MouseMotionListener listener) { eventListeners.addListener(MouseMotionListener.class, listener); } /** * Called after the receiver's parent has been set and it has been added to * its parent. * * @since 2.0 */ public void addNotify() { if (getFlag(FLAG_REALIZED)) throw new RuntimeException( "addNotify() should not be called multiple times"); //$NON-NLS-1$ setFlag(FLAG_REALIZED, true); for (int i = 0; i < children.size(); i++) ((IFigure) children.get(i)).addNotify(); } /** * @see IFigure#addPropertyChangeListener(String, PropertyChangeListener) */ public void addPropertyChangeListener(String property, PropertyChangeListener listener) { if (propertyListeners == null) propertyListeners = new PropertyChangeSupport(this); propertyListeners.addPropertyChangeListener(property, listener); } /** * @see IFigure#addPropertyChangeListener(PropertyChangeListener) */ public void addPropertyChangeListener(PropertyChangeListener listener) { if (propertyListeners == null) propertyListeners = new PropertyChangeSupport(this); propertyListeners.addPropertyChangeListener(listener); } /** * This method is final. Override {@link #containsPoint(int, int)} if * needed. * * @see IFigure#containsPoint(Point) * @since 2.0 */ public final boolean containsPoint(Point p) { return containsPoint(p.x, p.y); } /** * @see IFigure#containsPoint(int, int) */ public boolean containsPoint(int x, int y) { return getBounds().contains(x, y); } /** * @see IFigure#erase() */ public void erase() { if (getParent() == null || !isVisible()) return; Rectangle r = new Rectangle(getBounds()); getParent().translateToParent(r); getParent().repaint(r.x, r.y, r.width, r.height); } /** * Returns a descendant of this Figure such that the Figure returned * contains the point (x, y), and is accepted by the given TreeSearch. * Returns null if none found. * * @param x * The X coordinate * @param y * The Y coordinate * @param search * the TreeSearch * @return The descendant Figure at (x,y) */ protected IFigure findDescendantAtExcluding(int x, int y, TreeSearch search) { PRIVATE_POINT.setLocation(x, y); translateFromParent(PRIVATE_POINT); if (!getClientArea(Rectangle.SINGLETON).contains(PRIVATE_POINT)) return null; x = PRIVATE_POINT.x; y = PRIVATE_POINT.y; IFigure fig; for (int i = children.size(); i > 0;) { i--; fig = (IFigure) children.get(i); if (fig.isVisible()) { fig = fig.findFigureAt(x, y, search); if (fig != null) return fig; } } // No descendants were found return null; } /** * @see IFigure#findFigureAt(Point) */ public final IFigure findFigureAt(Point pt) { return findFigureAtExcluding(pt.x, pt.y, Collections.EMPTY_LIST); } /** * @see IFigure#findFigureAt(int, int) */ public final IFigure findFigureAt(int x, int y) { return findFigureAt(x, y, IdentitySearch.INSTANCE); } /** * @see IFigure#findFigureAt(int, int, TreeSearch) */ public IFigure findFigureAt(int x, int y, TreeSearch search) { if (!containsPoint(x, y)) return null; if (search.prune(this)) return null; IFigure child = findDescendantAtExcluding(x, y, search); if (child != null) return child; if (search.accept(this)) return this; return null; } /** * @see IFigure#findFigureAtExcluding(int, int, Collection) */ public final IFigure findFigureAtExcluding(int x, int y, Collection c) { return findFigureAt(x, y, new ExclusionSearch(c)); } /** * Returns the deepest descendant for which {@link #isMouseEventTarget()} * returns true or null if none found. The * Parameters x and y are absolute locations. Any Graphics * transformations applied by this Figure to its children during * {@link #paintChildren(Graphics)} (thus causing the children to appear * transformed to the user) should be applied inversely to the points * x and y when called on the children. * * @param x * The X coordinate * @param y * The Y coordinate * @return The deepest descendant for which isMouseEventTarget() returns * true */ public IFigure findMouseEventTargetAt(int x, int y) { if (!containsPoint(x, y)) return null; IFigure f = findMouseEventTargetInDescendantsAt(x, y); if (f != null) return f; if (isMouseEventTarget()) return this; return null; } /** * Searches this Figure's children for the deepest descendant for which * {@link #isMouseEventTarget()} returns true and returns that * descendant or null if none found. * * @see #findMouseEventTargetAt(int, int) * @param x * The X coordinate * @param y * The Y coordinate * @return The deepest descendant for which isMouseEventTarget() returns * true */ protected IFigure findMouseEventTargetInDescendantsAt(int x, int y) { PRIVATE_POINT.setLocation(x, y); translateFromParent(PRIVATE_POINT); if (!getClientArea(Rectangle.SINGLETON).contains(PRIVATE_POINT)) return null; IFigure fig; for (int i = children.size(); i > 0;) { i--; fig = (IFigure) children.get(i); if (fig.isVisible() && fig.isEnabled()) { if (fig.containsPoint(PRIVATE_POINT.x, PRIVATE_POINT.y)) { fig = fig.findMouseEventTargetAt(PRIVATE_POINT.x, PRIVATE_POINT.y); return fig; } } } return null; } /** * Notifies to all {@link CoordinateListener}s that this figure's local * coordinate system has changed in a way which affects the absolute bounds * of figures contained within. * * @since 3.1 */ protected void fireCoordinateSystemChanged() { if (!eventListeners.containsListener(CoordinateListener.class)) return; Iterator figureListeners = eventListeners .getListeners(CoordinateListener.class); while (figureListeners.hasNext()) ((CoordinateListener) figureListeners.next()) .coordinateSystemChanged(this); } /** * Notifies to all {@link FigureListener}s that this figure has moved. Moved * means that the bounds have changed in some way, location and/or size. * * @since 3.1 */ protected void fireFigureMoved() { if (!eventListeners.containsListener(FigureListener.class)) return; Iterator figureListeners = eventListeners .getListeners(FigureListener.class); while (figureListeners.hasNext()) ((FigureListener) figureListeners.next()).figureMoved(this); } /** * Fires both figuremoved and coordinate system changed. This method exists * for compatibility. Some listeners which used to listen for figureMoved * now listen for coordinates changed. So to be sure that those new * listeners are notified, any client code which used called this method * will also result in notification of coordinate changes. * * @since 2.0 * @deprecated call fireFigureMoved() or fireCoordinateSystemChanged() as * appropriate */ protected void fireMoved() { fireFigureMoved(); fireCoordinateSystemChanged(); } /** * Notifies any {@link PropertyChangeListener PropertyChangeListeners} * listening to this Figure that the boolean property with id * property has changed. * * @param property * The id of the property that changed * @param old * The old value of the changed property * @param current * The current value of the changed property * @since 2.0 */ protected void firePropertyChange(String property, boolean old, boolean current) { if (propertyListeners == null) return; propertyListeners.firePropertyChange(property, old, current); } /** * Notifies any {@link PropertyChangeListener PropertyChangeListeners} * listening to this figure that the Object property with id property * has changed. * * @param property * The id of the property that changed * @param old * The old value of the changed property * @param current * The current value of the changed property * @since 2.0 */ protected void firePropertyChange(String property, Object old, Object current) { if (propertyListeners == null) return; propertyListeners.firePropertyChange(property, old, current); } /** * Notifies any {@link PropertyChangeListener PropertyChangeListeners} * listening to this figure that the integer property with id * property has changed. * * @param property * The id of the property that changed * @param old * The old value of the changed property * @param current * The current value of the changed property * @since 2.0 */ protected void firePropertyChange(String property, int old, int current) { if (propertyListeners == null) return; propertyListeners.firePropertyChange(property, old, current); } /** * Returns this Figure's background color. If this Figure's background color * is null and its parent is not null, the * background color is inherited from the parent. * * @see IFigure#getBackgroundColor() */ public Color getBackgroundColor() { if (bgColor == null && getParent() != null) return getParent().getBackgroundColor(); return bgColor; } /** * @see IFigure#getBorder() */ public Border getBorder() { return border; } /** * Returns the smallest rectangle completely enclosing the figure. * Implementors may return the Rectangle by reference. For this reason, * callers of this method must not modify the returned Rectangle. * * @return The bounds of this Figure */ public Rectangle getBounds() { return bounds; } /** * @see IFigure#getChildren() */ public List getChildren() { return children; } /** * @see IFigure#getClientArea(Rectangle) */ public Rectangle getClientArea(Rectangle rect) { rect.setBounds(getBounds()); rect.crop(getInsets()); if (useLocalCoordinates()) rect.setLocation(0, 0); return rect; } /** * @see IFigure#getClientArea() */ public final Rectangle getClientArea() { return getClientArea(new Rectangle()); } /** * Returns the IClippingStrategy used by this figure to clip its children * * @return the IClipppingStrategy used to clip this figure's children. * @since 3.6 */ public IClippingStrategy getClippingStrategy() { return clippingStrategy; } /** * @see IFigure#getCursor() */ public Cursor getCursor() { if (cursor == null && getParent() != null) return getParent().getCursor(); return cursor; } /** * Returns the value of the given flag. * * @param flag * The flag to get * @return The value of the given flag */ protected boolean getFlag(int flag) { return (flags & flag) != 0; } /** * @see IFigure#getFont() */ public Font getFont() { if (font != null) return font; if (getParent() != null) return getParent().getFont(); return null; } /** * @see IFigure#getForegroundColor() */ public Color getForegroundColor() { if (fgColor == null && getParent() != null) return getParent().getForegroundColor(); return fgColor; } /** * Returns the border's Insets if the border is set. Otherwise returns * NO_INSETS, an instance of Insets with all 0s. Returns Insets by * reference. DO NOT Modify returned value. Cannot return null. * * @return This Figure's Insets */ public Insets getInsets() { if (getBorder() != null) return getBorder().getInsets(this); return NO_INSETS; } /** * @see IFigure#getLayoutManager() */ public LayoutManager getLayoutManager() { if (layoutManager instanceof LayoutNotifier) return ((LayoutNotifier) layoutManager).realLayout; return layoutManager; } /** * Returns an Iterator over the listeners of type clazz that are * listening to this Figure. If there are no listeners of type clazz, * an empty iterator is returned. * * @param clazz * The type of listeners to get * @return An Iterator over the requested listeners * @since 2.0 */ protected Iterator getListeners(Class clazz) { if (eventListeners == null) return Collections.EMPTY_LIST.iterator(); return eventListeners.getListeners(clazz); } /** * Returns null or the local background Color of this Figure. * Does not inherit this Color from the parent. * * @return bgColor null or the local background Color */ public Color getLocalBackgroundColor() { return bgColor; } /** * Returns null or the local font setting for this figure. Does * not return values inherited from the parent figure. * * @return null or the local font * @since 3.1 */ protected Font getLocalFont() { return font; } /** * Returns null or the local foreground Color of this Figure. * Does not inherit this Color from the parent. * * @return fgColor null or the local foreground Color */ public Color getLocalForegroundColor() { return fgColor; } /** * Returns the top-left corner of this Figure's bounds. * * @return The top-left corner of this Figure's bounds * @since 2.0 */ public final Point getLocation() { return getBounds().getLocation(); } /** * @see IFigure#getMaximumSize() */ public Dimension getMaximumSize() { if (maxSize != null) return maxSize; return MAX_DIMENSION; } /** * @see IFigure#getMinimumSize() */ public final Dimension getMinimumSize() { return getMinimumSize(-1, -1); } /** * @see IFigure#getMinimumSize(int, int) */ public Dimension getMinimumSize(int wHint, int hHint) { if (minSize != null) return minSize; if (getLayoutManager() != null) { Dimension d = getLayoutManager().getMinimumSize(this, wHint, hHint); if (d != null) return d; } return getPreferredSize(wHint, hHint); } /** * @see IFigure#getParent() */ public IFigure getParent() { return parent; } /** * @see IFigure#getPreferredSize() */ public final Dimension getPreferredSize() { return getPreferredSize(-1, -1); } /** * @see IFigure#getPreferredSize(int, int) */ public Dimension getPreferredSize(int wHint, int hHint) { if (prefSize != null) return prefSize; if (getLayoutManager() != null) { Dimension d = getLayoutManager().getPreferredSize(this, wHint, hHint); if (d != null) return d; } return getSize(); } /** * @see IFigure#getSize() */ public final Dimension getSize() { return getBounds().getSize(); } /** * @see IFigure#getToolTip() */ public IFigure getToolTip() { return toolTip; } /** * @see IFigure#getUpdateManager() */ public UpdateManager getUpdateManager() { if (getParent() != null) return getParent().getUpdateManager(); // Only happens when the figure has not been realized return NO_MANAGER; } /** * @see IFigure#handleFocusGained(FocusEvent) */ public void handleFocusGained(FocusEvent event) { Iterator iter = eventListeners.getListeners(FocusListener.class); while (iter.hasNext()) ((FocusListener) iter.next()).focusGained(event); } /** * @see IFigure#handleFocusLost(FocusEvent) */ public void handleFocusLost(FocusEvent event) { Iterator iter = eventListeners.getListeners(FocusListener.class); while (iter.hasNext()) ((FocusListener) iter.next()).focusLost(event); } /** * @see IFigure#handleKeyPressed(KeyEvent) */ public void handleKeyPressed(KeyEvent event) { Iterator iter = eventListeners.getListeners(KeyListener.class); while (!event.isConsumed() && iter.hasNext()) ((KeyListener) iter.next()).keyPressed(event); } /** * @see IFigure#handleKeyReleased(KeyEvent) */ public void handleKeyReleased(KeyEvent event) { Iterator iter = eventListeners.getListeners(KeyListener.class); while (!event.isConsumed() && iter.hasNext()) ((KeyListener) iter.next()).keyReleased(event); } /** * @see IFigure#handleMouseDoubleClicked(MouseEvent) */ public void handleMouseDoubleClicked(MouseEvent event) { Iterator iter = eventListeners.getListeners(MouseListener.class); while (!event.isConsumed() && iter.hasNext()) ((MouseListener) iter.next()).mouseDoubleClicked(event); } /** * @see IFigure#handleMouseDragged(MouseEvent) */ public void handleMouseDragged(MouseEvent event) { Iterator iter = eventListeners.getListeners(MouseMotionListener.class); while (!event.isConsumed() && iter.hasNext()) ((MouseMotionListener) iter.next()).mouseDragged(event); } /** * @see IFigure#handleMouseEntered(MouseEvent) */ public void handleMouseEntered(MouseEvent event) { Iterator iter = eventListeners.getListeners(MouseMotionListener.class); while (!event.isConsumed() && iter.hasNext()) ((MouseMotionListener) iter.next()).mouseEntered(event); } /** * @see IFigure#handleMouseExited(MouseEvent) */ public void handleMouseExited(MouseEvent event) { Iterator iter = eventListeners.getListeners(MouseMotionListener.class); while (!event.isConsumed() && iter.hasNext()) ((MouseMotionListener) iter.next()).mouseExited(event); } /** * @see IFigure#handleMouseHover(MouseEvent) */ public void handleMouseHover(MouseEvent event) { Iterator iter = eventListeners.getListeners(MouseMotionListener.class); while (!event.isConsumed() && iter.hasNext()) ((MouseMotionListener) iter.next()).mouseHover(event); } /** * @see IFigure#handleMouseMoved(MouseEvent) */ public void handleMouseMoved(MouseEvent event) { Iterator iter = eventListeners.getListeners(MouseMotionListener.class); while (!event.isConsumed() && iter.hasNext()) ((MouseMotionListener) iter.next()).mouseMoved(event); } /** * @see IFigure#handleMousePressed(MouseEvent) */ public void handleMousePressed(MouseEvent event) { Iterator iter = eventListeners.getListeners(MouseListener.class); while (!event.isConsumed() && iter.hasNext()) ((MouseListener) iter.next()).mousePressed(event); } /** * @see IFigure#handleMouseReleased(MouseEvent) */ public void handleMouseReleased(MouseEvent event) { Iterator iter = eventListeners.getListeners(MouseListener.class); while (!event.isConsumed() && iter.hasNext()) ((MouseListener) iter.next()).mouseReleased(event); } /** * @see IFigure#hasFocus() */ public boolean hasFocus() { EventDispatcher dispatcher = internalGetEventDispatcher(); if (dispatcher == null) return false; return dispatcher.getFocusOwner() == this; } /** * @see IFigure#internalGetEventDispatcher() */ public EventDispatcher internalGetEventDispatcher() { if (getParent() != null) return getParent().internalGetEventDispatcher(); return null; } /** * @see IFigure#intersects(Rectangle) */ public boolean intersects(Rectangle rect) { return getBounds().intersects(rect); } /** * @see IFigure#invalidate() */ public void invalidate() { if (layoutManager != null) layoutManager.invalidate(); setValid(false); } /** * @see IFigure#invalidateTree() */ public void invalidateTree() { invalidate(); for (Iterator iter = children.iterator(); iter.hasNext();) { IFigure child = (IFigure) iter.next(); child.invalidateTree(); } } /** * @see IFigure#isCoordinateSystem() */ public boolean isCoordinateSystem() { return useLocalCoordinates(); } /** * @see IFigure#isEnabled() */ public boolean isEnabled() { return (flags & FLAG_ENABLED) != 0; } /** * @see IFigure#isFocusTraversable() */ public boolean isFocusTraversable() { return (flags & FLAG_FOCUS_TRAVERSABLE) != 0; } /** * Returns true if this Figure can receive {@link MouseEvent * MouseEvents}. * * @return true if this Figure can receive {@link MouseEvent * MouseEvents} * @since 2.0 */ protected boolean isMouseEventTarget() { return (eventListeners.containsListener(MouseListener.class) || eventListeners .containsListener(MouseMotionListener.class)); } /** * @see org.eclipse.draw2d.IFigure#isMirrored() */ public boolean isMirrored() { if (getParent() != null) return getParent().isMirrored(); return false; } /** * @see IFigure#isOpaque() */ public boolean isOpaque() { return (flags & FLAG_OPAQUE) != 0; } /** * @see IFigure#isRequestFocusEnabled() */ public boolean isRequestFocusEnabled() { return (flags & FLAG_FOCUSABLE) != 0; } /** * @see IFigure#isShowing() */ public boolean isShowing() { return isVisible() && (getParent() == null || getParent().isShowing()); } /** * Returns true if this Figure is valid. * * @return true if this Figure is valid * @since 2.0 */ protected boolean isValid() { return (flags & FLAG_VALID) != 0; } /** * Returns true if revalidating this Figure does not require * revalidating its parent. * * @return true if revalidating this Figure doesn't require * revalidating its parent. * @since 2.0 */ protected boolean isValidationRoot() { return false; } /** * @see IFigure#isVisible() */ public boolean isVisible() { return getFlag(FLAG_VISIBLE); } /** * Lays out this Figure using its {@link LayoutManager}. * * @since 2.0 */ protected void layout() { if (layoutManager != null) layoutManager.layout(this); } /** * Paints this Figure and its children. * * @param graphics * The Graphics object used for painting * @see #paintFigure(Graphics) * @see #paintClientArea(Graphics) * @see #paintBorder(Graphics) */ public void paint(Graphics graphics) { if (getLocalBackgroundColor() != null) graphics.setBackgroundColor(getLocalBackgroundColor()); if (getLocalForegroundColor() != null) graphics.setForegroundColor(getLocalForegroundColor()); if (font != null) graphics.setFont(font); graphics.pushState(); try { paintFigure(graphics); graphics.restoreState(); paintClientArea(graphics); paintBorder(graphics); } finally { graphics.popState(); } } /** * Paints the border associated with this Figure, if one exists. * * @param graphics * The Graphics used to paint * @see Border#paint(IFigure, Graphics, Insets) * @since 2.0 */ protected void paintBorder(Graphics graphics) { if (getBorder() != null) getBorder().paint(this, graphics, NO_INSETS); } /** * Paints this Figure's children. The caller must save the state of the * graphics prior to calling this method, such that * graphics.restoreState() may be called safely, and doing so * will return the graphics to its original state when the method was * entered. *

* This method must leave the Graphics in its original state upon return. * * @param graphics * the graphics used to paint * @since 2.0 */ protected void paintChildren(Graphics graphics) { for (int i = 0; i < children.size(); i++) { IFigure child = (IFigure) children.get(i); if (child.isVisible()) { // determine clipping areas for child Rectangle[] clipping = null; if (clippingStrategy != null) { clipping = clippingStrategy.getClip(child); } else { // default clipping behaviour is to clip at bounds clipping = new Rectangle[] { child.getBounds() }; } // child may now paint inside the clipping areas for (int j = 0; j < clipping.length; j++) { if (clipping[j].intersects(graphics .getClip(Rectangle.SINGLETON))) { graphics.clipRect(clipping[j]); child.paint(graphics); graphics.restoreState(); } } } } } /** * Paints this Figure's client area. The client area is typically defined as * the anything inside the Figure's {@link Border} or {@link Insets}, and by * default includes the children of this Figure. On return, this method must * leave the given Graphics in its initial state. * * @param graphics * The Graphics used to paint * @since 2.0 */ protected void paintClientArea(Graphics graphics) { if (children.isEmpty()) return; boolean optimizeClip = getBorder() == null || getBorder().isOpaque(); if (useLocalCoordinates()) { graphics.translate(getBounds().x + getInsets().left, getBounds().y + getInsets().top); if (!optimizeClip) graphics.clipRect(getClientArea(PRIVATE_RECT)); graphics.pushState(); paintChildren(graphics); graphics.popState(); graphics.restoreState(); } else { if (optimizeClip) paintChildren(graphics); else { graphics.clipRect(getClientArea(PRIVATE_RECT)); graphics.pushState(); paintChildren(graphics); graphics.popState(); graphics.restoreState(); } } } /** * Paints this Figure's primary representation, or background. Changes made * to the graphics to the graphics current state will not affect the * subsequent calls to {@link #paintClientArea(Graphics)} and * {@link #paintBorder(Graphics)}. Furthermore, it is safe to call * graphics.restoreState() within this method, and doing so * will restore the graphics to its original state upon entry. * * @param graphics * The Graphics used to paint * @since 2.0 */ protected void paintFigure(Graphics graphics) { if (isOpaque()) graphics.fillRectangle(getBounds()); if (getBorder() instanceof AbstractBackground) ((AbstractBackground) getBorder()).paintBackground(this, graphics, NO_INSETS); } /** * Translates this Figure's bounds, without firing a move. * * @param dx * The amount to translate horizontally * @param dy * The amount to translate vertically * @see #translate(int, int) * @since 2.0 */ protected void primTranslate(int dx, int dy) { bounds.x += dx; bounds.y += dy; if (useLocalCoordinates()) { fireCoordinateSystemChanged(); return; } for (int i = 0; i < children.size(); i++) ((IFigure) children.get(i)).translate(dx, dy); } /** * Removes the given child Figure from this Figure's hierarchy and * revalidates this Figure. The child Figure's {@link #removeNotify()} * method is also called. * * @param figure * The Figure to remove */ public void remove(IFigure figure) { if ((figure.getParent() != this)) throw new IllegalArgumentException("Figure is not a child"); //$NON-NLS-1$ if (getFlag(FLAG_REALIZED)) figure.removeNotify(); if (layoutManager != null) layoutManager.remove(figure); // The updates in the UpdateManager *have* to be // done asynchronously, else will result in // incorrect dirty region corrections. figure.erase(); figure.setParent(null); children.remove(figure); revalidate(); } /** * Removes all children from this Figure. * * @see #remove(IFigure) * @since 2.0 */ public void removeAll() { List list = new ArrayList(getChildren()); for (int i = 0; i < list.size(); i++) { remove((IFigure) list.get(i)); } } /** * @see IFigure#removeAncestorListener(AncestorListener) */ public void removeAncestorListener(AncestorListener listener) { if (ancestorHelper != null) { ancestorHelper.removeAncestorListener(listener); if (ancestorHelper.isEmpty()) { ancestorHelper.dispose(); ancestorHelper = null; } } } /** * @see IFigure#removeCoordinateListener(CoordinateListener) */ public void removeCoordinateListener(CoordinateListener listener) { eventListeners.removeListener(CoordinateListener.class, listener); } /** * @see IFigure#removeFigureListener(FigureListener) */ public void removeFigureListener(FigureListener listener) { eventListeners.removeListener(FigureListener.class, listener); } /** * @see IFigure#removeFocusListener(FocusListener) */ public void removeFocusListener(FocusListener listener) { eventListeners.removeListener(FocusListener.class, listener); } /** * @see IFigure#removeKeyListener(KeyListener) */ public void removeKeyListener(KeyListener listener) { eventListeners.removeListener(KeyListener.class, listener); } /** * Removes the first occurence of the given listener. * * @since 3.1 * @param listener * the listener being removed */ public void removeLayoutListener(LayoutListener listener) { if (layoutManager instanceof LayoutNotifier) { LayoutNotifier notifier = (LayoutNotifier) layoutManager; notifier.listeners.remove(listener); if (notifier.listeners.isEmpty()) layoutManager = notifier.realLayout; } } /** * Removes listener of type clazz from this Figure's list of * listeners. * * @param clazz * The type of listener * @param listener * The listener to remove * @since 2.0 */ protected void removeListener(Class clazz, Object listener) { if (eventListeners == null) return; eventListeners.removeListener(clazz, listener); } /** * @see IFigure#removeMouseListener(MouseListener) */ public void removeMouseListener(MouseListener listener) { eventListeners.removeListener(MouseListener.class, listener); } /** * @see IFigure#removeMouseMotionListener(MouseMotionListener) */ public void removeMouseMotionListener(MouseMotionListener listener) { eventListeners.removeListener(MouseMotionListener.class, listener); } /** * Called prior to this figure's removal from its parent */ public void removeNotify() { for (int i = 0; i < children.size(); i++) ((IFigure) children.get(i)).removeNotify(); if (internalGetEventDispatcher() != null) internalGetEventDispatcher().requestRemoveFocus(this); setFlag(FLAG_REALIZED, false); } /** * @see IFigure#removePropertyChangeListener(PropertyChangeListener) */ public void removePropertyChangeListener(PropertyChangeListener listener) { if (propertyListeners == null) return; propertyListeners.removePropertyChangeListener(listener); } /** * @see IFigure#removePropertyChangeListener(String, PropertyChangeListener) */ public void removePropertyChangeListener(String property, PropertyChangeListener listener) { if (propertyListeners == null) return; propertyListeners.removePropertyChangeListener(property, listener); } /** * @see IFigure#repaint(Rectangle) */ public final void repaint(Rectangle rect) { repaint(rect.x, rect.y, rect.width, rect.height); } /** * @see IFigure#repaint(int, int, int, int) */ public void repaint(int x, int y, int w, int h) { if (isVisible()) getUpdateManager().addDirtyRegion(this, x, y, w, h); } /** * @see IFigure#repaint() */ public void repaint() { repaint(getBounds()); } /** * @see IFigure#requestFocus() */ public final void requestFocus() { if (!isRequestFocusEnabled() || hasFocus()) return; EventDispatcher dispatcher = internalGetEventDispatcher(); if (dispatcher == null) return; dispatcher.requestFocus(this); } /** * @see IFigure#revalidate() */ public void revalidate() { invalidate(); if (getParent() == null || isValidationRoot()) getUpdateManager().addInvalidFigure(this); else getParent().revalidate(); } /** * @see IFigure#setBackgroundColor(Color) */ public void setBackgroundColor(Color bg) { // Set background color to bg unless in high contrast mode. // In that case, get the color from system if (bgColor != null && bgColor.equals(bg)) return; Display display = Display.getCurrent(); if (display == null) { display = Display.getDefault(); } Color highContrastClr = null; try { if (display.getHighContrast()) { highContrastClr = display .getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); } } catch (SWTException e) { highContrastClr = null; } bgColor = highContrastClr == null ? bg : highContrastClr; repaint(); } /** * @see IFigure#setBorder(Border) */ public void setBorder(Border border) { this.border = border; revalidate(); repaint(); } /** * Sets the bounds of this Figure to the Rectangle rect. Note that * rect is compared to the Figure's current bounds to determine what * needs to be repainted and/or exposed and if validation is required. Since * {@link #getBounds()} may return the current bounds by reference, it is * not safe to modify that Rectangle and then call setBounds() after making * modifications. The figure would assume that the bounds are unchanged, and * no layout or paint would occur. For proper behavior, always use a copy. * * @param rect * The new bounds * @since 2.0 */ public void setBounds(Rectangle rect) { int x = bounds.x, y = bounds.y; boolean resize = (rect.width != bounds.width) || (rect.height != bounds.height), translate = (rect.x != x) || (rect.y != y); if ((resize || translate) && isVisible()) erase(); if (translate) { int dx = rect.x - x; int dy = rect.y - y; primTranslate(dx, dy); } bounds.width = rect.width; bounds.height = rect.height; if (translate || resize) { if (resize) invalidate(); fireFigureMoved(); repaint(); } } /** * Sets the direction of any {@link Orientable} children. Allowable values * for dir are found in {@link PositionConstants}. * * @param direction * The direction * @see Orientable#setDirection(int) * @since 2.0 */ protected void setChildrenDirection(int direction) { FigureIterator iterator = new FigureIterator(this); IFigure child; while (iterator.hasNext()) { child = iterator.nextFigure(); if (child instanceof Orientable) ((Orientable) child).setDirection(direction); } } /** * Sets all childrens' enabled property to value. * * @param value * The enable value * @see #setEnabled(boolean) * @since 2.0 */ protected void setChildrenEnabled(boolean value) { FigureIterator iterator = new FigureIterator(this); while (iterator.hasNext()) iterator.nextFigure().setEnabled(value); } /** * Sets the orientation of any {@link Orientable} children. Allowable values * for orientation are found in {@link PositionConstants}. * * @param orientation * The Orientation * @see Orientable#setOrientation(int) * @since 2.0 */ protected void setChildrenOrientation(int orientation) { FigureIterator iterator = new FigureIterator(this); IFigure child; while (iterator.hasNext()) { child = iterator.nextFigure(); if (child instanceof Orientable) ((Orientable) child).setOrientation(orientation); } } /** * @see IFigure#setConstraint(IFigure, Object) */ public void setConstraint(IFigure child, Object constraint) { if (child.getParent() != this) throw new IllegalArgumentException("Figure must be a child"); //$NON-NLS-1$ if (layoutManager != null) layoutManager.setConstraint(child, constraint); revalidate(); } /** * Registers a clipping strategy to specify how clipping is performed for * child figures. * * @param clippingStrategy * @since 3.6 */ public void setClippingStrategy(IClippingStrategy clippingStrategy) { this.clippingStrategy = clippingStrategy; } /** * @see IFigure#setCursor(Cursor) */ public void setCursor(Cursor cursor) { if (this.cursor == cursor) return; this.cursor = cursor; EventDispatcher dispatcher = internalGetEventDispatcher(); if (dispatcher != null) dispatcher.updateCursor(); } /** * @see IFigure#setEnabled(boolean) */ public void setEnabled(boolean value) { if (isEnabled() == value) return; setFlag(FLAG_ENABLED, value); } /** * Sets the given flag to the given value. * * @param flag * The flag to set * @param value * The value * @since 2.0 */ protected final void setFlag(int flag, boolean value) { if (value) flags |= flag; else flags &= ~flag; } /** * @see IFigure#setFocusTraversable(boolean) */ public void setFocusTraversable(boolean focusTraversable) { if (isFocusTraversable() == focusTraversable) return; setFlag(FLAG_FOCUS_TRAVERSABLE, focusTraversable); } /** * @see IFigure#setFont(Font) */ public void setFont(Font f) { if (font != f) { font = f; revalidate(); repaint(); } } /** * @see IFigure#setForegroundColor(Color) */ public void setForegroundColor(Color fg) { // Set foreground color to fg unless in high contrast mode. // In that case, get the color from system if (fgColor != null && fgColor.equals(fg)) return; Display display = Display.getCurrent(); if (display == null) { display = Display.getDefault(); } Color highContrastClr = null; try { if (display.getHighContrast()) { highContrastClr = display .getSystemColor(SWT.COLOR_WIDGET_FOREGROUND); } } catch (SWTException e) { highContrastClr = null; } fgColor = highContrastClr == null ? fg : highContrastClr; repaint(); } /** * @see IFigure#setLayoutManager(LayoutManager) */ public void setLayoutManager(LayoutManager manager) { if (layoutManager instanceof LayoutNotifier) ((LayoutNotifier) layoutManager).realLayout = manager; else layoutManager = manager; revalidate(); } /** * @see IFigure#setLocation(Point) */ public void setLocation(Point p) { if (getLocation().equals(p)) return; Rectangle r = new Rectangle(getBounds()); r.setLocation(p); setBounds(r); } /** * @see IFigure#setMaximumSize(Dimension) */ public void setMaximumSize(Dimension d) { if (maxSize != null && maxSize.equals(d)) return; maxSize = d; revalidate(); } /** * @see IFigure#setMinimumSize(Dimension) */ public void setMinimumSize(Dimension d) { if (minSize != null && minSize.equals(d)) return; minSize = d; revalidate(); } /** * @see IFigure#setOpaque(boolean) */ public void setOpaque(boolean opaque) { if (isOpaque() == opaque) return; setFlag(FLAG_OPAQUE, opaque); repaint(); } /** * @see IFigure#setParent(IFigure) */ public void setParent(IFigure p) { IFigure oldParent = parent; parent = p; firePropertyChange("parent", oldParent, p);//$NON-NLS-1$ } /** * @see IFigure#setPreferredSize(Dimension) */ public void setPreferredSize(Dimension size) { if (prefSize != null && prefSize.equals(size)) return; prefSize = size; revalidate(); } /** * Sets the preferred size of this figure. * * @param w * The new preferred width * @param h * The new preferred height * @see #setPreferredSize(Dimension) * @since 2.0 */ public final void setPreferredSize(int w, int h) { setPreferredSize(new Dimension(w, h)); } /** * @see IFigure#setRequestFocusEnabled(boolean) */ public void setRequestFocusEnabled(boolean requestFocusEnabled) { if (isRequestFocusEnabled() == requestFocusEnabled) return; setFlag(FLAG_FOCUSABLE, requestFocusEnabled); } /** * @see IFigure#setSize(Dimension) */ public final void setSize(Dimension d) { setSize(d.width, d.height); } /** * @see IFigure#setSize(int, int) */ public void setSize(int w, int h) { Rectangle bounds = getBounds(); if (bounds.width == w && bounds.height == h) return; Rectangle r = new Rectangle(getBounds()); r.setSize(w, h); setBounds(r); } /** * @see IFigure#setToolTip(IFigure) */ public void setToolTip(IFigure f) { if (toolTip == f) return; toolTip = f; } /** * Sets this figure to be valid if value is true and * invalid otherwise. * * @param value * The valid value * @since 2.0 */ public void setValid(boolean value) { setFlag(FLAG_VALID, value); } /** * @see IFigure#setVisible(boolean) */ public void setVisible(boolean visible) { boolean currentVisibility = isVisible(); if (visible == currentVisibility) return; if (currentVisibility) erase(); setFlag(FLAG_VISIBLE, visible); if (visible) repaint(); revalidate(); } /** * @see IFigure#translate(int, int) */ public final void translate(int x, int y) { primTranslate(x, y); fireFigureMoved(); } /** * @see IFigure#translateFromParent(Translatable) */ public void translateFromParent(Translatable t) { if (useLocalCoordinates()) t.performTranslate(-getBounds().x - getInsets().left, -getBounds().y - getInsets().top); } /** * @see IFigure#translateToAbsolute(Translatable) */ public final void translateToAbsolute(Translatable t) { if (getParent() != null) { getParent().translateToParent(t); getParent().translateToAbsolute(t); } } /** * @see IFigure#translateToParent(Translatable) */ public void translateToParent(Translatable t) { if (useLocalCoordinates()) t.performTranslate(getBounds().x + getInsets().left, getBounds().y + getInsets().top); } /** * @see IFigure#translateToRelative(Translatable) */ public final void translateToRelative(Translatable t) { if (getParent() != null) { getParent().translateToRelative(t); getParent().translateFromParent(t); } } /** * Returns true if this Figure uses local coordinates. This * means its children are placed relative to this Figure's top-left corner. * * @return true if this Figure uses local coordinates * @since 2.0 */ protected boolean useLocalCoordinates() { return false; } /** * @see IFigure#validate() */ public void validate() { if (isValid()) return; setValid(true); layout(); for (int i = 0; i < children.size(); i++) ((IFigure) children.get(i)).validate(); } /** * A search which does not filter any figures. since 3.0 */ protected static final class IdentitySearch implements TreeSearch { /** * The singleton instance. */ public static final TreeSearch INSTANCE = new IdentitySearch(); private IdentitySearch() { } /** * Always returns true. * * @see TreeSearch#accept(IFigure) */ public boolean accept(IFigure f) { return true; } /** * Always returns false. * * @see TreeSearch#prune(IFigure) */ public boolean prune(IFigure f) { return false; } } final class LayoutNotifier implements LayoutManager { LayoutManager realLayout; List listeners = new ArrayList(1); LayoutNotifier(LayoutManager layout, LayoutListener listener) { realLayout = layout; listeners.add(listener); } public Object getConstraint(IFigure child) { if (realLayout != null) return realLayout.getConstraint(child); return null; } public Dimension getMinimumSize(IFigure container, int wHint, int hHint) { if (realLayout != null) return realLayout.getMinimumSize(container, wHint, hHint); return null; } public Dimension getPreferredSize(IFigure container, int wHint, int hHint) { if (realLayout != null) return realLayout.getPreferredSize(container, wHint, hHint); return null; } public void invalidate() { for (int i = 0; i < listeners.size(); i++) ((LayoutListener) listeners.get(i)).invalidate(Figure.this); if (realLayout != null) realLayout.invalidate(); } public void layout(IFigure container) { boolean consumed = false; for (int i = 0; i < listeners.size(); i++) consumed |= ((LayoutListener) listeners.get(i)) .layout(container); if (realLayout != null && !consumed) realLayout.layout(container); for (int i = 0; i < listeners.size(); i++) ((LayoutListener) listeners.get(i)).postLayout(container); } public void remove(IFigure child) { for (int i = 0; i < listeners.size(); i++) ((LayoutListener) listeners.get(i)).remove(child); if (realLayout != null) realLayout.remove(child); } public void setConstraint(IFigure child, Object constraint) { for (int i = 0; i < listeners.size(); i++) ((LayoutListener) listeners.get(i)).setConstraint(child, constraint); if (realLayout != null) realLayout.setConstraint(child, constraint); } } /** * Iterates over a Figure's children. */ public static class FigureIterator { private List list; private int index; /** * Constructs a new FigureIterator for the given Figure. * * @param figure * The Figure whose children to iterate over */ public FigureIterator(IFigure figure) { list = figure.getChildren(); index = list.size(); } /** * Returns the next Figure. * * @return The next Figure */ public IFigure nextFigure() { return (IFigure) list.get(--index); } /** * Returns true if there's another Figure to iterate over. * * @return true if there's another Figure to iterate over */ public boolean hasNext() { return index > 0; } } /** * An UpdateManager that does nothing. */ protected static final UpdateManager NO_MANAGER = new UpdateManager() { public void addDirtyRegion(IFigure figure, int x, int y, int w, int h) { } public void addInvalidFigure(IFigure f) { } public void performUpdate() { } public void performUpdate(Rectangle region) { } public void setRoot(IFigure root) { } public void setGraphicsSource(GraphicsSource gs) { } }; } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/FigureCanvas.java000066400000000000000000000435771166301720600267300ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; /** * A scrolling Canvas that contains {@link Figure Figures} viewed through a * {@link Viewport}. Call {@link #setContents(IFigure)} to specify the root of * the tree of Figures to be viewed through the Viewport. *

* Normal procedure for using a FigureCanvas: *

    *
  1. Create a FigureCanvas. *
  2. Create a Draw2d Figure and call {@link #setContents(IFigure)}. This * Figure will be the top-level Figure of the Draw2d application. *
*
*
Required Styles (when using certain constructors):
*
V_SCROLL, H_SCROLL, NO_REDRAW_RESIZE
*
Optional Styles:
*
DOUBLE_BUFFERED, RIGHT_TO_LEFT, LEFT_TO_RIGHT, NO_BACKGROUND, BORDER
*
*

* Note: Only one of the styles RIGHT_TO_LEFT, LEFT_TO_RIGHT may be specified. *

*/ public class FigureCanvas extends Canvas { private static final int ACCEPTED_STYLES = SWT.RIGHT_TO_LEFT | SWT.LEFT_TO_RIGHT | SWT.V_SCROLL | SWT.H_SCROLL | SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE | SWT.DOUBLE_BUFFERED | SWT.BORDER; /** * The default styles are mixed in when certain constructors are used. This * constant is a bitwise OR of the following SWT style constants: *
    *
  • {@link SWT#NO_REDRAW_RESIZE}
  • *
  • {@link SWT#NO_BACKGROUND}
  • *
  • {@link SWT#V_SCROLL}
  • *
  • {@link SWT#H_SCROLL}
  • *
*/ static final int DEFAULT_STYLES = SWT.NO_REDRAW_RESIZE | SWT.NO_BACKGROUND | SWT.V_SCROLL | SWT.H_SCROLL; private static final int REQUIRED_STYLES = SWT.NO_REDRAW_RESIZE | SWT.V_SCROLL | SWT.H_SCROLL; /** Never show scrollbar */ public static int NEVER = 0; /** Automatically show scrollbar when needed */ public static int AUTOMATIC = 1; /** Always show scrollbar */ public static int ALWAYS = 2; private int vBarVisibility = AUTOMATIC; private int hBarVisibility = AUTOMATIC; private Viewport viewport; private Font font; private int hBarOffset; private int vBarOffset; private PropertyChangeListener horizontalChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { RangeModel model = getViewport().getHorizontalRangeModel(); hBarOffset = Math.max(0, -model.getMinimum()); getHorizontalBar().setValues(model.getValue() + hBarOffset, model.getMinimum() + hBarOffset, model.getMaximum() + hBarOffset, model.getExtent(), Math.max(1, model.getExtent() / 20), Math.max(1, model.getExtent() * 3 / 4)); } }; private PropertyChangeListener verticalChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { RangeModel model = getViewport().getVerticalRangeModel(); vBarOffset = Math.max(0, -model.getMinimum()); getVerticalBar().setValues(model.getValue() + vBarOffset, model.getMinimum() + vBarOffset, model.getMaximum() + vBarOffset, model.getExtent(), Math.max(1, model.getExtent() / 20), Math.max(1, model.getExtent() * 3 / 4)); } }; private final LightweightSystem lws; /** * Creates a new FigureCanvas with the given parent and the * {@link #DEFAULT_STYLES}. * * @param parent * the parent */ public FigureCanvas(Composite parent) { this(parent, SWT.DOUBLE_BUFFERED, new LightweightSystem()); } /** * Constructor which applies the default styles plus any optional styles * indicated. * * @param parent * the parent composite * @param style * see the class javadoc for optional styles * @since 3.1 */ public FigureCanvas(Composite parent, int style) { this(parent, style, new LightweightSystem()); } /** * Constructor which uses the given styles verbatim. Certain styles must be * used with this class. Refer to the class javadoc for more details. * * @param style * see the class javadoc for required and optional styles * @param parent * the parent composite * @since 3.4 */ public FigureCanvas(int style, Composite parent) { this(style, parent, new LightweightSystem()); } /** * Constructs a new FigureCanvas with the given parent and * LightweightSystem, using the {@link #DEFAULT_STYLES}. * * @param parent * the parent * @param lws * the LightweightSystem */ public FigureCanvas(Composite parent, LightweightSystem lws) { this(parent, SWT.DOUBLE_BUFFERED, lws); } /** * Constructor taking a lightweight system and SWT style, which is used * verbatim. Certain styles must be used with this class. Refer to the class * javadoc for more details. * * @param style * see the class javadoc for required and optional styles * @param parent * the parent composite * @param lws * the LightweightSystem * @since 3.4 */ public FigureCanvas(int style, Composite parent, LightweightSystem lws) { super(parent, checkStyle(style)); getHorizontalBar().setVisible(false); getVerticalBar().setVisible(false); this.lws = lws; lws.setControl(this); hook(); } /** * Constructor * * @param parent * the parent composite * @param style * look at class javadoc for valid styles * @param lws * the lightweight system * @since 3.1 */ public FigureCanvas(Composite parent, int style, LightweightSystem lws) { this(style | DEFAULT_STYLES, parent, lws); } private static int checkStyle(int style) { if ((style & REQUIRED_STYLES) != REQUIRED_STYLES) throw new IllegalArgumentException( "Required style missing on FigureCanvas"); //$NON-NLS-1$ if ((style & ~ACCEPTED_STYLES) != 0) throw new IllegalArgumentException( "Invalid style being set on FigureCanvas"); //$NON-NLS-1$ return style; } /** * @see org.eclipse.swt.widgets.Composite#computeSize(int, int, boolean) */ public org.eclipse.swt.graphics.Point computeSize(int wHint, int hHint, boolean changed) { // TODO Still doesn't handle scrollbar cases, such as when a constrained // width // would require a horizontal scrollbar, and therefore additional // height. int borderSize = computeTrim(0, 0, 0, 0).x * -2; if (wHint >= 0) wHint = Math.max(0, wHint - borderSize); if (hHint >= 0) hHint = Math.max(0, hHint - borderSize); Dimension size = getLightweightSystem().getRootFigure() .getPreferredSize(wHint, hHint) .getExpanded(borderSize, borderSize); size.union(new Dimension(wHint, hHint)); return new org.eclipse.swt.graphics.Point(size.width, size.height); } /** * @return the contents of the {@link Viewport}. */ public IFigure getContents() { return getViewport().getContents(); } /** * @see org.eclipse.swt.widgets.Control#getFont() */ public Font getFont() { if (font == null) font = super.getFont(); return font; } /** * @return the horizontal scrollbar visibility. */ public int getHorizontalScrollBarVisibility() { return hBarVisibility; } /** * @return the LightweightSystem */ public LightweightSystem getLightweightSystem() { return lws; } /** * @return the vertical scrollbar visibility. */ public int getVerticalScrollBarVisibility() { return vBarVisibility; } /** * Returns the Viewport. If it's null, a new one is created. * * @return the viewport */ public Viewport getViewport() { if (viewport == null) setViewport(new Viewport(true)); return viewport; } /** * Adds listeners for scrolling. */ private void hook() { getLightweightSystem().getUpdateManager().addUpdateListener( new UpdateListener() { public void notifyPainting(Rectangle damage, java.util.Map dirtyRegions) { } public void notifyValidating() { if (!isDisposed()) layoutViewport(); } }); getHorizontalBar().addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { scrollToX(getHorizontalBar().getSelection() - hBarOffset); } }); getVerticalBar().addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { scrollToY(getVerticalBar().getSelection() - vBarOffset); } }); } private void hookViewport() { getViewport().getHorizontalRangeModel().addPropertyChangeListener( horizontalChangeListener); getViewport().getVerticalRangeModel().addPropertyChangeListener( verticalChangeListener); } private void unhookViewport() { getViewport().getHorizontalRangeModel().removePropertyChangeListener( horizontalChangeListener); getViewport().getVerticalRangeModel().removePropertyChangeListener( verticalChangeListener); } private void layoutViewport() { ScrollPaneSolver.Result result; result = ScrollPaneSolver.solve( new Rectangle(getBounds()).setLocation(0, 0), getViewport(), getHorizontalScrollBarVisibility(), getVerticalScrollBarVisibility(), computeTrim(0, 0, 0, 0).width, computeTrim(0, 0, 0, 0).height); getLightweightSystem().setIgnoreResize(true); try { if (getHorizontalBar().getVisible() != result.showH) getHorizontalBar().setVisible(result.showH); if (getVerticalBar().getVisible() != result.showV) getVerticalBar().setVisible(result.showV); Rectangle r = new Rectangle(getClientArea()); r.setLocation(0, 0); getLightweightSystem().getRootFigure().setBounds(r); } finally { getLightweightSystem().setIgnoreResize(false); } } /** * Scrolls in an animated way to the new x and y location. * * @param x * the x coordinate to scroll to * @param y * the y coordinate to scroll to */ public void scrollSmoothTo(int x, int y) { // Ensure newHOffset and newVOffset are within the appropriate ranges x = verifyScrollBarOffset(getViewport().getHorizontalRangeModel(), x); y = verifyScrollBarOffset(getViewport().getVerticalRangeModel(), y); int oldX = getViewport().getViewLocation().x; int oldY = getViewport().getViewLocation().y; int dx = x - oldX; int dy = y - oldY; if (dx == 0 && dy == 0) return; // Nothing to do. Dimension viewingArea = getViewport().getClientArea().getSize(); int minFrames = 3; int maxFrames = 6; if (dx == 0 || dy == 0) { minFrames = 6; maxFrames = 13; } int frames = (Math.abs(dx) + Math.abs(dy)) / 15; frames = Math.max(frames, minFrames); frames = Math.min(frames, maxFrames); int stepX = Math.min((dx / frames), (viewingArea.width / 3)); int stepY = Math.min((dy / frames), (viewingArea.height / 3)); for (int i = 1; i < frames; i++) { scrollTo(oldX + i * stepX, oldY + i * stepY); getViewport().getUpdateManager().performUpdate(); } scrollTo(x, y); } /** * Scrolls the contents to the new x and y location. If this scroll * operation only consists of a vertical or horizontal scroll, a call will * be made to {@link #scrollToY(int)} or {@link #scrollToX(int)}, * respectively, to increase performance. * * @param x * the x coordinate to scroll to * @param y * the y coordinate to scroll to */ public void scrollTo(int x, int y) { x = verifyScrollBarOffset(getViewport().getHorizontalRangeModel(), x); y = verifyScrollBarOffset(getViewport().getVerticalRangeModel(), y); if (x == getViewport().getViewLocation().x) scrollToY(y); else if (y == getViewport().getViewLocation().y) scrollToX(x); else getViewport().setViewLocation(x, y); } /** * Scrolls the contents horizontally so that they are offset by * hOffset. * * @param hOffset * the new horizontal offset */ public void scrollToX(int hOffset) { hOffset = verifyScrollBarOffset( getViewport().getHorizontalRangeModel(), hOffset); int hOffsetOld = getViewport().getViewLocation().x; if (hOffset == hOffsetOld) return; int dx = -hOffset + hOffsetOld; Rectangle clientArea = getViewport().getBounds().getCropped( getViewport().getInsets()); Rectangle blit = clientArea.getResized(-Math.abs(dx), 0); Rectangle expose = clientArea.getCopy(); Point dest = clientArea.getTopLeft(); expose.width = Math.abs(dx); if (dx < 0) { // Moving left? blit.translate(-dx, 0); // Move blit area to the right expose.x = dest.x + blit.width; } else // Moving right dest.x += dx; // Move expose area to the right // fix for bug 41111 Control[] children = getChildren(); boolean[] manualMove = new boolean[children.length]; for (int i = 0; i < children.length; i++) { org.eclipse.swt.graphics.Rectangle bounds = children[i].getBounds(); manualMove[i] = blit.width <= 0 || bounds.x > blit.x + blit.width || bounds.y > blit.y + blit.height || bounds.x + bounds.width < blit.x || bounds.y + bounds.height < blit.y; } scroll(dest.x, dest.y, blit.x, blit.y, blit.width, blit.height, true); for (int i = 0; i < children.length; i++) { if (children[i].isDisposed()) continue; org.eclipse.swt.graphics.Rectangle bounds = children[i].getBounds(); if (manualMove[i]) children[i].setBounds(bounds.x + dx, bounds.y, bounds.width, bounds.height); } getViewport().setIgnoreScroll(true); getViewport().setHorizontalLocation(hOffset); getViewport().setIgnoreScroll(false); redraw(expose.x, expose.y, expose.width, expose.height, true); } /** * Scrolls the contents vertically so that they are offset by * vOffset. * * @param vOffset * the new vertical offset */ public void scrollToY(int vOffset) { vOffset = verifyScrollBarOffset(getViewport().getVerticalRangeModel(), vOffset); int vOffsetOld = getViewport().getViewLocation().y; if (vOffset == vOffsetOld) return; int dy = -vOffset + vOffsetOld; Rectangle clientArea = getViewport().getBounds().getCropped( getViewport().getInsets()); Rectangle blit = clientArea.getResized(0, -Math.abs(dy)); Rectangle expose = clientArea.getCopy(); Point dest = clientArea.getTopLeft(); expose.height = Math.abs(dy); if (dy < 0) { // Moving up? blit.translate(0, -dy); // Move blit area down expose.y = dest.y + blit.height; // Move expose area down } else // Moving down dest.y += dy; // fix for bug 41111 Control[] children = getChildren(); boolean[] manualMove = new boolean[children.length]; for (int i = 0; i < children.length; i++) { org.eclipse.swt.graphics.Rectangle bounds = children[i].getBounds(); manualMove[i] = blit.height <= 0 || bounds.x > blit.x + blit.width || bounds.y > blit.y + blit.height || bounds.x + bounds.width < blit.x || bounds.y + bounds.height < blit.y; } scroll(dest.x, dest.y, blit.x, blit.y, blit.width, blit.height, true); for (int i = 0; i < children.length; i++) { if (children[i].isDisposed()) continue; org.eclipse.swt.graphics.Rectangle bounds = children[i].getBounds(); if (manualMove[i]) children[i].setBounds(bounds.x, bounds.y + dy, bounds.width, bounds.height); } getViewport().setIgnoreScroll(true); getViewport().setVerticalLocation(vOffset); getViewport().setIgnoreScroll(false); redraw(expose.x, expose.y, expose.width, expose.height, true); } /** * Sets the given border on the LightweightSystem's root figure. * * @param border * The new border */ public void setBorder(Border border) { getLightweightSystem().getRootFigure().setBorder(border); } /** * Sets the contents of the {@link Viewport}. * * @param figure * the new contents */ public void setContents(IFigure figure) { getViewport().setContents(figure); } /** * @see org.eclipse.swt.widgets.Control#setFont(org.eclipse.swt.graphics.Font) */ public void setFont(Font font) { this.font = font; super.setFont(font); } /** * Sets the horizontal scrollbar visibility. Possible values are * {@link #AUTOMATIC}, {@link #ALWAYS}, and {@link #NEVER}. * * @param v * the new visibility */ public void setHorizontalScrollBarVisibility(int v) { hBarVisibility = v; } /** * Sets both the horizontal and vertical scrollbar visibility to the given * value. Possible values are {@link #AUTOMATIC}, {@link #ALWAYS}, and * {@link #NEVER}. * * @param both * the new visibility */ public void setScrollBarVisibility(int both) { setHorizontalScrollBarVisibility(both); setVerticalScrollBarVisibility(both); } /** * Sets the vertical scrollbar visibility. Possible values are * {@link #AUTOMATIC}, {@link #ALWAYS}, and {@link #NEVER}. * * @param v * the new visibility */ public void setVerticalScrollBarVisibility(int v) { vBarVisibility = v; } /** * Sets the Viewport. The given Viewport must use "fake" scrolling. That is, * it must be constructed using new Viewport(true). * * @param vp * the new viewport */ public void setViewport(Viewport vp) { if (viewport != null) unhookViewport(); viewport = vp; lws.setContents(viewport); hookViewport(); } private int verifyScrollBarOffset(RangeModel model, int value) { value = Math.max(model.getMinimum(), value); return Math.min(model.getMaximum() - model.getExtent(), value); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/FigureListener.java000066400000000000000000000015221166301720600272620ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; /** * A listener interface for receiving notification that an IFigure has moved. */ public interface FigureListener { /** * Called when the given IFigure has moved. * * @param source * The IFigure that has moved. */ void figureMoved(IFigure source); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/FigureUtilities.java000066400000000000000000000274121166301720600274560ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.ArrayList; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontMetrics; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.widgets.Shell; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Rectangle; /** * Provides miscellaneous Figure operations. */ public class FigureUtilities { private static final float RGB_VALUE_MULTIPLIER = 0.6f; private static GC gc; private static Font appliedFont; private static FontMetrics metrics; private static Color ghostFillColor = new Color(null, 31, 31, 31); /** * Returns a new Color the same as the passed color in a darker hue. * * @param color * the color to darken * @return the darkened color * @since 2.0 */ public static Color darker(Color color) { return new Color(null, (int) (color.getRed() * RGB_VALUE_MULTIPLIER), (int) (color.getGreen() * RGB_VALUE_MULTIPLIER), (int) (color.getBlue() * RGB_VALUE_MULTIPLIER)); } /** * Returns the FontMetrics associated with the passed Font. * * @param f * the font * @return the FontMetrics for the given font * @see GC#getFontMetrics() * @since 2.0 */ public static FontMetrics getFontMetrics(Font f) { setFont(f); if (metrics == null) metrics = getGC().getFontMetrics(); return metrics; } /** * Returns the GC used for various utilities. Advanced graphics must not be * switched on by clients using this GC. * * @deprecated do not mess with this GC * @return the GC */ protected static GC getGC() { if (gc == null) { gc = new GC(new Shell()); appliedFont = gc.getFont(); } return gc; } /** * Returns the dimensions of the String s using the font f. * Tab expansion and carriage return processing are performed. * * @param s * the string * @param f * the font * @return the text's dimensions * @see GC#textExtent(String) */ protected static org.eclipse.swt.graphics.Point getTextDimension(String s, Font f) { setFont(f); return getGC().textExtent(s); } /** * Returns the highest ancestor for the given figure * * @since 3.0 * @param figure * a figure * @return the root ancestor */ public static IFigure getRoot(IFigure figure) { while (figure.getParent() != null) figure = figure.getParent(); return figure; } /** * Returns the dimensions of the String s using the font f. No * tab expansion or carriage return processing will be performed. * * @param s * the string * @param f * the font * @return the string's dimensions * @see GC#stringExtent(java.lang.String) */ protected static org.eclipse.swt.graphics.Point getStringDimension( String s, Font f) { setFont(f); return getGC().stringExtent(s); } /** * Returns the Dimensions of the given text, converting newlines and tabs * appropriately. * * @param text * the text * @param f * the font * @return the dimensions of the given text * @since 2.0 */ public static Dimension getTextExtents(String text, Font f) { return new Dimension(getTextDimension(text, f)); } /** * Returns the Dimensions of s in Font f. * * @param s * the string * @param f * the font * @return the dimensions of the given string * @since 2.0 */ public static Dimension getStringExtents(String s, Font f) { return new Dimension(getStringDimension(s, f)); } /** * Returns the Dimensions of the given text, converting newlines and tabs * appropriately. * * @param s * the string * @param f * the font * @param result * the Dimension that will contain the result of this calculation * @since 2.0 */ public static void getTextExtents(String s, Font f, Dimension result) { org.eclipse.swt.graphics.Point pt = getTextDimension(s, f); result.width = pt.x; result.height = pt.y; } /** * Returns the width of s in Font f. * * @param s * the string * @param f * the font * @return the width * @since 2.0 */ public static int getTextWidth(String s, Font f) { return getTextDimension(s, f).x; } /** * Returns a Color the same as the passed color in a lighter hue. * * @param rgb * the color * @return the lighter color * @since 2.0 */ public static Color lighter(Color rgb) { int r = rgb.getRed(), g = rgb.getGreen(), b = rgb.getBlue(); return new Color(null, Math.max(2, Math.min((int) (r / RGB_VALUE_MULTIPLIER), 255)), Math.max(2, Math.min((int) (g / RGB_VALUE_MULTIPLIER), 255)), Math.max(2, Math.min((int) (b / RGB_VALUE_MULTIPLIER), 255))); } /** * Produces a ghosting effect on the shape s. * * @param s * the shape * @return the ghosted shape * @since 2.0 */ public static Shape makeGhostShape(Shape s) { s.setBackgroundColor(ghostFillColor); s.setFillXOR(true); s.setOutlineXOR(true); return s; } /** * Mixes the passed Colors and returns the resulting Color. * * @param c1 * the first color * @param c2 * the second color * @param weight * the first color's weight from 0-1 * @return the new color * @since 2.0 */ public static Color mixColors(Color c1, Color c2, double weight) { return new Color(null, (int) (c1.getRed() * weight + c2.getRed() * (1 - weight)), (int) (c1.getGreen() * weight + c2.getGreen() * (1 - weight)), (int) (c1.getBlue() * weight + c2.getBlue() * (1 - weight))); } /** * Mixes the passed Colors and returns the resulting Color. * * @param c1 * the first color * @param c2 * the second color * @return the new color * @since 2.0 */ public static Color mixColors(Color c1, Color c2) { return new Color(null, (c1.getRed() + c2.getRed()) / 2, (c1.getGreen() + c2.getGreen()) / 2, (c1.getBlue() + c2.getBlue()) / 2); } /** * Paints a border with an etching effect, having a shadow of Color * shadow and highlight of Color highlight. * * @param g * the graphics object * @param r * the bounds of the border * @param shadow * the shadow color * @param highlight * the highlight color * @since 2.0 */ public static void paintEtchedBorder(Graphics g, Rectangle r, Color shadow, Color highlight) { int x = r.x, y = r.y, w = r.width, h = r.height; g.setLineStyle(Graphics.LINE_SOLID); g.setLineWidth(1); g.setXORMode(false); w -= 2; h -= 2; g.setForegroundColor(shadow); g.drawRectangle(x, y, w, h); x++; y++; g.setForegroundColor(highlight); g.drawRectangle(x, y, w, h); } /** * Helper method to paint a grid. Painting is optimized as it is restricted * to the Graphics' clip. * * @param g * The Graphics object to be used for painting * @param f * The figure in which the grid is to be painted * @param origin * Any point where the grid lines are expected to intersect * @param distanceX * Distance between vertical grid lines; if 0 or less, vertical * grid lines will not be drawn * @param distanceY * Distance between horizontal grid lines; if 0 or less, * horizontal grid lines will not be drawn * * @since 3.0 */ public static void paintGrid(Graphics g, IFigure f, org.eclipse.draw2d.geometry.Point origin, int distanceX, int distanceY) { Rectangle clip = g.getClip(Rectangle.SINGLETON); if (distanceX > 0) { if (origin.x >= clip.x) while (origin.x - distanceX >= clip.x) origin.x -= distanceX; else while (origin.x < clip.x) origin.x += distanceX; for (int i = origin.x; i < clip.x + clip.width; i += distanceX) g.drawLine(i, clip.y, i, clip.y + clip.height); } if (distanceY > 0) { if (origin.y >= clip.y) while (origin.y - distanceY >= clip.y) origin.y -= distanceY; else while (origin.y < clip.y) origin.y += distanceY; for (int i = origin.y; i < clip.y + clip.height; i += distanceY) g.drawLine(clip.x, i, clip.x + clip.width, i); } } /** * Paints a border with an etching effect, having a shadow of a darker * version of g's background color, and a highlight a lighter version of g's * background color. * * @param g * the graphics object * @param r * the bounds of the border * @since 2.0 */ public static void paintEtchedBorder(Graphics g, Rectangle r) { Color rgb = g.getBackgroundColor(), shadow = darker(rgb), highlight = lighter(rgb); paintEtchedBorder(g, r, shadow, highlight); } /** * Sets Font to passed value. * * @param f * the new font * @since 2.0 */ protected static void setFont(Font f) { if (appliedFont == f || f.equals(appliedFont)) return; getGC().setFont(f); appliedFont = f; metrics = null; } /** * Returns the figure which is the nearest common ancestor of both figures, * or null if there is no common ancestor. A figure is an * ancestor if it is the parent of another figure, or if it is the ancestor * of that figure's parent. If one figure is the ancestor of the other, it * is returned as the common ancestor. * * @since 3.1 * @param l * left * @param r * right * @return the common ancestor, if it exists, or null. */ public static IFigure findCommonAncestor(IFigure l, IFigure r) { if (l == r) return l; ArrayList left = new ArrayList(); ArrayList right = new ArrayList(); while (l != null) { left.add(l); l = l.getParent(); } while (r != null) { right.add(r); r = r.getParent(); } if (left.isEmpty() || right.isEmpty()) return null; for (int i = 0; i < left.size(); i++) { if (right.contains(left.get(i))) return (IFigure) left.get(i); } return null; } /** * Returns true if the ancestor contains the descendant, or is * the ancestor of the descendant's parent. * * @param ancestor * the ancestor * @param descendant * the descendant * @return true if ancestor * @since 3.2 */ public static boolean isAncestor(final IFigure ancestor, IFigure descendant) { while (descendant != null) { descendant = descendant.getParent(); if (descendant == ancestor) return true; } return false; } /** * Determines whether the given figure is showing and not (completely) * clipped. * * @param figure * The figure to test * @return true if the given figure is showing and not * completely clipped, false otherwise. * @since 3.7 */ public static boolean isNotFullyClipped(IFigure figure) { if (figure == null || !figure.isShowing()) { return false; } // check if figure is clipped // TODO: IClippingStrategy has to be taken into consideration as well. Rectangle figBounds = figure.getBounds().getCopy(); IFigure walker = figure.getParent(); while (!figBounds.isEmpty() && walker != null) { walker.translateToParent(figBounds); figBounds.intersect(walker.getBounds()); walker = walker.getParent(); } return !figBounds.isEmpty(); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/FlowLayout.java000066400000000000000000000270451166301720600264500ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.Iterator; import java.util.List; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Rectangle; /** * Lays out children in rows or columns, wrapping when the current row/column is * filled. The aligment and spacing of rows in the parent can be configured. The * aligment and spacing of children within a row can be configured. */ public class FlowLayout extends OrderedLayout { /** * Holds the necessary information for layout calculations. */ protected class WorkingData { public Rectangle bounds[], area; public IFigure row[]; public int rowHeight, rowWidth, rowCount, rowX, rowY, maxWidth; } /** * Constant to specify components to be aligned on the left/top * * @deprecated Use {@link OrderedLayout#ALIGN_TOPLEFT} instead. */ public static final int ALIGN_LEFTTOP = ALIGN_TOPLEFT; /** * Constant to specify components to be aligned on the right/bottom * * @deprecated Use {@link OrderedLayout#ALIGN_BOTTOMRIGHT} instead. */ public static final int ALIGN_RIGHTBOTTOM = ALIGN_BOTTOMRIGHT; protected WorkingData data = null; /** * The property that determines whether leftover space at the end of a * row/column should be filled by the last item in that row/column. * * @deprecated Use {@link OrderedLayout#setStretchMinorAxis(boolean)} and * {@link OrderedLayout#isStretchMinorAxis()} instead. */ protected boolean fill; /** * The alignment along the major axis. * * @deprecated Use {@link #getMajorAlignment()} and * {@link #setMajorAlignment(int)} instead. */ protected int majorAlignment = ALIGN_TOPLEFT; /** * The spacing along the major axis. * * @deprecated Use {@link #getMajorSpacing()} and * {@link #setMajorSpacing(int)} instead. */ protected int majorSpacing = 5; /** * The spacing along the minor axis. * * @deprecated Use {@link #getMinorSpacing()} and * {@link #setMinorSpacing(int)} instead. */ protected int minorSpacing = 5; /** * Constructs a FlowLayout with horizontal orientation. * * @since 2.0 */ public FlowLayout() { setStretchMinorAxis(false); } /** * Constructs a FlowLayout whose orientation is given in the input. * * @param isHorizontal * true if the layout should be horizontal * @since 2.0 */ public FlowLayout(boolean isHorizontal) { setHorizontal(isHorizontal); setStretchMinorAxis(false); } /** * @see org.eclipse.draw2d.AbstractLayout#calculatePreferredSize(IFigure, * int, int) */ protected Dimension calculatePreferredSize(IFigure container, int wHint, int hHint) { // Subtract out the insets from the hints if (wHint > -1) wHint = Math.max(0, wHint - container.getInsets().getWidth()); if (hHint > -1) hHint = Math.max(0, hHint - container.getInsets().getHeight()); // Figure out the new hint that we are interested in based on the // orientation // Ignore the other hint (by setting it to -1). NOTE: The children of // the // parent figure will then be asked to ignore that hint as well. int maxWidth; if (isHorizontal()) { maxWidth = wHint; hHint = -1; } else { maxWidth = hHint; wHint = -1; } if (maxWidth < 0) { maxWidth = Integer.MAX_VALUE; } // The preferred dimension that is to be calculated and returned Dimension prefSize = new Dimension(); List children = container.getChildren(); int width = 0; int height = 0; IFigure child; Dimension childSize; // Build the sizes for each row, and update prefSize accordingly for (int i = 0; i < children.size(); i++) { child = (IFigure) children.get(i); childSize = transposer.t(getChildSize(child, wHint, hHint)); if (i == 0) { width = childSize.width; height = childSize.height; } else if (width + childSize.width + getMinorSpacing() > maxWidth) { // The current row is full, start a new row. prefSize.height += height + getMajorSpacing(); prefSize.width = Math.max(prefSize.width, width); width = childSize.width; height = childSize.height; } else { // The current row can fit another child. width += childSize.width + getMinorSpacing(); height = Math.max(height, childSize.height); } } // Flush out the last row's data prefSize.height += height; prefSize.width = Math.max(prefSize.width, width); // Transpose the dimension back, and compensate for the border. prefSize = transposer.t(prefSize); prefSize.width += container.getInsets().getWidth(); prefSize.height += container.getInsets().getHeight(); prefSize.union(getBorderPreferredSize(container)); return prefSize; } /** * Provides the given child's preferred size. * * @param child * the Figure whose preferred size needs to be calculated * @param wHint * the width hint * @param hHint * the height hint * @return the child's preferred size */ protected Dimension getChildSize(IFigure child, int wHint, int hHint) { return child.getPreferredSize(wHint, hHint); } /** * Returns {@link PositionConstants#HORIZONTAL} by default. * * @see org.eclipse.draw2d.OrderedLayout#getDefaultOrientation() */ protected int getDefaultOrientation() { return PositionConstants.HORIZONTAL; } /** * Returns the alignment used for an entire row/column. *

* Possible values are : *

    *
  • {@link #ALIGN_CENTER} *
  • {@link #ALIGN_LEFTTOP} *
  • {@link #ALIGN_RIGHTBOTTOM} *
* * @return the major alignment * @since 2.0 */ public int getMajorAlignment() { return majorAlignment; } /** * Returns the spacing in pixels to be used between children in the * direction parallel to the layout's orientation. * * @return the major spacing */ public int getMajorSpacing() { return majorSpacing; } /** * Returns the spacing to be used between children within a row/column. * * @return the minor spacing */ public int getMinorSpacing() { return minorSpacing; } /** * Initializes the state of row data, which is internal to the layout * process. */ protected void initRow() { data.rowX = 0; data.rowHeight = 0; data.rowWidth = 0; data.rowCount = 0; } /** * Initializes state data for laying out children, based on the Figure given * as input. * * @param parent * the parent figure * @since 2.0 */ protected void initVariables(IFigure parent) { data.row = new IFigure[parent.getChildren().size()]; data.bounds = new Rectangle[data.row.length]; data.maxWidth = data.area.width; } /** * @see org.eclipse.draw2d.AbstractHintLayout#isSensitiveHorizontally(IFigure) */ protected boolean isSensitiveHorizontally(IFigure parent) { return isHorizontal(); } /** * @see org.eclipse.draw2d.AbstractHintLayout#isSensitiveVertically(IFigure) */ protected boolean isSensitiveVertically(IFigure parent) { return !isHorizontal(); } /** * Overwritten to guarantee backwards compatibility with {@link #fill} * field. * * @see org.eclipse.draw2d.OrderedLayout#isStretchMinorAxis() */ public boolean isStretchMinorAxis() { return fill; } /** * @see org.eclipse.draw2d.LayoutManager#layout(IFigure) */ public void layout(IFigure parent) { data = new WorkingData(); Rectangle relativeArea = parent.getClientArea(); data.area = transposer.t(relativeArea); Iterator iterator = parent.getChildren().iterator(); int dx; // Calculate the hints to be passed to children int wHint = -1; int hHint = -1; if (isHorizontal()) wHint = parent.getClientArea().width; else hHint = parent.getClientArea().height; initVariables(parent); initRow(); while (iterator.hasNext()) { IFigure f = (IFigure) iterator.next(); Dimension pref = transposer.t(getChildSize(f, wHint, hHint)); Rectangle r = new Rectangle(0, 0, pref.width, pref.height); if (data.rowCount > 0) { if (data.rowWidth + pref.width > data.maxWidth) layoutRow(parent); } r.x = data.rowX; r.y = data.rowY; dx = r.width + getMinorSpacing(); data.rowX += dx; data.rowWidth += dx; data.rowHeight = Math.max(data.rowHeight, r.height); data.row[data.rowCount] = f; data.bounds[data.rowCount] = r; data.rowCount++; } if (data.rowCount != 0) layoutRow(parent); data = null; } /** * Layouts one row of components. This is done based on the layout's * orientation, minor alignment and major alignment. * * @param parent * the parent figure * @since 2.0 */ protected void layoutRow(IFigure parent) { int majorAdjustment = 0; int minorAdjustment = 0; int correctMajorAlignment = getMajorAlignment(); int correctMinorAlignment = getMinorAlignment(); majorAdjustment = data.area.width - data.rowWidth + getMinorSpacing(); switch (correctMajorAlignment) { case ALIGN_TOPLEFT: majorAdjustment = 0; break; case ALIGN_CENTER: majorAdjustment /= 2; break; case ALIGN_BOTTOMRIGHT: break; } for (int j = 0; j < data.rowCount; j++) { if (isStretchMinorAxis()) { data.bounds[j].height = data.rowHeight; } else { minorAdjustment = data.rowHeight - data.bounds[j].height; switch (correctMinorAlignment) { case ALIGN_TOPLEFT: minorAdjustment = 0; break; case ALIGN_CENTER: minorAdjustment /= 2; break; case ALIGN_BOTTOMRIGHT: break; } data.bounds[j].y += minorAdjustment; } data.bounds[j].x += majorAdjustment; setBoundsOfChild(parent, data.row[j], transposer.t(data.bounds[j])); } data.rowY += getMajorSpacing() + data.rowHeight; initRow(); } /** * Sets the given bounds for the child figure input. * * @param parent * the parent figure * @param child * the child figure * @param bounds * the size of the child to be set * @since 2.0 */ protected void setBoundsOfChild(IFigure parent, IFigure child, Rectangle bounds) { parent.getClientArea(Rectangle.SINGLETON); bounds.translate(Rectangle.SINGLETON.x, Rectangle.SINGLETON.y); child.setBounds(bounds); } /** * Sets the alignment for an entire row/column within the parent figure. *

* Possible values are : *

    *
  • {@link #ALIGN_CENTER} *
  • {@link #ALIGN_LEFTTOP} *
  • {@link #ALIGN_RIGHTBOTTOM} *
* * @param align * the major alignment * @since 2.0 */ public void setMajorAlignment(int align) { majorAlignment = align; } /** * Sets the spacing in pixels to be used between children in the direction * parallel to the layout's orientation. * * @param n * the major spacing * @since 2.0 */ public void setMajorSpacing(int n) { majorSpacing = n; } /** * Sets the spacing to be used between children within a row/column. * * @param n * the minor spacing * @since 2.0 */ public void setMinorSpacing(int n) { minorSpacing = n; } /** * Overwritten to guarantee backwards compatibility with {@link #fill} * field. * * @see org.eclipse.draw2d.OrderedLayout#setStretchMinorAxis(boolean) */ public void setStretchMinorAxis(boolean value) { fill = value; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/FocusBorder.java000066400000000000000000000026741166301720600265610ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Insets; /** * A Border that looks like the system's focus rectangle. */ public class FocusBorder extends AbstractBorder { /** * Constructs a new FocusBorder. */ public FocusBorder() { } /** * @see org.eclipse.draw2d.Border#getInsets(IFigure) */ public Insets getInsets(IFigure figure) { return new Insets(1); } /** * @see org.eclipse.draw2d.Border#isOpaque() */ public boolean isOpaque() { return true; } /** * Paints a focus rectangle. * * @see org.eclipse.draw2d.Border#paint(IFigure, Graphics, Insets) */ public void paint(IFigure figure, Graphics graphics, Insets insets) { tempRect.setBounds(getPaintRectangle(figure, insets)); tempRect.width--; tempRect.height--; graphics.setForegroundColor(ColorConstants.black); graphics.setBackgroundColor(ColorConstants.white); graphics.drawFocus(tempRect); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/FocusEvent.java000066400000000000000000000020641166301720600264160ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; /** * An event that occurs when an {@link org.eclipse.draw2d.IFigure} gains or * loses focus. */ public class FocusEvent { /** The figure losing focus */ public IFigure loser; /** The figure gaining focus */ public IFigure gainer; /** * Constructs a new FocusEvent. * * @param loser * the figure losing focus * @param gainer * the figure gaining focus */ public FocusEvent(IFigure loser, IFigure gainer) { this.loser = loser; this.gainer = gainer; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/FocusListener.java000066400000000000000000000025271166301720600271260ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; /** * A listener interface for receiving {@link FocusEvent FocusEvents}. */ public interface FocusListener { /** * Called when the listened to object has gained focus. * * @param fe * The FocusEvent object */ void focusGained(FocusEvent fe); /** * Called when the listened to object has lost focus. * * @param fe * The FocusEvent object */ void focusLost(FocusEvent fe); /** * An empty implementation of FocusListener for convenience. */ public class Stub implements FocusListener { /** * @see org.eclipse.draw2d.FocusListener#focusGained(FocusEvent) */ public void focusGained(FocusEvent fe) { } /** * @see org.eclipse.draw2d.FocusListener#focusLost(FocusEvent) */ public void focusLost(FocusEvent fe) { } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/FocusTraverseManager.java000066400000000000000000000132271166301720600304260ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.List; /** * This class is a helper to the {@link SWTEventDispatcher}. It handles the task * of determining which Figure will gain focus upon a tab/shift-tab. It also * keeps track of the Figure with current focus. *

* Note: When a Canvas with a {@link LightweightSystem} gains focus, it gives * focus to the child Figure who had focus when this Canvas lost focus. If the * canvas is gaining focus for the first time, focus is given to its first child * Figure. */ public class FocusTraverseManager { IFigure currentFocusOwner; /** * Default constructor. */ public FocusTraverseManager() { } private IFigure findDeepestRightmostChildOf(IFigure fig) { while (fig.getChildren().size() != 0) { fig = (IFigure) fig.getChildren().get(fig.getChildren().size() - 1); } return fig; } /** * Returns the IFigure that will receive focus upon a 'tab' traverse event. * * @param root * the {@link LightweightSystem LightweightSystem's} root figure * @param prevFocus * the IFigure who currently owns focus * @return the next focusable figure */ public IFigure getNextFocusableFigure(IFigure root, IFigure prevFocus) { boolean found = false; IFigure nextFocus = prevFocus; /* * If no Figure currently has focus, apply focus to root's first * focusable child. */ if (prevFocus == null) { if (root.getChildren().size() != 0) { nextFocus = ((IFigure) root.getChildren().get(0)); if (isFocusEligible(nextFocus)) return nextFocus; } else return null; } int siblingPos = nextFocus.getParent().getChildren().indexOf(nextFocus); while (!found) { IFigure parent = nextFocus.getParent(); /* * Figure traversal is implemented using the pre-order left to right * tree traversal algorithm. * * If the focused sibling has children, traverse to its leftmost * child. If the focused sibling has no children, traverse to the * sibling to its right. If there is no sibling to the right, go up * the tree until a node with un-traversed siblings is found. */ List siblings = parent.getChildren(); if (nextFocus.getChildren().size() != 0) { nextFocus = (IFigure) nextFocus.getChildren().get(0); siblingPos = 0; if (isFocusEligible(nextFocus)) found = true; } else if (siblingPos < siblings.size() - 1) { nextFocus = ((IFigure) (siblings.get(++siblingPos))); if (isFocusEligible(nextFocus)) found = true; } else { boolean untraversedSiblingFound = false; while (!untraversedSiblingFound) { IFigure p = nextFocus.getParent(); IFigure gp = p.getParent(); if (gp != null) { int parentSiblingCount = gp.getChildren().size(); int parentIndex = gp.getChildren().indexOf(p); if (parentIndex < parentSiblingCount - 1) { nextFocus = ((IFigure) p.getParent().getChildren() .get(parentIndex + 1)); siblingPos = parentIndex + 1; untraversedSiblingFound = true; if (isFocusEligible(nextFocus)) found = true; } else nextFocus = p; } else { nextFocus = null; untraversedSiblingFound = true; found = true; } } } } return nextFocus; } /** * Returns the IFigure that will receive focus upon a 'shift-tab' traverse * event. * * @param root * The {@link LightweightSystem LightweightSystem's} root figure * @param prevFocus * The IFigure who currently owns focus * @return the previous focusable figure */ public IFigure getPreviousFocusableFigure(IFigure root, IFigure prevFocus) { if (prevFocus == null) return null; boolean found = false; IFigure nextFocus = prevFocus; while (!found) { IFigure parent = nextFocus.getParent(); /* * At root, return null to indicate traversal is complete. */ if (parent == null) return null; List siblings = parent.getChildren(); int siblingPos = siblings.indexOf(nextFocus); /* * Figure traversal is implemented using the post-order right to * left tree traversal algorithm. * * Find the rightmost child. If this child is focusable, return it * If not focusable, traverse to its sibling and repeat. If there is * no sibling, traverse its parent. */ if (siblingPos != 0) { IFigure child = findDeepestRightmostChildOf((IFigure) siblings .get(siblingPos - 1)); if (isFocusEligible(child)) { found = true; nextFocus = child; } else if (child.equals(nextFocus)) { if (isFocusEligible(nextFocus)) found = true; } else nextFocus = child; } else { nextFocus = parent; if (isFocusEligible(nextFocus)) found = true; } } return nextFocus; } /** * @return the figure that currently has focus */ public IFigure getCurrentFocusOwner() { return currentFocusOwner; } private boolean isFocusEligible(IFigure fig) { return (fig != null && fig.isFocusTraversable() && fig.isShowing()); } /** * Sets the currently focused figure. * * @param fig * the figure to get focus */ public void setCurrentFocusOwner(IFigure fig) { currentFocusOwner = fig; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/FrameBorder.java000066400000000000000000000051571166301720600265330ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; /** * Provides for a frame-like border which contains a title bar for holding the * title of a Figure. */ public class FrameBorder extends CompoundBorder implements LabeledBorder { /** * The border scheme that determines the border highlight and shadow colors, * as well as the border width (3). */ protected static final SchemeBorder.Scheme SCHEME_FRAME = new SchemeBorder.Scheme( new Color[] { ColorConstants.button, ColorConstants.buttonLightest, ColorConstants.button }, new Color[] { ColorConstants.buttonDarkest, ColorConstants.buttonDarker, ColorConstants.button }); { createBorders(); } /** * Constructs a FrameBorder with its label set to the name of the * {@link TitleBarBorder} class. * * @since 2.0 */ public FrameBorder() { } /** * Constructs a FrameBorder with the title set to the passed String. * * @param label * label or title of the frame. * @since 2.0 */ public FrameBorder(String label) { setLabel(label); } /** * Creates the necessary borders for this FrameBorder. The inner border is a * {@link TitleBarBorder}. The outer border is a {@link SchemeBorder}. * * @since 2.0 */ protected void createBorders() { inner = new TitleBarBorder(); outer = new SchemeBorder(SCHEME_FRAME); } /** * Returns the inner border of this FrameBorder, which contains the label * for the FrameBorder. * * @return the border holding the label. * @since 2.0 */ protected LabeledBorder getLabeledBorder() { return (LabeledBorder) inner; } /** * @return the label for this border */ public String getLabel() { return getLabeledBorder().getLabel(); } /** * Sets the label for this border. * * @param label * the label */ public void setLabel(String label) { getLabeledBorder().setLabel(label); } /** * Sets the font for this border's label. * * @param font * the font */ public void setFont(Font font) { getLabeledBorder().setFont(font); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/FreeformFigure.java000066400000000000000000000036031166301720600272440ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Rectangle; /** * A figure that allows its children to extend into negative coordinates. This * figure must be placed in a {@link org.eclipse.draw2d.FreeformViewport}. Also, * you shouldn't call {@link IFigure#setBounds(Rectangle)} on this figure. The * bounds will be calculated based on the extent of its children. A * FreeformFigure's bounds will be the smallest rectangle that will contain all * of its children. */ public interface FreeformFigure extends IFigure { /** * Adds a FreeformListener to this FreeformFigure. * * @param listener * the listener */ void addFreeformListener(FreeformListener listener); /** * Notifies listeners that the freeform extent (i.e. bounds) has changed. */ void fireExtentChanged(); /** * Returns the freeform extent, essentially the bounds of the * FreeformFigure. This is based on the extent of its children. * * @return the freeform extent */ Rectangle getFreeformExtent(); /** * Removes the given listener from this FreeformFigure. * * @param listener * the listener */ void removeFreeformListener(FreeformListener listener); /** * Sets the freeform bounds of this FreeformFigure. * * @param bounds * the new freeform bounds */ void setFreeformBounds(Rectangle bounds); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/FreeformHelper.java000066400000000000000000000056761166301720600272560ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.List; import org.eclipse.draw2d.geometry.Insets; import org.eclipse.draw2d.geometry.Rectangle; class FreeformHelper implements FreeformListener { class ChildTracker implements FigureListener { public void figureMoved(IFigure source) { invalidate(); } } private FreeformFigure host; private Rectangle freeformExtent; private FigureListener figureListener = new ChildTracker(); FreeformHelper(FreeformFigure host) { this.host = host; } public Rectangle getFreeformExtent() { if (freeformExtent != null) return freeformExtent; Rectangle r; List children = host.getChildren(); for (int i = 0; i < children.size(); i++) { IFigure child = (IFigure) children.get(i); if (child instanceof FreeformFigure) r = ((FreeformFigure) child).getFreeformExtent(); else r = child.getBounds(); if (freeformExtent == null) freeformExtent = r.getCopy(); else freeformExtent.union(r); } Insets insets = host.getInsets(); if (freeformExtent == null) freeformExtent = new Rectangle(0, 0, insets.getWidth(), insets.getHeight()); else { host.translateToParent(freeformExtent); freeformExtent.expand(insets); } // System.out.println("New extent calculated for " + host + " = " + // freeformExtent); return freeformExtent; } public void hookChild(IFigure child) { invalidate(); if (child instanceof FreeformFigure) ((FreeformFigure) child).addFreeformListener(this); else child.addFigureListener(figureListener); } void invalidate() { freeformExtent = null; host.fireExtentChanged(); if (host.getParent() != null) host.getParent().revalidate(); else host.revalidate(); } public void notifyFreeformExtentChanged() { // A childs freeform extent has changed, therefore this extent must be // recalculated invalidate(); } public void setFreeformBounds(Rectangle bounds) { host.setBounds(bounds); bounds = bounds.getCopy(); host.translateFromParent(bounds); List children = host.getChildren(); for (int i = 0; i < children.size(); i++) { IFigure child = (IFigure) children.get(i); if (child instanceof FreeformFigure) ((FreeformFigure) child).setFreeformBounds(bounds); } } public void unhookChild(IFigure child) { invalidate(); if (child instanceof FreeformFigure) ((FreeformFigure) child).removeFreeformListener(this); else child.removeFigureListener(figureListener); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/FreeformLayer.java000066400000000000000000000044061166301720600271010ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.Iterator; import org.eclipse.draw2d.geometry.Rectangle; /** * A Layer that can extend in all 4 directions. */ public class FreeformLayer extends Layer implements FreeformFigure { private FreeformHelper helper = new FreeformHelper(this); /** * @see IFigure#add(IFigure, Object, int) */ public void add(IFigure child, Object constraint, int index) { super.add(child, constraint, index); helper.hookChild(child); } /** * @see FreeformFigure#addFreeformListener(FreeformListener) */ public void addFreeformListener(FreeformListener listener) { addListener(FreeformListener.class, listener); } /** * @see FreeformFigure#fireExtentChanged() */ public void fireExtentChanged() { Iterator iter = getListeners(FreeformListener.class); while (iter.hasNext()) ((FreeformListener) iter.next()).notifyFreeformExtentChanged(); } /** * Overrides to do nothing. * * @see Figure#fireMoved() */ protected void fireMoved() { } /** * @see FreeformFigure#getFreeformExtent() */ public Rectangle getFreeformExtent() { return helper.getFreeformExtent(); } /** * @see Figure#primTranslate(int, int) */ public void primTranslate(int dx, int dy) { bounds.x += dx; bounds.y += dy; } /** * @see IFigure#remove(IFigure) */ public void remove(IFigure child) { helper.unhookChild(child); super.remove(child); } /** * @see FreeformFigure#removeFreeformListener(FreeformListener) */ public void removeFreeformListener(FreeformListener listener) { removeListener(FreeformListener.class, listener); } /** * @see FreeformFigure#setFreeformBounds(Rectangle) */ public void setFreeformBounds(Rectangle bounds) { helper.setFreeformBounds(bounds); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/FreeformLayeredPane.java000066400000000000000000000053021166301720600302120ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.Iterator; import org.eclipse.draw2d.geometry.Rectangle; /** * A LayeredPane that contains {@link org.eclipse.draw2d.FreeformLayer * FreeformLayers}. */ public class FreeformLayeredPane extends LayeredPane implements FreeformFigure { private FreeformHelper helper = new FreeformHelper(this); /** * Constructs a new FreeformLayeredPane. */ public FreeformLayeredPane() { setLayoutManager(null); } /** * @see IFigure#add(IFigure, Object, int) */ public void add(IFigure child, Object constraint, int index) { super.add(child, constraint, index); helper.hookChild(child); } /** * @see FreeformFigure#addFreeformListener(FreeformListener) */ public void addFreeformListener(FreeformListener listener) { addListener(FreeformListener.class, listener); } /** * @see FreeformFigure#fireExtentChanged() */ public void fireExtentChanged() { Iterator iter = getListeners(FreeformListener.class); while (iter.hasNext()) ((FreeformListener) iter.next()).notifyFreeformExtentChanged(); } /** * Overrides to do nothing. * * @see Figure#fireMoved() */ protected void fireMoved() { } /** * Returns the FreeformHelper. * * @return the FreeformHelper */ protected FreeformHelper getFreeformHelper() { return helper; } /** * @see FreeformFigure#getFreeformExtent() */ public Rectangle getFreeformExtent() { return helper.getFreeformExtent(); } /** * @see Figure#primTranslate(int, int) */ protected void primTranslate(int dx, int dy) { bounds.x += dx; bounds.y += dy; } /** * @see IFigure#remove(IFigure) */ public void remove(IFigure child) { helper.unhookChild(child); super.remove(child); } /** * @see FreeformFigure#removeFreeformListener(FreeformListener) */ public void removeFreeformListener(FreeformListener listener) { removeListener(FreeformListener.class, listener); } /** * @see FreeformFigure#setFreeformBounds(Rectangle) */ public void setFreeformBounds(Rectangle bounds) { helper.setFreeformBounds(bounds); } /** * Calls {@link Figure#fireMoved() super.fireMoved()}. */ protected void superFireMoved() { super.fireMoved(); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/FreeformLayout.java000066400000000000000000000053731166301720600273060ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.ListIterator; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; /** * A layout for {@link org.eclipse.draw2d.FreeformFigure FreeformFigures}. * Supports option to set only positive (x,y) coordinates for children figures. */ public class FreeformLayout extends XYLayout { /** * Option that forces only positive coordinates to children figures by * setting the layout origin appropriately */ private static final int FLAG__POSITIVE_COORDINATES = 1; /** * Option flags */ private int flags; /** * Layout origin point */ private Point origin = null; /** * Returns the point (0,0) as the origin. * * @see XYLayout#getOrigin(IFigure) */ public Point getOrigin(IFigure figure) { if (origin == null) { origin = new Point(); if (isPositiveCoordinates()) { ListIterator children = figure.getChildren().listIterator(); while (children.hasNext()) { IFigure f = (IFigure) children.next(); Rectangle constraint = (Rectangle) getConstraint(f); if (constraint != null) { origin.x = Math.min(origin.x, constraint.x); origin.y = Math.min(origin.y, constraint.y); } } origin.negate(); } } return origin; } /** * Checks whether the positive coordinates flag is on, e.g positive * coordinates for children are inforced by the layout * * @return boolean * @since 3.6 */ public boolean isPositiveCoordinates() { return (flags & FLAG__POSITIVE_COORDINATES) != 0; } /** * Sets/unsets the positive coordinates flag for true/false parameters * respectively. If option is set to on then layout calculates positive * coordinates for children figures by adjusting the layout origin * accordingly. * * @param positiveCoordinates * @since 3.6 */ public void setPositiveCoordinates(boolean positiveCoordinates) { if (positiveCoordinates != isPositiveCoordinates()) { if (positiveCoordinates) { flags |= FLAG__POSITIVE_COORDINATES; } else { flags &= ~FLAG__POSITIVE_COORDINATES; } invalidate(); } } /** * @see org.eclipse.draw2d.AbstractLayout#invalidate() */ public void invalidate() { origin = null; super.invalidate(); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/FreeformListener.java000066400000000000000000000015631166301720600276130ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; /** * Listens for extent changes in {@link org.eclipse.draw2d.FreeformFigure * FreeformFigures}. Created on :Oct 4, 2002 * * @author hudsonr * @since 2.0 */ public interface FreeformListener { /** * Called when the extent of the FreeformFigure has changed. */ void notifyFreeformExtentChanged(); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/FreeformViewport.java000066400000000000000000000054451166301720600276500ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Rectangle; /** * A viewport for {@link org.eclipse.draw2d.FreeformFigure FreeformFigures}. * FreeformFigures can only reside in this type of viewport. */ public class FreeformViewport extends Viewport { class FreeformViewportLayout extends ViewportLayout { protected Dimension calculatePreferredSize(IFigure parent, int wHint, int hHint) { getContents().validate(); wHint = Math.max(0, wHint); hHint = Math.max(0, hHint); return ((FreeformFigure) getContents()).getFreeformExtent() .getExpanded(getInsets()).union(0, 0) .union(wHint - 1, hHint - 1).getSize(); } protected boolean isSensitiveHorizontally(IFigure parent) { return true; } protected boolean isSensitiveVertically(IFigure parent) { return true; } public void layout(IFigure figure) { // Do nothing, contents updates itself. } } /** * Constructs a new FreeformViewport. This viewport must use graphics * translation to scroll the FreeformFigures inside of it. */ public FreeformViewport() { super(true); // Must use graphics translate to scroll freeforms. setLayoutManager(new FreeformViewportLayout()); } /** * Readjusts the scrollbars. In doing so, it gets the freeform extent of the * contents and unions this rectangle with this viewport's client area, then * sets the contents freeform bounds to be this unioned rectangle. Then * proceeds to set the scrollbar values based on this new information. * * @see Viewport#readjustScrollBars() */ protected void readjustScrollBars() { if (getContents() == null) return; if (!(getContents() instanceof FreeformFigure)) return; FreeformFigure ff = (FreeformFigure) getContents(); Rectangle clientArea = getClientArea(); Rectangle bounds = ff.getFreeformExtent().getCopy(); bounds.union(0, 0, clientArea.width, clientArea.height); ff.setFreeformBounds(bounds); getVerticalRangeModel().setAll(bounds.y, clientArea.height, bounds.bottom()); getHorizontalRangeModel().setAll(bounds.x, clientArea.width, bounds.right()); } /** * Returns true. * * @see Figure#useLocalCoordinates() */ protected boolean useLocalCoordinates() { return true; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/GhostImageFigure.java000066400000000000000000000062031166301720600275250ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Research Group Software Construction, * RWTH Aachen University, Germany - initial API and implementation */ package org.eclipse.draw2d; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Display; import org.eclipse.draw2d.geometry.PrecisionRectangle; import org.eclipse.draw2d.geometry.Rectangle; /** * A figure used to render a partly transparent copy of an original source * figure. * * This class is pretty much based on a sample, posted within the GEF newsgroup * (http://dev.eclipse.org/newslists/news.eclipse.tools.gef/msg15158.html), * although we decided to not cache the ghost image itself (but only its image * data), so the figure does not have to be disposed (and may thus directly * extend {@link Figure} rather than {@link ImageFigure}). * * @author Alexander Nyssen * @author Philip Ritzkopf * * @since 3.6 */ public class GhostImageFigure extends Figure { private int alpha = -1; private ImageData ghostImageData; /** * The single constructor. * * @param source * The original figure that will be used to render the ghost * image. * @param alpha * The desired transparency value, to be forwarded to * {@link Graphics#setAlpha(int)}. * @param transparency * The RBG value of the color that is to be regarded as * transparent. May be null. */ public GhostImageFigure(final IFigure source, int alpha, RGB transparency) { this.alpha = alpha; Rectangle sourceFigureRelativePrecisionBounds = new PrecisionRectangle( source.getBounds().getCopy()); Image offscreenImage = new Image(Display.getCurrent(), sourceFigureRelativePrecisionBounds.width, sourceFigureRelativePrecisionBounds.height); GC gc = new GC(offscreenImage); SWTGraphics swtGraphics = new SWTGraphics(gc); swtGraphics.translate(-sourceFigureRelativePrecisionBounds.x, -sourceFigureRelativePrecisionBounds.y); source.paint(swtGraphics); ghostImageData = offscreenImage.getImageData(); if (transparency != null) { ghostImageData.transparentPixel = ghostImageData.palette .getPixel(transparency); } offscreenImage.dispose(); swtGraphics.dispose(); gc.dispose(); } /** * @see Figure#paintFigure(Graphics) */ protected void paintFigure(Graphics graphics) { Image feedbackImage = new Image(Display.getCurrent(), ghostImageData); graphics.setAlpha(alpha); graphics.setClip(getBounds().getCopy()); graphics.drawImage(feedbackImage, 0, 0, ghostImageData.width, ghostImageData.height, getBounds().x, getBounds().y, getBounds().width, getBounds().height); feedbackImage.dispose(); } }eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/Graphics.java000066400000000000000000000750401166301720600261010ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontMetrics; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.LineAttributes; import org.eclipse.swt.graphics.Path; import org.eclipse.swt.graphics.Pattern; import org.eclipse.swt.graphics.TextLayout; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.PointList; import org.eclipse.draw2d.geometry.Rectangle; /** * The Graphics class allows you to draw to a surface. The drawXxx() methods * that pertain to shapes draw an outline of the shape, whereas the fillXxx() * methods fill in the shape. Also provides for drawing text, lines and images. * * @noextend This class is not intended to be subclassed by clients. */ public abstract class Graphics { /** * @see SWT#LINE_CUSTOM */ public static final int LINE_CUSTOM = SWT.LINE_CUSTOM; /** * @see SWT#LINE_DASH */ public static final int LINE_DASH = SWT.LINE_DASH; /** * @see SWT#LINE_DASHDOT */ public static final int LINE_DASHDOT = SWT.LINE_DASHDOT; /** * @see SWT#LINE_DASHDOTDOT */ public static final int LINE_DASHDOTDOT = SWT.LINE_DASHDOTDOT; /** * @see SWT#LINE_DOT */ public static final int LINE_DOT = SWT.LINE_DOT; /** * @see SWT#LINE_SOLID */ public static final int LINE_SOLID = SWT.LINE_SOLID; /** * Sets the clip region to the given rectangle. Anything outside this * rectangle will not be drawn. * * @param r * the clip rectangle */ public abstract void clipRect(Rectangle r); /** * Sets the clip region to the given rectangle. Anything outside this * rectangle will not be drawn. Takes into account current clipping area set * on the graphics. * * @param path * the clip path * * @since 3.6 */ public void clipPath(Path path) { throwNotImplemented(); } /** * Disposes this object, releasing any resources. */ public abstract void dispose(); /** * Draws the outline of an arc located at (x,y) with width w and * height h. The starting angle of the arc (specified in degrees) is * offset and length is the arc's angle (specified in * degrees). * * @param x * the x coordinate * @param y * the y coordinate * @param w * the width * @param h * the height * @param offset * the start angle * @param length * the length of the arc */ public abstract void drawArc(int x, int y, int w, int h, int offset, int length); /** * @see #drawArc(int, int, int, int, int, int) */ public final void drawArc(Rectangle r, int offset, int length) { drawArc(r.x, r.y, r.width, r.height, offset, length); } /** * Draws a focus rectangle. * * @param x * the x coordinate * @param y * the y coordinate * @param w * the width * @param h * the height */ public abstract void drawFocus(int x, int y, int w, int h); /** * @see #drawFocus(int, int, int, int) */ public final void drawFocus(Rectangle r) { drawFocus(r.x, r.y, r.width, r.height); } /** * Draws the given Image at the location (x,y). * * @param srcImage * the Image * @param x * the x coordinate * @param y * the y coordinate */ public abstract void drawImage(Image srcImage, int x, int y); /** * Draws a rectangular section of the given Image to the specified * rectangular reagion on the canvas. The section of the image bounded by * the rectangle (x1,y1,w1,h1) is copied to the section of the canvas * bounded by the rectangle (x2,y2,w2,h2). If these two sizes are different, * scaling will occur. * * @param srcImage * the image * @param x1 * the x coordinate of the source * @param y1 * the y coordinate of the source * @param w1 * the width of the source * @param h1 * the height of the source * @param x2 * the x coordinate of the destination * @param y2 * the y coordinate of the destination * @param w2 * the width of the destination * @param h2 * the height of the destination */ public abstract void drawImage(Image srcImage, int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2); /** * Draws the given image at a point. * * @param image * the image to draw * @param p * where to draw the image * @see #drawImage(Image, int, int) */ public final void drawImage(Image image, Point p) { drawImage(image, p.x, p.y); } /** * @see #drawImage(Image, int, int, int, int, int, int, int, int) */ public final void drawImage(Image srcImage, Rectangle src, Rectangle dest) { drawImage(srcImage, src.x, src.y, src.width, src.height, dest.x, dest.y, dest.width, dest.height); } /** * Draws a line between the points (x1,y1) and * (x2,y2) using the foreground color. * * @param x1 * the x coordinate for the first point * @param y1 * the y coordinate for the first point * @param x2 * the x coordinate for the second point * @param y2 * the y coordinate for the second point */ public abstract void drawLine(int x1, int y1, int x2, int y2); /** * @see #drawLine(int, int, int, int) */ public final void drawLine(Point p1, Point p2) { drawLine(p1.x, p1.y, p2.x, p2.y); } /** * Draws the outline of an ellipse that fits inside the rectangle with the * given properties using the foreground color. * * @param x * the x coordinate * @param y * the y coordinate * @param w * the width * @param h * the height */ public abstract void drawOval(int x, int y, int w, int h); /** * Draws an oval inside the given rectangle using the current foreground * color. * * @param r * the rectangle circumscribing the oval to be drawn * @see #drawOval(int, int, int, int) */ public final void drawOval(Rectangle r) { drawOval(r.x, r.y, r.width, r.height); } /** * Draws the given path. * * @param path * the path to draw * @since 3.1 */ public void drawPath(Path path) { throwNotImplemented(); } /** * Draws a pixel, using the foreground color, at the specified point ( * x, y). *

* Note that the current line attributes do not affect this operation. *

* * @param x * the point's x coordinate * @param y * the point's y coordinate * */ public void drawPoint(int x, int y) { drawLine(x, y, x, y); } /** * Draws a closed polygon defined by the given Integer array containing the * vertices in x,y order. The first and last points in the list will be * connected. * * @param points * the vertices */ public void drawPolygon(int[] points) { drawPolygon(getPointList(points)); } /** * Draws a closed polygon defined by the given PointList * containing the vertices. The first and last points in the list will be * connected. * * @param points * the vertices */ public abstract void drawPolygon(PointList points); /** * Draws a polyline defined by the given Integer array containing the * vertices in x,y order. The first and last points in the list will * not be connected. * * @param points * the vertices */ public void drawPolyline(int[] points) { drawPolyline(getPointList(points)); } /** * Draws a polyline defined by the given PointList containing * the vertices. The first and last points in the list will not be * connected. * * @param points * the vertices */ public abstract void drawPolyline(PointList points); /** * Draws a rectangle whose top-left corner is located at the point (x,y) * with the given width and height. * * @param x * the x coordinate * @param y * the y coordinate * @param width * the width * @param height * the height */ public abstract void drawRectangle(int x, int y, int width, int height); /** * Draws the given rectangle using the current foreground color. * * @param r * the rectangle to draw * @see #drawRectangle(int, int, int, int) */ public final void drawRectangle(Rectangle r) { drawRectangle(r.x, r.y, r.width, r.height); } /** * Draws a rectangle with rounded corners using the foreground color. * arcWidth and arcHeight represent the horizontal and * vertical diameter of the corners. * * @param r * the rectangle * @param arcWidth * the arc width * @param arcHeight * the arc height */ public abstract void drawRoundRectangle(Rectangle r, int arcWidth, int arcHeight); /** * Draws the given string using the current font and foreground color. No * tab expansion or carriage return processing will be performed. The * background of the string will be transparent. * * @param s * the string * @param x * the x coordinate * @param y * the y coordinate */ public abstract void drawString(String s, int x, int y); /** * @see #drawString(String, int, int) */ public final void drawString(String s, Point p) { drawString(s, p.x, p.y); } /** * Draws the given string using the current font and foreground color. Tab * expansion and carriage return processing are performed. The background of * the text will be transparent. * * @param s * the text * @param x * the x coordinate * @param y * the y coordinate */ public abstract void drawText(String s, int x, int y); /** * Draws a string using the specified styles. The styles are defined by * {@link GC#drawText(String, int, int, int)}. * * @param s * the String to draw * @param x * the x location * @param y * the y location * @param style * the styles used to render the string * @since 3.0 */ public void drawText(String s, int x, int y, int style) { throwNotImplemented(); } /** * @see #drawText(String, int, int) */ public final void drawText(String s, Point p) { drawText(s, p.x, p.y); } /** * Draws a string using the specified styles. The styles are defined by * {@link GC#drawText(String, int, int, int)}. * * @param s * the String to draw * @param p * the point at which to draw the string * @param style * the styles used to render the string * @since 3.0 */ public final void drawText(String s, Point p, int style) { drawText(s, p.x, p.y, style); } /** * Renders the specified TextLayout to this Graphics. * * @since 3.0 * @param layout * the TextLayout * @param x * the x coordinate * @param y * the y coordinate */ public final void drawTextLayout(TextLayout layout, int x, int y) { drawTextLayout(layout, x, y, -1, -1, null, null); } /** * @param x * the x location * @param y * the y location * @param layout * the TextLayout being rendered * @param selectionStart * the start of selection * @param selectionEnd * the end of selection * @param selectionForeground * the foreground selection color * @param selectionBackground * the background selection color * @see Graphics#drawTextLayout(TextLayout, int, int) */ public void drawTextLayout(TextLayout layout, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground) { throwNotImplemented(); } /** * Fills the interior of an arc located at (x,y) with width * w and height h. The starting angle of the arc (specified in * degrees) is offset and length is the arc's angle (specified * in degrees). * * @param x * the x coordinate * @param y * the y coordinate * @param w * the width * @param h * the height * @param offset * the start angle * @param length * the length of the arc */ public abstract void fillArc(int x, int y, int w, int h, int offset, int length); /** * @see #fillArc(int, int, int, int, int, int) */ public final void fillArc(Rectangle r, int offset, int length) { fillArc(r.x, r.y, r.width, r.height, offset, length); } /** * Fills the the given rectangle with a gradient from the foreground color * to the background color. If vertical is true, the * gradient will go from top to bottom. Otherwise, it will go from left to * right. background color. * * @param x * the x coordinate * @param y * the y coordinate * @param w * the width * @param h * the height * @param vertical * whether the gradient should be vertical */ public abstract void fillGradient(int x, int y, int w, int h, boolean vertical); /** * @see #fillGradient(int, int, int, int, boolean) */ public final void fillGradient(Rectangle r, boolean vertical) { fillGradient(r.x, r.y, r.width, r.height, vertical); } /** * Fills an ellipse that fits inside the rectangle with the given properties * using the background color. * * @param x * the x coordinate * @param y * the y coordinate * @param w * the width * @param h * the height */ public abstract void fillOval(int x, int y, int w, int h); /** * @see #fillOval(int, int, int, int) */ public final void fillOval(Rectangle r) { fillOval(r.x, r.y, r.width, r.height); } /** * Fills the given path. * * @param path * the path to fill * @since 3.1 */ public void fillPath(Path path) { throwNotImplemented(); } /** * Fills a closed polygon defined by the given Integer array containing the * vertices in x,y order. The first and last points in the list will be * connected. * * @param points * the vertices */ public void fillPolygon(int[] points) { fillPolygon(getPointList(points)); } /** * Fills a closed polygon defined by the given PointList * containing the vertices. The first and last points in the list will be * connected. * * @param points * the vertices */ public abstract void fillPolygon(PointList points); /** * Fills a rectangle whose top-left corner is located at the point (x,y) * with the given width and height. * * @param x * the x coordinate * @param y * the y coordinate * @param width * the width * @param height * the height */ public abstract void fillRectangle(int x, int y, int width, int height); /** * Fills the given rectangle using the current background color. * * @param r * the rectangle to fill * @see #fillRectangle(int, int, int, int) */ public final void fillRectangle(Rectangle r) { fillRectangle(r.x, r.y, r.width, r.height); } /** * Fills a rectangle with rounded corners using the background color. * arcWidth and arcHeight represent the horizontal and * vertical diameter of the corners. * * @param r * the rectangle * @param arcWidth * the arc width * @param arcHeight * the arc height */ public abstract void fillRoundRectangle(Rectangle r, int arcWidth, int arcHeight); /** * Draws the given string using the current font and foreground color. No * tab expansion or carriage return processing will be performed. The * background of the string will be filled with the current background * color. * * @param s * the string * @param x * the x coordinate * @param y * the y coordinate */ public abstract void fillString(String s, int x, int y); /** * @see #fillString(String, int, int) */ public final void fillString(String s, Point p) { fillString(s, p.x, p.y); } /** * Draws the given string using the current font and foreground color. Tab * expansion and carriage return processing are performed. The background of * the text will be filled with the current background color. * * @param s * the text * @param x * the x coordinate * @param y * the y coordinate */ public abstract void fillText(String s, int x, int y); /** * @see #fillText(String, int, int) */ public final void fillText(String s, Point p) { fillText(s, p.x, p.y); } /** * Returns the current absolute scaling which will be applied to the * underlying Device when painting to this Graphics. The default value is * 1.0. * * @since 3.0 * @return the effective absolute scaling factor */ public double getAbsoluteScale() { return 1.0; } /** * @return true if the underlying graphics device is using advanced graphics * mode. * @since 3.5 */ public boolean getAdvanced() { throwNotImplemented(); return false; } /** * Returns the current alpha value of the graphics. * * @return the alpha value * @since 3.1 */ public int getAlpha() { throwNotImplemented(); return 255; } /** * Returns the anti-aliasing setting value, which will be one of * SWT.DEFAULT, SWT.OFF or SWT.ON. * Note that this controls anti-aliasing for all non-text drawing * operations. * * @see #getTextAntialias() * @return the anti-alias setting * @since 3.1 */ public int getAntialias() { throwNotImplemented(); return SWT.DEFAULT; } /** * Returns the background color used for filling. * * @return the background color */ public abstract Color getBackgroundColor(); /** * Modifies the given rectangle to match the clip region and returns that * rectangle. * * @param rect * the rectangle to hold the clip region * @return the clip rectangle */ public abstract Rectangle getClip(Rectangle rect); /** * Returns the fill rule, which will be one of * SWT.FILL_EVEN_ODD or SWT.FILL_WINDING. * * @return the fill rule * @since 3.1 */ public int getFillRule() { throwNotImplemented(); return 0; } /** * Returns the font used to draw and fill text. * * @return the font */ public abstract Font getFont(); /** * Returns the font metrics for the current font. * * @return the font metrics */ public abstract FontMetrics getFontMetrics(); /** * Returns the foreground color used to draw lines and text. * * @return the foreground color */ public abstract Color getForegroundColor(); /** * Returns the interpolation setting. * * @see org.eclipse.swt.graphics.GC#getInterpolation() * @return the interpolation setting * @since 3.1 */ public int getInterpolation() { throwNotImplemented(); return 0; } /** * Returns the current collection of line attributes. * * @see org.eclipse.swt.graphics.LineAttributes * @return all attributes used for line drawing * @since 3.5 */ public LineAttributes getLineAttributes() { throwNotImplemented(); return null; } /** * Returns the current line cap style. * * @see org.eclipse.swt.graphics.LineAttributes#cap * @return the cap style used for drawing lines * @since 3.1 */ public int getLineCap() { throwNotImplemented(); return SWT.CAP_FLAT; } /** * Returns the line join style. * * @see org.eclipse.swt.graphics.LineAttributes#join * @since 3.1 * @return the join style used for drawing lines */ public int getLineJoin() { throwNotImplemented(); return SWT.JOIN_MITER; } /** * Returns the line miter limit. * * @see org.eclipse.swt.graphics.LineAttributes#miterLimit * @return miter limit * @since 3.5 */ public float getLineMiterLimit() { throwNotImplemented(); return 0; } /** * Returns the line style. * * @see org.eclipse.swt.graphics.LineAttributes#style * @return the line style */ public abstract int getLineStyle(); /** * Returns the current line width. * * @return the line width */ public abstract int getLineWidth(); /** * Returns the current line width. * * @see org.eclipse.swt.graphics.LineAttributes#width * @return the line width * @since 3.5 */ public abstract float getLineWidthFloat(); /** * Returns a pointlist containing all the points from the integer array. * * @param points * an integer array of x,y points * @return the corresponding pointlist */ private PointList getPointList(int[] points) { PointList pointList = new PointList(points.length / 2); for (int i = 0; (i + 1) < points.length; i += 2) pointList.addPoint(points[i], points[i + 1]); return pointList; } /** * Returns the textual anti-aliasing setting value, which will be one of * SWT.DEFAULT, SWT.OFF or SWT.ON. * Note that this controls anti-aliasing only for text drawing * operations. * * @see #getAntialias() * @return the anti-aliasing setting * @since 3.1 */ public int getTextAntialias() { throwNotImplemented(); return SWT.DEFAULT; } /** * Returns true if this graphics object should use XOR mode * with painting. * * @return whether XOR mode is turned on */ public abstract boolean getXORMode(); /** * Pops the previous state of this graphics object off the stack (if * {@link #pushState()} has previously been called) and restores the current * state to that popped state. */ public abstract void popState(); /** * Pushes the current state of this graphics object onto a stack. */ public abstract void pushState(); /** * Restores the previous state of this graphics object. */ public abstract void restoreState(); /** * Rotates the coordinates by the given counter-clockwise angle. All * subsequent painting will be performed in the resulting coordinates. Some * functions are illegal when a rotated coordinates system is in use. To * restore access to those functions, it is necessary to call restore or pop * to return to a non rotated state. * * @param degrees * the degrees to rotate * @since 3.1 */ public void rotate(float degrees) { throwNotImplemented(); } /** * Scales this graphics object by the given amount. * * @param amount * the scale factor */ public abstract void scale(double amount); /** * Scales the graphics by the given horizontal and vertical components. * * @param horizontal * the horizontal scaling factor * @param vertical * the vertical scaling factor * @since 3.1 */ public void scale(float horizontal, float vertical) { throwNotImplemented(); } /** * Sets the alpha to the given value. Values may range from 0 to 255. A * value of 0 is completely transparent. * * @param alpha * an alpha value (0-255) * @since 3.1 */ public void setAlpha(int alpha) { throwNotImplemented(); } /** * Turns advanced graphics mode on or off. * * @param advanced * @since 3.5 */ public void setAdvanced(boolean advanced) { throwNotImplemented(); } /** * Sets the anti-aliasing value to the parameter, which must be one of * SWT.DEFAULT, SWT.OFF or SWT.ON. * Note that this controls anti-aliasing for all non-text drawing * operations. * * @param value * the anti-alias value */ public void setAntialias(int value) { throwNotImplemented(); } /** * Sets the background color. * * @param rgb * the new background color */ public abstract void setBackgroundColor(Color rgb); /** * Sets the pattern used for fill-type graphics operations. The pattern must * not be disposed while it is being used by the graphics. * * @param pattern * the background pattern * @since 3.1 */ public void setBackgroundPattern(Pattern pattern) { throwNotImplemented(); } /** * Sets the area which can be affected by drawing operations to the * specified Path. * * @param path * the clipping path * @since 3.1 */ public void setClip(Path path) { throwNotImplemented(); } /** * Sets the clip rectangle. Painting will not occur outside this * area. * * @param r * the new clip rectangle */ public abstract void setClip(Rectangle r); /** * Sets the fill rule to the given value, which must be one of * SWT.FILL_EVEN_ODD or SWT.FILL_WINDING. * * @param rule * the fill rule * @since 3.1 */ public void setFillRule(int rule) { throwNotImplemented(); } /** * Sets the font. * * @param f * the new font */ public abstract void setFont(Font f); /** * Sets the foreground color. * * @param rgb * the new foreground color */ public abstract void setForegroundColor(Color rgb); /** * Sets the foreground pattern for draw and text operations. The pattern * must not be disposed while it is being referenced by the graphics. * * @param pattern * the foreground pattern * @since 3.1 */ public void setForegroundPattern(Pattern pattern) { throwNotImplemented(); } /** * Sets the interpolation setting to the given value, which must be one of * SWT.DEFAULT, SWT.NONE, SWT.LOW or * SWT.HIGH. This setting is relevant when working with Images. * * @param interpolation * the interpolation * @since 3.1 */ public void setInterpolation(int interpolation) { throwNotImplemented(); } /** * Sets all line attributes together * * @param attributes * the line attributes * @since 3.5 */ public void setLineAttributes(LineAttributes attributes) { throwNotImplemented(); } /** * Sets the line cap style to the argument, which must be one of the * constants SWT.CAP_FLAT, SWT.CAP_ROUND, or * SWT.CAP_SQUARE. * * @param cap * the line cap * @since 3.1 */ public void setLineCap(int cap) { throwNotImplemented(); } /** * Sets the dash pattern when the custom line style is in use. Because this * feature is rarely used, the dash pattern may not be preserved when * calling {@link #pushState()} and {@link #popState()}. * * @param dash * the pixel pattern * @since 3.1 */ public void setLineDash(int dash[]) { throwNotImplemented(); } /** * Sets the dash pattern when the custom line style is in use. * * @param value * the pixel pattern. * @since 3.5 */ public void setLineDash(float[] value) { throwNotImplemented(); } /** * Sets the line join style to the argument, which must be one of the * constants SWT.JOIN_MITER, SWT.JOIN_ROUND, or * SWT.JOIN_BEVEL. * * @param join * the join type * @since 3.1 */ public void setLineJoin(int join) { throwNotImplemented(); } /** * Sets the line style to the argument, which must be one of the constants * SWT.LINE_SOLID, SWT.LINE_DASH, * SWT.LINE_DOT, SWT.LINE_DASHDOT or * SWT.LINE_DASHDOTDOT. * * @param style * the new style */ public abstract void setLineStyle(int style); /** * Sets the line width. * * @param width * the new width */ public abstract void setLineWidth(int width); /** * Sets the line width. * * @param width * the new width * @since 3.5 */ public abstract void setLineWidthFloat(float width); /** * @param miterLimit * @since 3.5 */ public abstract void setLineMiterLimit(float miterLimit); /** * Sets the textual anti-aliasing value to the parameter, which must be one * of SWT.DEFAULT, SWT.OFF or SWT.ON. * Note that this controls anti-aliasing only for all text drawing * operations. * * @param value * the textual anti-alias setting * @since 3.1 */ public void setTextAntialias(int value) { throwNotImplemented(); } /** * Modifies the current transformation by shearing the graphics in the * specified horizontal and vertical amounts. Shearing can be used to * produce effects like Italic fonts. * * @param horz * the horizontal shearing amount * @param vert * the vertical shearing amount * @since 3.1 */ public void shear(float horz, float vert) { throwNotImplemented(); } /** * Sets the XOR mode. * * @param b * the new XOR mode */ public abstract void setXORMode(boolean b); /** * Throws a runtime exception to indicate a subclass has chosen not to * implement the method. * * @since 3.2 */ private void throwNotImplemented() { throw new RuntimeException("The class: " + getClass() //$NON-NLS-1$ + " has not implemented this new graphics function"); //$NON-NLS-1$ } /** * Translates the receiver's coordinates by the specified x and y amounts. * All subsequent painting will be performed in the resulting coordinate * system. Integer translation used by itself does not require or start the * use of the advanced graphics system in SWT. It is emulated until advanced * graphics are triggered. * * @param dx * the horizontal offset * @param dy * the vertical offset */ public abstract void translate(int dx, int dy); /** * Modifies the current transform by translating the given x and y amounts. * All subsequent painting will be performed in the resulting coordinate * system. * * @param dx * the horizontal offset * @param dy * the vertical offset */ public void translate(float dx, float dy) { throwNotImplemented(); } /** * @see #translate(int, int) */ public final void translate(Point pt) { translate(pt.x, pt.y); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/GraphicsSource.java000066400000000000000000000023011166301720600272500ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Rectangle; /** * Provides a {@link org.eclipse.draw2d.Graphics} object for painting. */ public interface GraphicsSource { /** * Returns a Graphics for the rectangular region requested. May return * null. * * @param region * The rectangular region * @return A new Graphics object for the given region */ Graphics getGraphics(Rectangle region); /** * Tells the GraphicsSource that you have finished using that region. * * @param region * The rectangular region that that no longer needs the Graphics */ void flushGraphics(Rectangle region); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/GridData.java000066400000000000000000000402561166301720600260210ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation * Asim Ullah - Ported for use in draw2d (c.f Bugzilla 71684).[Sep 10, 2004] *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.SWT; import org.eclipse.draw2d.geometry.Dimension; /** * GridData is the layout data object associated with * GridLayout. To set a GridData object into a * Figure, you use the setConstraint() method of * GridLayout to map the Figure to its layout * GridData. *

* There are two ways to create a GridData object with certain * fields set. The first is to set the fields directly, like this: * *

 * GridData gridData = new GridData();
 * gridData.horizontalAlignment = GridData.FILL;
 * gridData.grabExcessHorizontalSpace = true;
 * 
 * // associate the figure to the GridData object
 * myGridlayout.setConstraint(myFigure, gridData);
 * 
* * The second is to take advantage of convenience style bits defined by * GridData: * *
 * GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL
 * 		| GridData.GRAB_HORIZONTAL);
 * 
* *

*

* NOTE: Do not reuse GridData objects. Every child in the parent * Figure that is managed by the GridLayout must have * a unique GridData object. If the layout data for a Grid member * in a GridLayout is null at layout time, a unique * GridData object is created for it. *

* * @see GridLayout */ public final class GridData { /** * verticalAlignment specifies how figures will be positioned vertically * within a cell. * * The default value is CENTER. * * Possible values are: * * SWT.BEGINNING (or SWT.TOP): Position the figure at the top of the cell * SWT.CENTER: Position the figure in the vertical center of the cell * SWT.END (or SWT.BOTTOM): Position the figure at the bottom of the cell * SWT.FILL: Resize the figure to fill the cell vertically */ public int verticalAlignment = CENTER; /** * horizontalAlignment specifies how figures will be positioned horizontally * within a cell. * * The default value is BEGINNING. * * Possible values are: * * SWT.BEGINNING (or SWT.LEFT): Position the figure at the left of the cell * SWT.CENTER: Position the figure in the horizontal center of the cell * SWT.END (or SWT.RIGHT): Position the figure at the right of the cell * SWT.FILL: Resize the figure to fill the cell horizontally */ public int horizontalAlignment = BEGINNING; /** * widthHint specifies a minimum width for the column. A value of * SWT.DEFAULT indicates that no minimum width is specified. * * The default value is SWT.DEFAULT. */ public int widthHint = SWT.DEFAULT; /** * heightHint specifies a minimum height for the row. A value of SWT.DEFAULT * indicates that no minimum height is specified. * * The default value is SWT.DEFAULT. */ public int heightHint = SWT.DEFAULT; /** * horizontalIndent specifies the number of pixels of indentation that will * be placed along the left side of the cell. * * The default value is 0. */ public int horizontalIndent = 0; /** * horizontalSpan specifies the number of column cells that the figure will * take up. * * The default value is 1. */ public int horizontalSpan = 1; /** * verticalSpan specifies the number of row cells that the figure will take * up. * * The default value is 1. */ public int verticalSpan = 1; /** * grabExcessHorizontalSpace specifies whether the cell will be made wide * enough to fit the remaining horizontal space. * * The default value is false. */ public boolean grabExcessHorizontalSpace = false; /** * grabExcessVerticalSpace specifies whether the cell will be made tall * enough to fit the remaining vertical space. * * The default value is false. */ public boolean grabExcessVerticalSpace = false; /** * Value for horizontalAlignment or verticalAlignment. Position the figure * at the top or left of the cell. Not recommended. Use SWT.BEGINNING, * SWT.TOP or SWT.LEFT instead. */ public static final int BEGINNING = SWT.BEGINNING; /** * Value for horizontalAlignment or verticalAlignment. Position the figure * in the vertical or horizontal center of the cell Not recommended. Use * SWT.CENTER instead. */ public static final int CENTER = 2; /** * Value for horizontalAlignment or verticalAlignment. Position the figure * at the bottom or right of the cell Not recommended. Use SWT.END, * SWT.BOTTOM or SWT.RIGHT instead. */ public static final int END = 3; /** * Value for horizontalAlignment or verticalAlignment. Resize the figure to * fill the cell horizontally or vertically. Not recommended. Use SWT.FILL * instead. */ public static final int FILL = SWT.FILL; /** * Style bit for new GridData(int). Position the figure at the * top of the cell. Not recommended. Use * new GridData(int, SWT.BEGINNING, boolean, boolean) instead. */ public static final int VERTICAL_ALIGN_BEGINNING = 1 << 1; /** * Style bit for new GridData(int) to position the figure in * the vertical center of the cell. Not recommended. Use * new GridData(int, SWT.CENTER, boolean, boolean) instead. */ public static final int VERTICAL_ALIGN_CENTER = 1 << 2; /** * Style bit for new GridData(int) to position the figure at * the bottom of the cell. Not recommended. Use * new GridData(int, SWT.END, boolean, boolean) instead. */ public static final int VERTICAL_ALIGN_END = 1 << 3; /** * Style bit for new GridData(int) to resize the figure to fill * the cell vertically. Not recommended. Use * new GridData(int, SWT.FILL, boolean, boolean) instead */ public static final int VERTICAL_ALIGN_FILL = 1 << 4; /** * Style bit for new GridData(int) to position the figure at * the left of the cell. Not recommended. Use * new GridData(SWT.BEGINNING, int, boolean, boolean) instead. */ public static final int HORIZONTAL_ALIGN_BEGINNING = 1 << 5; /** * Style bit for new GridData(int) to position the figure in * the horizontal center of the cell. Not recommended. Use * new GridData(SWT.CENTER, int, boolean, boolean) instead. */ public static final int HORIZONTAL_ALIGN_CENTER = 1 << 6; /** * Style bit for new GridData(int) to position the figure at * the right of the cell. Not recommended. Use * new GridData(SWT.END, int, boolean, boolean) instead. */ public static final int HORIZONTAL_ALIGN_END = 1 << 7; /** * Style bit for new GridData(int) to resize the figure to fill * the cell horizontally. Not recommended. Use * new GridData(SWT.FILL, int, boolean, boolean) instead. */ public static final int HORIZONTAL_ALIGN_FILL = 1 << 8; /** * Style bit for new GridData(int) to resize the figure to fit * the remaining horizontal space. Not recommended. Use * new GridData(int, int, true, boolean) instead. */ public static final int GRAB_HORIZONTAL = 1 << 9; /** * Style bit for new GridData(int) to resize the figure to fit * the remaining vertical space. Not recommended. Use * new GridData(int, int, boolean, true) instead. */ public static final int GRAB_VERTICAL = 1 << 10; /** * Style bit for new GridData(int) to resize the figure to fill * the cell vertically and to fit the remaining vertical space. * FILL_VERTICAL = VERTICAL_ALIGN_FILL | GRAB_VERTICAL Not recommended. Use * new GridData(int, SWT.FILL, boolean, true) instead. */ public static final int FILL_VERTICAL = VERTICAL_ALIGN_FILL | GRAB_VERTICAL; /** * Style bit for new GridData(int) to resize the figure to fill * the cell horizontally and to fit the remaining horizontal space. * FILL_HORIZONTAL = HORIZONTAL_ALIGN_FILL | GRAB_HORIZONTAL Not * recommended. Use new GridData(SWT.FILL, int, true, boolean) * instead. */ public static final int FILL_HORIZONTAL = HORIZONTAL_ALIGN_FILL | GRAB_HORIZONTAL; /** * Style bit for new GridData(int) to resize the figure to fill * the cell horizontally and vertically and to fit the remaining horizontal * and vertical space. FILL_BOTH = FILL_VERTICAL | FILL_HORIZONTAL Not * recommended. Use * new GridData(SWT.FILL, SWT.FILL, true, true) instead. */ public static final int FILL_BOTH = FILL_VERTICAL | FILL_HORIZONTAL; int cacheWidth = -1, cacheHeight = -1; int[][] cache = new int[2][4]; int cacheIndex = -1; /** * Constructs a new instance of GridData using default values. */ public GridData() { super(); } /** * Constructs a new instance based on the GridData style. This constructor * is not recommended. * * @param style * the GridData style */ public GridData(int style) { super(); if ((style & VERTICAL_ALIGN_BEGINNING) != 0) verticalAlignment = BEGINNING; if ((style & VERTICAL_ALIGN_CENTER) != 0) verticalAlignment = CENTER; if ((style & VERTICAL_ALIGN_FILL) != 0) verticalAlignment = FILL; if ((style & VERTICAL_ALIGN_END) != 0) verticalAlignment = END; if ((style & HORIZONTAL_ALIGN_BEGINNING) != 0) horizontalAlignment = BEGINNING; if ((style & HORIZONTAL_ALIGN_CENTER) != 0) horizontalAlignment = CENTER; if ((style & HORIZONTAL_ALIGN_FILL) != 0) horizontalAlignment = FILL; if ((style & HORIZONTAL_ALIGN_END) != 0) horizontalAlignment = END; grabExcessHorizontalSpace = (style & GRAB_HORIZONTAL) != 0; grabExcessVerticalSpace = (style & GRAB_VERTICAL) != 0; } /** * Constructs a new instance of GridData according to the parameters. * * @param horizontalAlignment * how figure will be positioned horizontally within a cell * @param verticalAlignment * how figure will be positioned vertically within a cell * @param grabExcessHorizontalSpace * whether cell will be made wide enough to fit the remaining * horizontal space * @param grabExcessVerticalSpace * whether cell will be made high enough to fit the remaining * vertical space * */ public GridData(int horizontalAlignment, int verticalAlignment, boolean grabExcessHorizontalSpace, boolean grabExcessVerticalSpace) { this(horizontalAlignment, verticalAlignment, grabExcessHorizontalSpace, grabExcessVerticalSpace, 1, 1); } /** * Constructs a new instance of GridData according to the parameters. * * @param horizontalAlignment * how figure will be positioned horizontally within a cell * @param verticalAlignment * how figure will be positioned vertically within a cell * @param grabExcessHorizontalSpace * whether cell will be made wide enough to fit the remaining * horizontal space * @param grabExcessVerticalSpace * whether cell will be made high enough to fit the remaining * vertical space * @param horizontalSpan * the number of column cells that the figure will take up * @param verticalSpan * the number of row cells that the figure will take up * */ public GridData(int horizontalAlignment, int verticalAlignment, boolean grabExcessHorizontalSpace, boolean grabExcessVerticalSpace, int horizontalSpan, int verticalSpan) { super(); this.horizontalAlignment = horizontalAlignment; this.verticalAlignment = verticalAlignment; this.grabExcessHorizontalSpace = grabExcessHorizontalSpace; this.grabExcessVerticalSpace = grabExcessVerticalSpace; this.horizontalSpan = horizontalSpan; this.verticalSpan = verticalSpan; } /** * Constructs a new instance of GridData according to the parameters. A * value of SWT.DEFAULT indicates that no minimum width or no minumum height * is specified. * * @param width * a minimum width for the column * @param height * a minimum height for the row * */ public GridData(int width, int height) { super(); this.widthHint = width; this.heightHint = height; } Dimension computeSize(IFigure figure, boolean flushCache) { if (cacheWidth != -1 && cacheHeight != -1) { return new Dimension(cacheWidth, cacheHeight); } for (int i = 0; i < cacheIndex + 1; i++) { if (cache[i][0] == widthHint && cache[i][1] == heightHint) { cacheWidth = cache[i][2]; cacheHeight = cache[i][3]; return new Dimension(cacheWidth, cacheHeight); } } Dimension size = figure.getPreferredSize(widthHint, heightHint) .getCopy(); if (widthHint != -1) size.width = widthHint; if (heightHint != -1) size.height = heightHint; if (cacheIndex < cache.length - 1) cacheIndex++; cache[cacheIndex][0] = widthHint; cache[cacheIndex][1] = heightHint; cacheWidth = cache[cacheIndex][2] = size.width; cacheHeight = cache[cacheIndex][3] = size.height; return size; } void flushCache() { cacheWidth = cacheHeight = -1; cacheIndex = -1; } String getName() { String string = getClass().getName(); int index = string.lastIndexOf('.'); if (index == -1) return string; return string.substring(index + 1, string.length()); } public String toString() { String hAlign = ""; //$NON-NLS-1$ switch (horizontalAlignment) { case SWT.FILL: hAlign = "SWT.FILL"; //$NON-NLS-1$ break; case SWT.BEGINNING: hAlign = "SWT.BEGINNING"; //$NON-NLS-1$ break; case SWT.LEFT: hAlign = "SWT.LEFT"; //$NON-NLS-1$ break; case SWT.END: hAlign = "SWT.END"; //$NON-NLS-1$ break; case END: hAlign = "GridData.END"; //$NON-NLS-1$ break; case SWT.RIGHT: hAlign = "SWT.RIGHT"; //$NON-NLS-1$ break; case SWT.CENTER: hAlign = "SWT.CENTER"; //$NON-NLS-1$ break; case CENTER: hAlign = "GridData.CENTER"; //$NON-NLS-1$ break; default: hAlign = "Undefined " + horizontalAlignment; //$NON-NLS-1$ break; } String vAlign = ""; //$NON-NLS-1$ switch (verticalAlignment) { case SWT.FILL: vAlign = "SWT.FILL"; //$NON-NLS-1$ break; case SWT.BEGINNING: vAlign = "SWT.BEGINNING"; //$NON-NLS-1$ break; case SWT.TOP: vAlign = "SWT.TOP"; //$NON-NLS-1$ break; case SWT.END: vAlign = "SWT.END"; //$NON-NLS-1$ break; case END: vAlign = "GridData.END"; //$NON-NLS-1$ break; case SWT.BOTTOM: vAlign = "SWT.BOTTOM"; //$NON-NLS-1$ break; case SWT.CENTER: vAlign = "SWT.CENTER"; //$NON-NLS-1$ break; case CENTER: vAlign = "GridData.CENTER"; //$NON-NLS-1$ break; default: vAlign = "Undefined " + verticalAlignment; //$NON-NLS-1$ break; } String string = getName() + " {"; //$NON-NLS-1$ string += "horizontalAlignment=" + hAlign + " "; //$NON-NLS-1$ //$NON-NLS-2$ if (horizontalIndent != 0) string += "horizontalIndent=" + horizontalIndent + " "; //$NON-NLS-1$ //$NON-NLS-2$ if (horizontalSpan != 1) string += "horizontalSpan=" + horizontalSpan + " "; //$NON-NLS-1$//$NON-NLS-2$ if (grabExcessHorizontalSpace) string += "grabExcessHorizontalSpace=" + grabExcessHorizontalSpace //$NON-NLS-1$ + " "; //$NON-NLS-1$ if (widthHint != SWT.DEFAULT) string += "widthHint=" + widthHint + " "; //$NON-NLS-1$ //$NON-NLS-2$ string += "verticalAlignment=" + vAlign + " "; //$NON-NLS-1$ //$NON-NLS-2$ if (verticalSpan != 1) string += "verticalSpan=" + verticalSpan + " "; //$NON-NLS-1$ //$NON-NLS-2$ if (grabExcessVerticalSpace) string += "grabExcessVerticalSpace=" + grabExcessVerticalSpace //$NON-NLS-1$ + " "; //$NON-NLS-1$ if (heightHint != SWT.DEFAULT) string += "heightHint=" + heightHint + " "; //$NON-NLS-1$ //$NON-NLS-2$ string = string.trim(); string += "}"; //$NON-NLS-1$ return string; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/GridLayout.java000066400000000000000000000571321166301720600264260ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation * Asim Ullah - Ported for use in draw2d (c.f Bugzilla 71684). [Sep 10, 2004] *******************************************************************************/ package org.eclipse.draw2d; import java.util.HashMap; import java.util.List; import java.util.Map; import org.eclipse.swt.SWT; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Rectangle; /** * Lays out children into a Grid arrangement in which overall aligment and * spacing can be configured, as well as specfic layout requirements for the * each individual member of the GridLayout. This layout is a Draw2D port of the * swt GridLayout. * * GridLayout has a number of configuration fields, and the Figures * it lays out can have an associated layout data object, called * GridData (similar to the swt GridData object). The power of * GridLayout lies in the ability to configure * GridData for each Figure in the layout. *

* The following code creates a container Figure managed by a * GridLayout with 2 columns, containing 3 RectangleFigure shapes, * the last of which has been given further layout instructions. Note that it is * the GridLayout method setConstraint that binds the * child Figure to its layout GridData object. * *

 * Figure container = new Figure();
 * GridLayout gridLayout = new GridLayout();
 * gridLayout.numColumns = 2;
 * container.setLayout(gridLayout);
 * 
 * Shape rect;
 * rect = new RectangleFigure();
 * container.add(rect);
 * 
 * rect = new RectangleFigure();
 * container.add(rect);
 * 
 * rect = new RectangleFigure();
 * GridData gridData = new GridData();
 * gridData.widthHint = 150;
 * layout.setConstraint(rect, gridData);
 * 
 * container.add(rect);
 * 
* *

* The numColumns field is the most important field in a * GridLayout. Widgets are laid out in columns from left to right, * and a new row is created when numColumns+ 1 figures are added to * the Figure parent container. * * @see GridData * */ public class GridLayout extends AbstractLayout { /** * numColumns specifies the number of cell columns in the layout. * * The default value is 1. */ public int numColumns = 1; /** * makeColumnsEqualWidth specifies whether all columns in the layout will be * forced to have the same width. * * The default value is false. */ public boolean makeColumnsEqualWidth = false; /** * marginWidth specifies the number of pixels of horizontal margin that will * be placed along the left and right edges of the layout. * * The default value is 5. */ public int marginWidth = 5; /** * marginHeight specifies the number of pixels of vertical margin that will * be placed along the top and bottom edges of the layout. * * The default value is 5. */ public int marginHeight = 5; /** * horizontalSpacing specifies the number of pixels between the right edge * of one cell and the left edge of its neighbouring cell to the right. * * The default value is 5. */ public int horizontalSpacing = 5; /** * verticalSpacing specifies the number of pixels between the bottom edge of * one cell and the top edge of its neighbouring cell underneath. * * The default value is 5. */ public int verticalSpacing = 5; /** The layout contraints */ protected Map constraints = new HashMap(); /** * Default Constructor */ public GridLayout() { super(); } /** * Constructs a new instance of this class given the number of columns, and * whether or not the columns should be forced to have the same width. * * @param numColumns * the number of columns in the grid * @param makeColumnsEqualWidth * whether or not the columns will have equal width * */ public GridLayout(int numColumns, boolean makeColumnsEqualWidth) { this.numColumns = numColumns; this.makeColumnsEqualWidth = makeColumnsEqualWidth; } /** * @param child * @param wHint * @param hHint * @return the child size. */ protected Dimension getChildSize(IFigure child, int wHint, int hHint) { return child.getPreferredSize(wHint, hHint); } GridData getData(IFigure[][] grid, int row, int column, int rowCount, int columnCount, boolean first) { IFigure figure = grid[row][column]; if (figure != null) { GridData data = (GridData) getConstraint(figure); int hSpan = Math.max(1, Math.min(data.horizontalSpan, columnCount)); int vSpan = Math.max(1, data.verticalSpan); int i = first ? row + vSpan - 1 : row - vSpan + 1; int j = first ? column + hSpan - 1 : column - hSpan + 1; if (0 <= i && i < rowCount) { if (0 <= j && j < columnCount) { if (figure == grid[i][j]) return data; } } } return null; } void initChildren(IFigure container) { List children = container.getChildren(); for (int i = 0; i < children.size(); i++) { IFigure child = (IFigure) children.get(i); if (child.getLayoutManager() == null) child.setLayoutManager(this); } } /* * (non-Javadoc) * * @see * org.eclipse.draw2d.AbstractLayout#calculatePreferredSize(org.eclipse. * draw2d.IFigure, int, int) */ protected Dimension calculatePreferredSize(IFigure container, int wHint, int hHint) { Dimension size = layout(container, false, 0, 0, wHint, hHint, /* flushCache */ true); if (wHint != SWT.DEFAULT) size.width = wHint; if (hHint != SWT.DEFAULT) size.height = hHint; /* * Adjust for the size of the border */ size.expand(container.getInsets().getWidth(), container.getInsets() .getHeight()); size.union(getBorderPreferredSize(container)); return size; } /* * (non-Javadoc) * * @see org.eclipse.draw2d.LayoutManager#layout(org.eclipse.draw2d.IFigure) */ public void layout(IFigure container) { // initChildren( container); Rectangle rect = container.getClientArea(); layout(container, true, rect.x, rect.y, rect.width, rect.height, /* flushCache */ true); } Dimension layout(IFigure container, boolean move, int x, int y, int width, int height, boolean flushCache) { if (numColumns < 1) return new Dimension(marginWidth * 2, marginHeight * 2); List children = container.getChildren(); for (int i = 0; i < children.size(); i++) { IFigure child = (IFigure) children.get(i); GridData data = (GridData) getConstraint(child); if (data == null) setConstraint(child, data = new GridData()); if (flushCache) data.flushCache(); data.computeSize(child, flushCache); } /* Build the grid */ int row = 0, column = 0, rowCount = 0, columnCount = numColumns; IFigure[][] grid = new IFigure[4][columnCount]; for (int i = 0; i < children.size(); i++) { IFigure child = (IFigure) children.get(i); GridData data = (GridData) getConstraint(child); int hSpan = Math.max(1, Math.min(data.horizontalSpan, columnCount)); int vSpan = Math.max(1, data.verticalSpan); while (true) { int lastRow = row + vSpan; if (lastRow >= grid.length) { IFigure[][] newGrid = new IFigure[lastRow + 4][columnCount]; System.arraycopy(grid, 0, newGrid, 0, grid.length); grid = newGrid; } if (grid[row] == null) { grid[row] = new IFigure[columnCount]; } while (column < columnCount && grid[row][column] != null) { column++; } int endCount = column + hSpan; if (endCount <= columnCount) { int index = column; while (index < endCount && grid[row][index] == null) { index++; } if (index == endCount) break; column = index; } if (column + hSpan >= columnCount) { column = 0; row++; } } for (int j = 0; j < vSpan; j++) { if (grid[row + j] == null) { grid[row + j] = new IFigure[columnCount]; } for (int k = 0; k < hSpan; k++) { grid[row + j][column + k] = child; } } rowCount = Math.max(rowCount, row + vSpan); column += hSpan; } /* Column widths */ int availableWidth = width - horizontalSpacing * (columnCount - 1) - marginWidth * 2; int expandCount = 0; int[] widths = new int[columnCount]; int[] minWidths = new int[columnCount]; boolean[] expandColumn = new boolean[columnCount]; for (int j = 0; j < columnCount; j++) { for (int i = 0; i < rowCount; i++) { GridData data = getData(grid, i, j, rowCount, columnCount, true); if (data != null) { int hSpan = Math.max(1, Math.min(data.horizontalSpan, columnCount)); if (hSpan == 1) { int w = data.cacheWidth + data.horizontalIndent; widths[j] = Math.max(widths[j], w); if (data.grabExcessHorizontalSpace) { if (!expandColumn[j]) expandCount++; expandColumn[j] = true; } if (data.widthHint != SWT.DEFAULT || !data.grabExcessHorizontalSpace) { minWidths[j] = Math.max(minWidths[j], w); } } } } for (int i = 0; i < rowCount; i++) { GridData data = getData(grid, i, j, rowCount, columnCount, false); if (data != null) { int hSpan = Math.max(1, Math.min(data.horizontalSpan, columnCount)); if (hSpan > 1) { int spanWidth = 0, spanMinWidth = 0, spanExpandCount = 0; for (int k = 0; k < hSpan; k++) { spanWidth += widths[j - k]; spanMinWidth += minWidths[j - k]; if (expandColumn[j - k]) spanExpandCount++; } if (data.grabExcessHorizontalSpace && spanExpandCount == 0) { expandCount++; expandColumn[j] = true; } int w = data.cacheWidth + data.horizontalIndent - spanWidth - (hSpan - 1) * horizontalSpacing; if (w > 0) { if (spanExpandCount == 0) { widths[j] += w; } else { int delta = w / spanExpandCount; int remainder = w % spanExpandCount, last = -1; for (int k = 0; k < hSpan; k++) { if (expandColumn[j - k]) { widths[last = j - k] += delta; } } if (last > -1) widths[last] += remainder; } } if (data.widthHint != SWT.DEFAULT || !data.grabExcessHorizontalSpace) { w = data.cacheWidth + data.horizontalIndent - spanMinWidth - (hSpan - 1) * horizontalSpacing; if (w > 0) { if (spanExpandCount == 0) { minWidths[j] += w; } else { int delta = w / spanExpandCount; int remainder = w % spanExpandCount, last = -1; for (int k = 0; k < hSpan; k++) { if (expandColumn[j - k]) { minWidths[last = j - k] += delta; } } if (last > -1) minWidths[last] += remainder; } } } } } } } if (makeColumnsEqualWidth) { int minColumnWidth = 0; int columnWidth = 0; for (int i = 0; i < columnCount; i++) { minColumnWidth = Math.max(minColumnWidth, minWidths[i]); columnWidth = Math.max(columnWidth, widths[i]); } columnWidth = width == SWT.DEFAULT || expandCount == 0 ? columnWidth : Math.max(minColumnWidth, availableWidth / columnCount); for (int i = 0; i < columnCount; i++) { expandColumn[i] = expandCount > 0; widths[i] = columnWidth; } } else { if (width != SWT.DEFAULT && expandCount > 0) { int totalWidth = 0; for (int i = 0; i < columnCount; i++) { totalWidth += widths[i]; } int count = expandCount; int delta = (availableWidth - totalWidth) / count; int remainder = (availableWidth - totalWidth) % count; int last = -1; while (totalWidth != availableWidth) { for (int j = 0; j < columnCount; j++) { if (expandColumn[j]) { if (widths[j] + delta > minWidths[j]) { widths[last = j] = widths[j] + delta; } else { widths[j] = minWidths[j]; expandColumn[j] = false; count--; } } } if (last > -1) widths[last] += remainder; for (int j = 0; j < columnCount; j++) { for (int i = 0; i < rowCount; i++) { GridData data = getData(grid, i, j, rowCount, columnCount, false); if (data != null) { int hSpan = Math.max(1, Math.min( data.horizontalSpan, columnCount)); if (hSpan > 1) { if (data.widthHint != SWT.DEFAULT || !data.grabExcessHorizontalSpace) { int spanWidth = 0, spanExpandCount = 0; for (int k = 0; k < hSpan; k++) { spanWidth += widths[j - k]; if (expandColumn[j - k]) spanExpandCount++; } int w = data.cacheWidth + data.horizontalIndent - spanWidth - (hSpan - 1) * horizontalSpacing; if (w > 0) { if (spanExpandCount == 0) { widths[j] += w; } else { int delta2 = w / spanExpandCount; int remainder2 = w % spanExpandCount, last2 = -1; for (int k = 0; k < hSpan; k++) { if (expandColumn[j - k]) { widths[last2 = j - k] += delta2; } } if (last2 > -1) widths[last2] += remainder2; } } } } } } } if (count == 0) break; totalWidth = 0; for (int i = 0; i < columnCount; i++) { totalWidth += widths[i]; } delta = (availableWidth - totalWidth) / count; remainder = (availableWidth - totalWidth) % count; last = -1; } } } /* Wrapping */ GridData[] flush = null; int flushLength = 0; if (width != SWT.DEFAULT) { for (int j = 0; j < columnCount; j++) { for (int i = 0; i < rowCount; i++) { GridData data = getData(grid, i, j, rowCount, columnCount, false); if (data != null) { if (data.heightHint == SWT.DEFAULT) { IFigure child = grid[i][j]; // TEMPORARY CODE int hSpan = Math.max(1, Math.min(data.horizontalSpan, columnCount)); int currentWidth = 0; for (int k = 0; k < hSpan; k++) { currentWidth += widths[j - k]; } currentWidth += (hSpan - 1) * horizontalSpacing - data.horizontalIndent; if ((currentWidth != data.cacheWidth && data.horizontalAlignment == SWT.FILL) || (data.cacheWidth > currentWidth)) { int trim = 0; /* * // *Note*: Left this in place from SWT // * GridLayout. Not sure if Draw2D Borders or // * Scrollbars 'trim' will need to be takeninto * account. * * if (child instanceof Group) { Group g * =(Group)child; trim = g.getSize ().x - * g.getClientArea ().width; } else if (child * instanceof Scrollable) { Rectangle rect = * ((Scrollable) child).computeTrim (0, 0, 0,0); * trim = rect.width; } else { trim = * child.getBorderWidth () * 2; } */ int oldWidthHint = data.widthHint; data.widthHint = Math.max(0, currentWidth - trim); data.cacheWidth = data.cacheHeight = SWT.DEFAULT; data.computeSize(child, false); data.widthHint = oldWidthHint; if (flush == null) flush = new GridData[children.size()]; flush[flushLength++] = data; } } } } } } /* Row heights */ int availableHeight = height - verticalSpacing * (rowCount - 1) - marginHeight * 2; expandCount = 0; int[] heights = new int[rowCount]; int[] minHeights = new int[rowCount]; boolean[] expandRow = new boolean[rowCount]; for (int i = 0; i < rowCount; i++) { for (int j = 0; j < columnCount; j++) { GridData data = getData(grid, i, j, rowCount, columnCount, true); if (data != null) { int vSpan = Math.max(1, Math.min(data.verticalSpan, rowCount)); if (vSpan == 1) { int h = data.cacheHeight; // + data.verticalIndent; heights[i] = Math.max(heights[i], h); if (data.grabExcessVerticalSpace) { if (!expandRow[i]) expandCount++; expandRow[i] = true; } if (data.heightHint != SWT.DEFAULT || !data.grabExcessVerticalSpace) { minHeights[i] = Math.max(minHeights[i], h); } } } } for (int j = 0; j < columnCount; j++) { GridData data = getData(grid, i, j, rowCount, columnCount, false); if (data != null) { int vSpan = Math.max(1, Math.min(data.verticalSpan, rowCount)); if (vSpan > 1) { int spanHeight = 0, spanMinHeight = 0, spanExpandCount = 0; for (int k = 0; k < vSpan; k++) { spanHeight += heights[i - k]; spanMinHeight += minHeights[i - k]; if (expandRow[i - k]) spanExpandCount++; } if (data.grabExcessVerticalSpace && spanExpandCount == 0) { expandCount++; expandRow[i] = true; } int h = data.cacheHeight - spanHeight - (vSpan - 1) * verticalSpacing; // + data.verticalalIndent if (h > 0) { if (spanExpandCount == 0) { heights[i] += h; } else { int delta = h / spanExpandCount; int remainder = h % spanExpandCount, last = -1; for (int k = 0; k < vSpan; k++) { if (expandRow[i - k]) { heights[last = i - k] += delta; } } if (last > -1) heights[last] += remainder; } } if (data.heightHint != SWT.DEFAULT || !data.grabExcessVerticalSpace) { h = data.cacheHeight - spanMinHeight - (vSpan - 1) * verticalSpacing; // + data.verticalIndent if (h > 0) { if (spanExpandCount == 0) { minHeights[i] += h; } else { int delta = h / spanExpandCount; int remainder = h % spanExpandCount, last = -1; for (int k = 0; k < vSpan; k++) { if (expandRow[i - k]) { minHeights[last = i - k] += delta; } } if (last > -1) minHeights[last] += remainder; } } } } } } } if (height != SWT.DEFAULT && expandCount > 0) { int totalHeight = 0; for (int i = 0; i < rowCount; i++) { totalHeight += heights[i]; } int count = expandCount; int delta = (availableHeight - totalHeight) / count; int remainder = (availableHeight - totalHeight) % count; int last = -1; while (totalHeight != availableHeight) { for (int i = 0; i < rowCount; i++) { if (expandRow[i]) { if (heights[i] + delta > minHeights[i]) { heights[last = i] = heights[i] + delta; } else { heights[i] = minHeights[i]; expandRow[i] = false; count--; } } } if (last > -1) heights[last] += remainder; for (int i = 0; i < rowCount; i++) { for (int j = 0; j < columnCount; j++) { GridData data = getData(grid, i, j, rowCount, columnCount, false); if (data != null) { int vSpan = Math.max(1, Math.min(data.verticalSpan, rowCount)); if (vSpan > 1) { if (data.heightHint != SWT.DEFAULT || !data.grabExcessVerticalSpace) { int spanHeight = 0, spanExpandCount = 0; for (int k = 0; k < vSpan; k++) { spanHeight += heights[i - k]; if (expandRow[i - k]) spanExpandCount++; } int h = data.cacheHeight - spanHeight - (vSpan - 1) * verticalSpacing; // + // data.verticalIndent if (h > 0) { if (spanExpandCount == 0) { heights[i] += h; } else { int delta2 = h / spanExpandCount; int remainder2 = h % spanExpandCount, last2 = -1; for (int k = 0; k < vSpan; k++) { if (expandRow[i - k]) { heights[last2 = i - k] += delta2; } } if (last2 > -1) heights[last2] += remainder2; } } } } } } } if (count == 0) break; totalHeight = 0; for (int i = 0; i < rowCount; i++) { totalHeight += heights[i]; } delta = (availableHeight - totalHeight) / count; remainder = (availableHeight - totalHeight) % count; last = -1; } } /* Position the IFigures */ if (move) { int gridY = y + marginHeight; for (int i = 0; i < rowCount; i++) { int gridX = x + marginWidth; for (int j = 0; j < columnCount; j++) { GridData data = getData(grid, i, j, rowCount, columnCount, true); if (data != null) { int hSpan = Math.max(1, Math.min(data.horizontalSpan, columnCount)); int vSpan = Math.max(1, data.verticalSpan); int cellWidth = 0, cellHeight = 0; for (int k = 0; k < hSpan; k++) { cellWidth += widths[j + k]; } for (int k = 0; k < vSpan; k++) { cellHeight += heights[i + k]; } cellWidth += horizontalSpacing * (hSpan - 1); int childX = gridX + data.horizontalIndent; int childWidth = Math.min(data.cacheWidth, cellWidth); switch (data.horizontalAlignment) { case SWT.CENTER: case GridData.CENTER: childX = gridX + Math.max(0, (cellWidth - childWidth) / 2); break; case SWT.RIGHT: case SWT.END: case GridData.END: childX = gridX + Math.max(0, cellWidth - childWidth); break; case SWT.FILL: childWidth = cellWidth - data.horizontalIndent; break; } cellHeight += verticalSpacing * (vSpan - 1); int childY = gridY; // + data.verticalIndent; int childHeight = Math .min(data.cacheHeight, cellHeight); switch (data.verticalAlignment) { case SWT.CENTER: case GridData.CENTER: childY = gridY + Math.max(0, (cellHeight - childHeight) / 2); break; case SWT.BOTTOM: case SWT.END: case GridData.END: childY = gridY + Math.max(0, cellHeight - childHeight); break; case SWT.FILL: childHeight = cellHeight; // - // data.verticalIndent; break; } IFigure child = grid[i][j]; if (child != null) { // following param could be replaced by // Rectangle.SINGLETON child.setBounds(new Rectangle(childX, childY, childWidth, childHeight)); } } gridX += widths[j] + horizontalSpacing; } gridY += heights[i] + verticalSpacing; } } // clean up cache for (int i = 0; i < flushLength; i++) { flush[i].cacheWidth = flush[i].cacheHeight = -1; } int totalDefaultWidth = 0; int totalDefaultHeight = 0; for (int i = 0; i < columnCount; i++) { totalDefaultWidth += widths[i]; } for (int i = 0; i < rowCount; i++) { totalDefaultHeight += heights[i]; } totalDefaultWidth += horizontalSpacing * (columnCount - 1) + marginWidth * 2; totalDefaultHeight += verticalSpacing * (rowCount - 1) + marginHeight * 2; return new Dimension(totalDefaultWidth, totalDefaultHeight); } /* * (non-Javadoc) * * @see * org.eclipse.draw2d.LayoutManager#getConstraint(org.eclipse.draw2d.IFigure * ) */ public Object getConstraint(IFigure child) { return constraints.get(child); } /** * Sets the layout constraint of the given figure. The constraints can only * be of type {@link GridData}. * * @see LayoutManager#setConstraint(IFigure, Object) */ public void setConstraint(IFigure figure, Object newConstraint) { super.setConstraint(figure, newConstraint); if (newConstraint != null) { constraints.put(figure, newConstraint); } } }eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/GroupBoxBorder.java000066400000000000000000000047031166301720600272420ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Insets; import org.eclipse.draw2d.geometry.Rectangle; /** * A labeled border intended to house a Figure with a group of children. The * label should serve as a description of the group. */ public class GroupBoxBorder extends AbstractLabeledBorder { /** * Constructs a GroupBoxBorder with the name of this class as its label. * * @since 2.0 */ public GroupBoxBorder() { } /** * Constructs a GroupBoxBorder with label s. * * @param s * the label * @since 2.0 */ public GroupBoxBorder(String s) { super(s); } /** * Calculates and returns the Insets for this GroupBoxBorder. * * @param figure * IFigure on which the calculations should be made. Generally * this is the IFigure of which this GroupBoxBorder is * surrounding. * @return the Insets for this GroupBoxBorder. * @since 2.0 */ protected Insets calculateInsets(IFigure figure) { int height = getTextExtents(figure).height; return new Insets(height); } /** * @see org.eclipse.draw2d.Border#getPreferredSize(IFigure) */ public Dimension getPreferredSize(IFigure fig) { Dimension textSize = getTextExtents(fig); return textSize.getCopy().expand(textSize.height * 2, 0); } /** * @see Border#paint(IFigure, Graphics, Insets) */ public void paint(IFigure figure, Graphics g, Insets insets) { tempRect.setBounds(getPaintRectangle(figure, insets)); Rectangle r = tempRect; if (r.isEmpty()) return; Rectangle textLoc = new Rectangle(r.getTopLeft(), getTextExtents(figure)); r.crop(new Insets(getTextExtents(figure).height / 2)); FigureUtilities.paintEtchedBorder(g, r); textLoc.x += getInsets(figure).left; g.setFont(getFont(figure)); g.setForegroundColor(getTextColor()); g.clipRect(textLoc); g.fillText(getLabel(), textLoc.getTopLeft()); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/IClippingStrategy.java000066400000000000000000000027751166301720600277470ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Research Group Software Construction, * RWTH Aachen University, Germany - initial API and implementation */ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Rectangle; /** * A clipping strategy used to specify the clipping region for child figures. * * @author Alexander Nyssen * * @since 3.6 */ public interface IClippingStrategy { /** * Specifies the clipping region for the given child figure. That is, all * parts of the figure, which are not covered by one of the returned * rectangles are masked out and will not get painted. Each returned * rectangle is considered to be specified in coordinates relative to the * given child figure's bounds. * * @param childFigure * The child figure, which clipping region has to be returned. * @return An array of rectangles to specify the clipping region of the * figure, i.e. the areas in which the figure should not get * clipped. May return an empty array in case the figure should not * be visible at all, may not return null. */ Rectangle[] getClip(IFigure childFigure); }eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/IFigure.java000066400000000000000000000726741166301720600257050ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.beans.PropertyChangeListener; import java.util.Collection; import java.util.List; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Cursor; import org.eclipse.swt.graphics.Font; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Insets; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.draw2d.geometry.Translatable; /** * A lightweight graphical object. Figures are rendered to a {@link Graphics} * object. Figures can be composed to create complex graphics. * * @noimplement This interface is not intended to be implemented by clients. Use * {@link Figure}. */ public interface IFigure { /** * Insets that are all 0. Always returns * true for {@link #isEmpty()}. */ class NoInsets extends Insets { NoInsets() { super(0, 0, 0, 0); } public boolean isEmpty() { return true; } } /** * The maximum allowable dimension. ({@link Integer#MAX_VALUE}, * {@link Integer#MAX_VALUE}) */ Dimension MAX_DIMENSION = new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE); /** * The minimum allowable dimension. (5,5) */ Dimension MIN_DIMENSION = new Dimension(5, 5); /** * Empty Insets. */ Insets NO_INSETS = new NoInsets(); /** * Adds the given IFigure as a child of this IFigure. The same as calling * {@link #add(IFigure, Object, int) add(figure, null, -1)}. * * @param figure * The IFigure to add */ void add(IFigure figure); /** * Adds the given IFigure as a child of this IFigure at the given index. The * same as calling {@link #add(IFigure, Object, int) add(figure, null, * index)}. * * @param figure * The IFigure to add * @param index * The index where the IFigure should be added */ void add(IFigure figure, int index); /** * Adds the given IFigure as a child of this IFigure with the given * constraint. The same as calling {@link #add(IFigure, Object, int) * add(figure, constraint, -1)}. * * @param figure * The IFigure to add * @param constraint * The newly added IFigure's constraint */ void add(IFigure figure, Object constraint); /** * Adds the child with the specified index and constraint. The child's * parent is currently not null, it is removed from that parent. If this * figure has a LayoutManager, then * {@link LayoutManager#setConstraint(IFigure, Object)} shall be called on * the layout. * * @param figure * The IFigure to add * @param constraint * The newly added IFigure's constraint * @param index * The index where the IFigure should be added * @throws IndexOutOfBoundsException * if the index is out of range * @throws IllegalArgumentException * if adding the child creates a cycle */ void add(IFigure figure, Object constraint, int index); /** * Registers the given listener as an AncestorListener of this figure. * * @param listener * The listener to add */ void addAncestorListener(AncestorListener listener); /** * Registers the given listener as a CoordinateListener of this figure. * * @param listener * the listener to add * @since 3.1 */ void addCoordinateListener(CoordinateListener listener); /** * Registers the given listener as a FigureListener of this figure. * * @param listener * The listener to add */ void addFigureListener(FigureListener listener); /** * Registers the given listener as a FocusListener of this figure. * * @param listener * The listener to add */ void addFocusListener(FocusListener listener); /** * Registers the given listener as a KeyListener of this figure. * * @param listener * The listener to add */ void addKeyListener(KeyListener listener); /** * Registers the given listener on this figure. * * @param listener * The listener to add * @since 3.1 */ void addLayoutListener(LayoutListener listener); /** * Registers the given listener as a MouseListener of this IFigure. * * @param listener * The listener to add */ void addMouseListener(MouseListener listener); /** * Registers the given listener as a MouseMotionListener of this IFigure. * * @param listener * The listener to add */ void addMouseMotionListener(MouseMotionListener listener); /** * Called after this IFigure is added to its parent. */ void addNotify(); /** * Registers the given listener as a PropertyChangeListener of this IFigure. * * @param listener * The listener to add */ void addPropertyChangeListener(PropertyChangeListener listener); /** * Registers the given listener as a PropertyChangeListener of this IFigure, * interested only in the given property. * * @param property * The property the listener is interested in * @param listener * The listener to add */ void addPropertyChangeListener(String property, PropertyChangeListener listener); /** * Returns true if the point (x, y) is contained * within this IFigure's bounds. * * @param x * The X coordinate * @param y * The Y coordinate * @return true if the point (x,y) is contained in this * IFigure's bounds */ boolean containsPoint(int x, int y); /** * Returns true if the Point p is contained within this * IFigure's bounds. * * @param p * The point * @return true if the Point p is contained within this * IFigure's bounds */ boolean containsPoint(Point p); /** * Erases this IFigure. */ void erase(); /** * Returns the IFigure at the specified location. May return * this or null. * * @param x * The X coordinate * @param y * The Y coordinate * @return The IFigure at the specified location */ IFigure findFigureAt(int x, int y); /** * Returns the IFigure at the specified location based on the conditional * TreeSearch. May return this or null * * @param x * the X coordinate * @param y * the Y coordinate * @param search * the conditional TreeSearch * @return the IFigure at the specified location */ IFigure findFigureAt(int x, int y, TreeSearch search); /** * Returns the IFigure at the specified location. May return * this or null. * * @param p * The point * @return The IFigure at the specified location */ IFigure findFigureAt(Point p); /** * Returns the IFigure at the specified location, excluding any IFigures in * collection. May return this or * null. * * @param x * The X coordinate * @param y * The Y coordinate * @param collection * A collection of IFigures to be excluded * @return The IFigure at the specified location, excluding any IFigures in * collection */ IFigure findFigureAtExcluding(int x, int y, Collection collection); /** * Returns the IFigure located at the given location which will accept mouse * events. * * @param x * The X coordinate * @param y * The Y coordinate * @return The IFigure located at the given location which will accept mouse * events */ IFigure findMouseEventTargetAt(int x, int y); /** * Returns the background color. Background color can be inherited from the * parent. * * @return The background color */ Color getBackgroundColor(); /** * Returns the current border by reference. * * @return The current border */ Border getBorder(); /** * Returns the smallest rectangle completely enclosing the IFigure. * Implementation may return the Rectangle by reference. For this reason, * callers of this method must not modify the returned Rectangle. The * Rectangle's values may change in the future. * * @return This IFigure's bounds */ Rectangle getBounds(); /** * Returns an unmodifiable list of children by reference. * * @return An unmodifiable list of children by reference */ List getChildren(); /** * Returns the rectangular area within this Figure's bounds in which * children will be placed (via {@link LayoutManager LayoutManagers}) and * the painting of children will be clipped. * * @return The client area */ Rectangle getClientArea(); /** * Copies the client area into the specificied Recangle, and returns that * rectangle for convenience. * * @param rect * The destination rectangle for the client area * @return The same instance that was passed in, modified to contain the * client area */ Rectangle getClientArea(Rectangle rect); /** * Returns the IClippingStrategy used by this figure to clip its children * * @return the IClipppingStrategy used to clip this figure's children. * @since 3.6 */ IClippingStrategy getClippingStrategy(); /** * Returns the Cursor used when the mouse is over this IFigure. * * @return The Cursor used when the mouse is over this IFigure */ Cursor getCursor(); /** * Returns the current Font by reference. * * @return The current Font */ Font getFont(); /** * Returns the foreground color. * * @return The foreground color */ Color getForegroundColor(); /** * Returns the current Insets. May be returned by reference. The returned * value should not be modified. * * @return The current Insets. */ Insets getInsets(); /** * Returns the current LayoutManager by reference. * * @return The current LayoutManager by reference */ LayoutManager getLayoutManager(); /** * Returns the background Color of this Figure. Does not inherit this Color * from the parent, may return null. * * @return The local background Color */ Color getLocalBackgroundColor(); /** * Returns the local foreground Color of this Figure. Does not inherit this * Color from the parent, may return null. * * @return The local foreground Color */ Color getLocalForegroundColor(); /** * Returns a hint indicating the largest desireable size for the IFigure. * Returned Dimension is by value. * * @return The maximum size */ Dimension getMaximumSize(); /** * Returns a hint indicating the smallest desireable size for the IFigure. * The returned dimension may be by reference, and it must not be * modified by the caller. * * @return The minimum size */ Dimension getMinimumSize(); /** * Returns a hint indicating the smallest desireable size for the IFigure. * The returned dimension may be by reference, and it must not be * modified by the caller. * * @param wHint * the width hint * @param hHint * the height hint * @return The minimum size */ Dimension getMinimumSize(int wHint, int hHint); /** * Returns the IFigure that is the current parent of this IFigure or * null if there is no parent. * * @return null or the parent figure */ IFigure getParent(); /** * Returns the preferred size for this IFigure. The returned value must not * be modified by the caller. If the figure has no preference, it returns * its current size. The same as calling {@link #getPreferredSize(int, int) * getPreferredSize(-1, -1)}. * * @return The preferred size */ Dimension getPreferredSize(); /** * Returns the preferred size for this IFigure using the provided width and * height hints. The returned dimension may be by reference, and it * must not be modified by the caller. A value of -1 indicates * that there is no constraint in that direction. * * @param wHint * a width hint * @param hHint * a height hint * @return The preferred size */ Dimension getPreferredSize(int wHint, int hHint); /** * Returns the current size. Returned Dimension is by value. * * @return The current size */ Dimension getSize(); /** * Returns a IFigure that is the tooltip for this IFigure. * * @return This IFigure's tooltip */ IFigure getToolTip(); /** * Returns the UpdateManager for this IFigure by reference. * * @return The update manager */ UpdateManager getUpdateManager(); /** * Called when this IFigure has gained focus. *

* NOTE: You should not override this method. If you are interested * in receiving notification of this type of event, you should register a * {@link FocusListener} with this IFigure. * * @param event * The focus event */ void handleFocusGained(FocusEvent event); /** * Called when this IFigure has lost focus. *

* NOTE: You should not override this method. If you are interested * in receiving notification of this type of event, you should register a * {@link FocusListener} with this IFigure. * * @param event * The focus event */ void handleFocusLost(FocusEvent event); /** * Called when a key is pressed while this IFigure has focus. *

* NOTE: You should not override this method. If you are interested * in receiving notification of this type of event, you should register a * {@link KeyListener} with this IFigure. * * @param event * The key event */ void handleKeyPressed(KeyEvent event); /** * Called when a key is released while this IFigure has focus. *

* NOTE: You should not override this method. If you are interested * in receiving notification of this type of event, you should register a * {@link KeyListener} with this IFigure. * * @param event * The key event */ void handleKeyReleased(KeyEvent event); /** * Called when a mouse button has been double-clicked while within this * IFigure's bounds. *

* NOTE: You should not override this method. If you are interested * in receiving notification of this type of event, you should register a * {@link MouseListener} with this IFigure. * * @param event * The mouse event */ void handleMouseDoubleClicked(MouseEvent event); /** * Called when the mouse has been dragged within this IFigure's bounds. *

* NOTE: You should not override this method. If you are interested * in receiving notification of this type of event, you should register a * {@link MouseMotionListener} with this IFigure. * * @param event * The mouse event */ void handleMouseDragged(MouseEvent event); /** * Called when the mouse has entered this IFigure's bounds. *

* NOTE: You should not override this method. If you are interested * in receiving notification of this type of event, you should register a * {@link MouseMotionListener} with this IFigure. * * @param event * The mouse event */ void handleMouseEntered(MouseEvent event); /** * Called when the mouse has exited this IFigure's bounds. *

* NOTE: You should not override this method. If you are interested * in receiving notification of this type of event, you should register a * {@link MouseMotionListener} with this IFigure. * * @param event * The mouse event */ void handleMouseExited(MouseEvent event); /** * Called when the mouse has hovered over this IFigure. *

* NOTE: You should not override this method. If you are interested * in receiving notification of this type of event, you should register a * {@link MouseMotionListener} with this IFigure. * * @param event * The mouse event */ void handleMouseHover(MouseEvent event); /** * Called when the mouse has moved within this IFigure's bounds. *

* NOTE: You should not override this method. If you are interested * in receiving notification of this type of event, you should register a * {@link MouseMotionListener} with this IFigure. * * @param event * The mouse event */ void handleMouseMoved(MouseEvent event); /** * Called when a mouse button has been pressed while within this IFigure's * bounds. *

* NOTE: You should not override this method. If you are interested * in receiving notification of this type of event, you should register a * {@link MouseListener} with this IFigure. * * @param event * The mouse event */ void handleMousePressed(MouseEvent event); /** * Called when a mouse button has been released while within this IFigure's * bounds. *

* NOTE: You should not override this method. If you are interested * in receiving notification of this type of event, you should register a * {@link MouseListener} with this IFigure. * * @param event * The mouse event */ void handleMouseReleased(MouseEvent event); /** * Returns true if this IFigure has focus. * * @return true if this IFigure has focus */ boolean hasFocus(); /** * This method is for internal purposes only and should not be * called. * * @return The event dispatcher */ EventDispatcher internalGetEventDispatcher(); /** * Returns true if this IFigure's bounds intersect with the * given Rectangle. Figure is asked so that non-rectangular IFigures can * reduce the frequency of paints. * * @param rect * The rectangle to check for intersection * @return true if this IFigure's bounds intersect with the * given Rectangle */ boolean intersects(Rectangle rect); /** * Invalidates this IFigure. If this figure has a LayoutManager, then * {@link LayoutManager#invalidate()} should be called on that layout. */ void invalidate(); /** * Invalidates this figure as well as all contained within. */ void invalidateTree(); /** * Returns true if this figure is capable of applying a local * coordinate system which affects its children. * * @since 3.1 * @return true if this figure provides local coordinates to * children */ boolean isCoordinateSystem(); /** * Returns true if this IFigure is enabled. * * @return true if this IFigure is enabled */ boolean isEnabled(); /** * Returns true if this IFigure can gain focus on a * {@link org.eclipse.swt.events.TraverseEvent}. * * @return true if this IFigure can gain focus on a * TraverseEvent */ boolean isFocusTraversable(); /** * @return true if this figure is hosted in a Control that is * mirrored * @since 3.1 */ boolean isMirrored(); /** * Returns true if this IFigure is opaque. * * @return true if this IFigure is opaque */ boolean isOpaque(); /** * Returns true if this IFigure can receive focus on a call to * {@link #requestFocus()}. * * @return true if this IFigure can receive focus on a call to * requestFocus() */ boolean isRequestFocusEnabled(); /** * Returns true if this IFigure is showing. This figure is only * showing if it is visible and its parent is showing, or it has no parent. * * @return true if this IFigure is showing */ boolean isShowing(); /** * returns true if this figure's visibility flag is set to * true. Does not walk up the parent chain. * * @return true if the figure's visibility flag is set */ boolean isVisible(); /** * Paints this IFigure and its children. * * @param graphics * The Graphics object used for painting */ void paint(Graphics graphics); /** * Removes the given child from this figure's children. If this figure has a * LayoutManager, then {@link LayoutManager#remove(IFigure)} shall be called * on that layout with the child. * * @param figure * The IFigure to remove */ void remove(IFigure figure); /** * Unregisters the given listener, so that it will no longer receive * notification of ancestor events. * * @param listener * The listener to remove */ void removeAncestorListener(AncestorListener listener); /** * Unregisters the given listener, so that it will no longer receive * notification of coordinate changes. * * @param listener * the listener to remove * @since 3.1 */ void removeCoordinateListener(CoordinateListener listener); /** * Unregisters the given listener, so that it will no longer receive * notification of IFigure events. * * @param listener * The listener to remove */ void removeFigureListener(FigureListener listener); /** * Unregisters the given listener, so that it will no longer receive * notification of focus events. * * @param listener * The listener to remove */ void removeFocusListener(FocusListener listener); /** * Removes the first occurence of the given listener. * * @param listener * The listener to remove */ void removeKeyListener(KeyListener listener); /** * Removes the most recent occurence of the given listener. * * @since 3.1 * @param listener * the listener to remove */ void removeLayoutListener(LayoutListener listener); /** * Unregisters the given listener, so that it will no longer receive * notification of mouse events. * * @param listener * The listener to remove */ void removeMouseListener(MouseListener listener); /** * Unregisters the given listener, so that it will no longer receive * notification of mouse motion events. * * @param listener * The listener to remove */ void removeMouseMotionListener(MouseMotionListener listener); /** * Called before this IFigure is removed from its parent. */ void removeNotify(); /** * Unregisters the given listener, so that it will no longer receive * notification of any property changes. * * @param listener * The listener to remove */ void removePropertyChangeListener(PropertyChangeListener listener); /** * Unregisters the given listener, so that it will no longer receive * notification of changes in the given property. This will only unregister * the listener for the given property. If the listener is registered to * listen to other properties, this will not affect the notification of the * listener regarding those properties. * * @param property * The property that the listener is no longer interested in * @param listener * The listener no longer interested in the property */ void removePropertyChangeListener(String property, PropertyChangeListener listener); /** * Repaints this IFigure. */ void repaint(); /** * Repaints the rectangular area within this IFigure whose upper-left corner * is located at the point (x,y) and whose width and height are * w and h, respectively. * * @param x * The X coordinate of the area to repaint * @param y * The Y coordinate of the area to repaint * @param w * The width of the area to repaint * @param h * The height of the area to repaint */ void repaint(int x, int y, int w, int h); /** * Repaints the rectangular area within this IFigure represented by * rect. * * @param rect * The rectangular area to be repainted */ void repaint(Rectangle rect); /** * Requests focus from the {@link EventDispatcher}. */ void requestFocus(); /** * Invalidates this figure and revalidates() its parent. If a figure does * not have a parent, it will request a validation from it UpdateManager. * Calling this method does not guarantee that a repaint will occur. */ void revalidate(); /** * Sets the background color. * * @param c * The new background color */ void setBackgroundColor(Color c); /** * Sets the border. * * @param b * The new border */ void setBorder(Border b); /** * Sets the bounds to the bounds of the specified Rectangle. * * @param rect * The new bounds */ void setBounds(Rectangle rect); /** * Registers a clipping strategy to specify how clipping is performed for * child figures. * * @param clippingStrategy * @since 3.6 */ void setClippingStrategy(IClippingStrategy clippingStrategy); /** * Convenience method to set the constraint of the specified child in the * current LayoutManager. * * @param child * The figure whose constraint is being set * @param constraint * the constraint * @throws IllegalArgumentException * if the child is not contained by this Figure */ void setConstraint(IFigure child, Object constraint); /** * Sets the cursor. * * @param cursor * The new cursor */ void setCursor(Cursor cursor); /** * Sets this IFigure to be enabled. * * @param value * true if this IFigure should be enabled */ void setEnabled(boolean value); /** * Sets the ability for this IFigure to gain focus on a * {@link org.eclipse.swt.events.TraverseEvent}. * * @param value * true if this IFigure should gain focus on a * TraverseEvent */ void setFocusTraversable(boolean value); /** * Sets the font. * * @param f * The new font */ void setFont(Font f); /** * Sets the foreground color. * * @param c * The new foreground color */ void setForegroundColor(Color c); /** * Sets the LayoutManager. * * @param lm * The new layout manager */ void setLayoutManager(LayoutManager lm); /** * Sets the location of this IFigure. * * @param p * The new location */ void setLocation(Point p); /** * Sets the maximum size this IFigure can be. * * @param size * The new maximum size */ void setMaximumSize(Dimension size); /** * Sets the minimum size this IFigure can be. * * @param size * The new minimum size */ void setMinimumSize(Dimension size); /** * Sets this IFigure to be opaque if isOpaque is true * and transparent if isOpaque is false. * * @param isOpaque * true is this IFigure should be opaque */ void setOpaque(boolean isOpaque); /** * Sets this IFigure's parent. * * @param parent * The new parent IFigure */ void setParent(IFigure parent); /** * Sets this IFigure's preferred size. * * @param size * The new preferred size */ void setPreferredSize(Dimension size); /** * Sets the ability for this Figure to gain focus on a call to * {@link #requestFocus()}. * * @param requestFocusEnabled * true if this IFigure should gain focus on a call * to requestFocus() */ void setRequestFocusEnabled(boolean requestFocusEnabled); /** * Sets this IFigure's size. * * @param d * The new size */ void setSize(Dimension d); /** * Sets this IFigure's size. * * @param w * The new width * @param h * The new height */ void setSize(int w, int h); /** * Sets a tooltip that is displayed when the mouse hovers over this IFigure. * * @param figure * The tooltip IFigure */ void setToolTip(IFigure figure); /** * Sets this IFigure's visibility. * * @param visible * true if this IFigure should be visible */ void setVisible(boolean visible); /** * Moves this IFigure x pixels horizontally and y * pixels vertically. * * @param x * The amount to move this IFigure horizontally * @param y * The amount to move this IFigure vertically */ void translate(int x, int y); /** * Translates a Translatable from this IFigure's parent's coordinates to * this IFigure's local coordinates. * * @param t * The object to translate */ void translateFromParent(Translatable t); /** * Translates a Translatable that is relative to this figure's bounds to * absolute. * * @param t * The object to translate */ void translateToAbsolute(Translatable t); /** * Translates a Translatable from this IFigure's coordinates to its parent's * coordinates. * * @param t * The object to translate */ void translateToParent(Translatable t); /** * Translates a Translatable in absolute coordinates to be relative to this * figure's bounds. * * @param t * The object to translate */ void translateToRelative(Translatable t); /** * Indicates that this figure should make itself valid. Validation includes * invoking layout on a LayoutManager if present, and then validating all * children figures. Default validation uses pre-order, depth-first * ordering. */ void validate(); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/IImageFigure.java000066400000000000000000000032311166301720600266270ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.graphics.Image; /** * Interface for image figures * *

* WARNING: This interface is not intended to be implemented by clients. Extend * {@link AbstractImageFigure} instead. * * @noimplement * @since 3.6 */ public interface IImageFigure extends IFigure { /** * Returns the SWT Image contained by the figure * * @return the Image contained by the figure * @since 3.6 */ public Image getImage(); /** * Attaches ImageChangedListener to the figure * * @param listener * @since 3.6 */ public void addImageChangedListener(ImageChangedListener listener); /** * Detaches ImageChangedListener from the figure * * @param listener * @since 3.6 */ public void removeImageChangedListener(ImageChangedListener listener); /** * Listener to the image figure to track changes to the containede SWT Image * * @since 3.6 */ public interface ImageChangedListener { /** * Notifies about a change to SWT Image contained by the * IIMageFigure * * @since 3.6 */ public void imageChanged(); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/IScrollableFigure.java000066400000000000000000000016511166301720600276730ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Research Group Software Construction, * RWTH Aachen University, Germany - initial API and implementation */ package org.eclipse.draw2d; /** * Interface to stereotype those figures that contain a ScrollPane with a nested * Viewport. * * @author Philip Ritzkopf * @author Alexander Nyssen * * @since 3.6 */ public interface IScrollableFigure extends IFigure { /** * Provides access to this figure's nested ScrollPane. * * @return the ScrollPane contained within this figure */ ScrollPane getScrollPane(); }eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ImageFigure.java000066400000000000000000000104661166301720600265260ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.graphics.Image; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Insets; import org.eclipse.draw2d.geometry.Rectangle; /** * A Figure that simply contains an Image. Use this Figure, instead of a Label, * when displaying Images without any accompanying text. This figure is not * intended to have a layout mananger or children. *

* Note that it is the client's responsibility to dispose the given image. There * is no "free" resource management in draw2d. * * @author Pratik Shah */ public class ImageFigure extends AbstractImageFigure { private Image img; private Dimension size = new Dimension(); private int alignment; /** * Constructor
* The default alignment is PositionConstants.CENTER. */ public ImageFigure() { this(null, PositionConstants.CENTER); } /** * Constructor
* The default alignment is PositionConstants.CENTER. * * @param image * The Image to be displayed */ public ImageFigure(Image image) { this(image, PositionConstants.CENTER); } /** * Constructor * * @param image * The Image to be displayed * @param alignment * A PositionConstant indicating the alignment * * @see ImageFigure#setImage(Image) * @see ImageFigure#setAlignment(int) */ public ImageFigure(Image image, int alignment) { setImage(image); setAlignment(alignment); } /** * @return The Image that this Figure displays */ public Image getImage() { return img; } /** * Calculates the necessary size to display the Image within the figure's * client area. * * @see org.eclipse.draw2d.Figure#getPreferredSize(int, int) */ public Dimension getPreferredSize(int wHint, int hHint) { if (getInsets() == NO_INSETS) return size; Insets i = getInsets(); return size.getExpanded(i.getWidth(), i.getHeight()); } /** * @see org.eclipse.draw2d.Figure#paintFigure(Graphics) */ protected void paintFigure(Graphics graphics) { super.paintFigure(graphics); if (getImage() == null) return; int x, y; Rectangle area = getBounds().getShrinked(getInsets()); switch (alignment & PositionConstants.NORTH_SOUTH) { case PositionConstants.NORTH: y = area.y; break; case PositionConstants.SOUTH: y = area.y + area.height - size.height; break; default: y = (area.height - size.height) / 2 + area.y; break; } switch (alignment & PositionConstants.EAST_WEST) { case PositionConstants.EAST: x = area.x + area.width - size.width; break; case PositionConstants.WEST: x = area.x; break; default: x = (area.width - size.width) / 2 + area.x; break; } graphics.drawImage(getImage(), x, y); } /** * Sets the alignment of the Image within this Figure. The alignment comes * into play when the ImageFigure is larger than the Image. The alignment * could be any valid combination of the following: * *

    *
  • PositionConstants.NORTH
  • *
  • PositionConstants.SOUTH
  • *
  • PositionConstants.EAST
  • *
  • PositionConstants.WEST
  • *
  • PositionConstants.CENTER or PositionConstants.NONE
  • *
* * @param flag * A constant indicating the alignment */ public void setAlignment(int flag) { alignment = flag; } /** * Sets the Image that this ImageFigure displays. *

* IMPORTANT: Note that it is the client's responsibility to dispose the * given image. * * @param image * The Image to be displayed. It can be null. */ public void setImage(Image image) { if (img == image) return; img = image; if (img != null) size = new Rectangle(image.getBounds()).getSize(); else size = new Dimension(); revalidate(); notifyImageChanged(); repaint(); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ImageUtilities.java000066400000000000000000000147151166301720600272610ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontMetrics; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.graphics.PaletteData; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Display; import org.eclipse.draw2d.geometry.Dimension; /** * @author Pratik Shah * @since 3.0 */ public class ImageUtilities { /** * Returns a new Image with the given String rotated left (by 90 degrees). * The String will be rendered using the provided colors and fonts. The * client is responsible for disposing the returned Image. Strings cannot * contain newline or tab characters. * * @param string * the String to be rendered * @param font * the font * @param foreground * the text's color * @param background * the background color * @return an Image which must be disposed */ public static Image createRotatedImageOfString(String string, Font font, Color foreground, Color background) { Display display = Display.getDefault(); FontMetrics metrics = FigureUtilities.getFontMetrics(font); Dimension strSize = FigureUtilities.getStringExtents(string, font); Image srcImage = new Image(display, strSize.width, metrics.getAscent()); GC gc = new GC(srcImage); gc.setFont(font); gc.setForeground(foreground); gc.setBackground(background); gc.fillRectangle(srcImage.getBounds()); gc.drawString(string, 0, 0 - metrics.getLeading()); Image result = createRotatedImage(srcImage); gc.dispose(); srcImage.dispose(); return result; } /** * Returns a new Image that is the given Image rotated left by 90 degrees. * The client is responsible for disposing the returned Image. * * @param srcImage * the Image that is to be rotated left * @return the rotated Image (the client is responsible for disposing it) */ public static Image createRotatedImage(Image srcImage) { Display display = Display.getDefault(); ImageData srcData = srcImage.getImageData(); ImageData destData; if (srcData.depth < 8) destData = rotatePixelByPixel(srcData); else destData = rotateOptimized(srcData); return new Image(display, destData); } /** * Creates an ImageData representing the given Image shaded * with the given Color. * * @param fromImage * Image that has to be shaded * @param shade * The Color to be used for shading * @return A new ImageData that can be used to create an Image. */ public static ImageData createShadedImage(Image fromImage, Color shade) { org.eclipse.swt.graphics.Rectangle r = fromImage.getBounds(); ImageData data = fromImage.getImageData(); PaletteData palette = data.palette; if (!palette.isDirect) { /* Convert the palette entries */ RGB[] rgbs = palette.getRGBs(); for (int i = 0; i < rgbs.length; i++) { if (data.transparentPixel != i) { RGB color = rgbs[i]; color.red = determineShading(color.red, shade.getRed()); color.blue = determineShading(color.blue, shade.getBlue()); color.green = determineShading(color.green, shade.getGreen()); } } data.palette = new PaletteData(rgbs); } else { /* Convert the pixels. */ int[] scanline = new int[r.width]; int redMask = palette.redMask; int greenMask = palette.greenMask; int blueMask = palette.blueMask; int redShift = palette.redShift; int greenShift = palette.greenShift; int blueShift = palette.blueShift; for (int y = 0; y < r.height; y++) { data.getPixels(0, y, r.width, scanline, 0); for (int x = 0; x < r.width; x++) { int pixel = scanline[x]; int red = pixel & redMask; red = (redShift < 0) ? red >>> -redShift : red << redShift; int green = pixel & greenMask; green = (greenShift < 0) ? green >>> -greenShift : green << greenShift; int blue = pixel & blueMask; blue = (blueShift < 0) ? blue >>> -blueShift : blue << blueShift; red = determineShading(red, shade.getRed()); blue = determineShading(blue, shade.getBlue()); green = determineShading(green, shade.getGreen()); red = (redShift < 0) ? red << -redShift : red >> redShift; red &= redMask; green = (greenShift < 0) ? green << -greenShift : green >> greenShift; green &= greenMask; blue = (blueShift < 0) ? blue << -blueShift : blue >> blueShift; blue &= blueMask; scanline[x] = red | blue | green; } data.setPixels(0, y, r.width, scanline, 0); } } return data; } private static int determineShading(int origColor, int shadeColor) { return (origColor + shadeColor) / 2; } private static ImageData rotateOptimized(ImageData srcData) { int bytesPerPixel = Math.max(1, srcData.depth / 8); int destBytesPerLine = ((srcData.height * bytesPerPixel - 1) / srcData.scanlinePad + 1) * srcData.scanlinePad; byte[] newData = new byte[destBytesPerLine * srcData.width]; for (int srcY = 0; srcY < srcData.height; srcY++) { for (int srcX = 0; srcX < srcData.width; srcX++) { int destX = srcY; int destY = srcData.width - srcX - 1; int destIndex = (destY * destBytesPerLine) + (destX * bytesPerPixel); int srcIndex = (srcY * srcData.bytesPerLine) + (srcX * bytesPerPixel); System.arraycopy(srcData.data, srcIndex, newData, destIndex, bytesPerPixel); } } return new ImageData(srcData.height, srcData.width, srcData.depth, srcData.palette, srcData.scanlinePad, newData); } private static ImageData rotatePixelByPixel(ImageData srcData) { ImageData destData = new ImageData(srcData.height, srcData.width, srcData.depth, srcData.palette); for (int y = 0; y < srcData.height; y++) { for (int x = 0; x < srcData.width; x++) { destData.setPixel(y, srcData.width - x - 1, srcData.getPixel(x, y)); } } return destData; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/InputEvent.java000066400000000000000000000054551166301720600264450ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.SWT; /** * The base class for Draw2d events. */ public abstract class InputEvent extends java.util.EventObject { private int state; private boolean consumed = false; /** * @deprecated Use {@link SWT#ALT} instead. */ public static final int ALT = SWT.ALT; /** * @deprecated Use {@link SWT#CONTROL} instead. */ public static final int CONTROL = SWT.CONTROL; /** * @deprecated Use {@link SWT#SHIFT} instead. */ public static final int SHIFT = SWT.SHIFT; /** * @deprecated Use {@link SWT#BUTTON1} instead. */ public static final int BUTTON1 = SWT.BUTTON1; /** * @deprecated Use {@link SWT#BUTTON2} instead. */ public static final int BUTTON2 = SWT.BUTTON2; /** * @deprecated Use {@link SWT#BUTTON3} instead. */ public static final int BUTTON3 = SWT.BUTTON3; /** * @deprecated Use {@link SWT#BUTTON4} instead. */ public static final int BUTTON4 = SWT.BUTTON4; /** * @deprecated Use {@link SWT#BUTTON5} instead. */ public static final int BUTTON5 = SWT.BUTTON5; /** * A bitwise OR'ing of {@link #BUTTON1}, {@link #BUTTON2}, {@link #BUTTON3}, * {@link #BUTTON4} and {@link #BUTTON5} * * @deprecated Use {@link SWT#BUTTON_MASK} instead. */ public static final int ANY_BUTTON = SWT.BUTTON_MASK; /** * Constructs a new InputEvent. * * @param dispatcher * the event dispatcher * @param source * the source of the event * @param state * the state of the keyboard modifier and mouse button mask. * * @see org.eclipse.swt.SWT#MODIFIER_MASK * @see org.eclipse.swt.SWT#BUTTON_MASK */ public InputEvent(EventDispatcher dispatcher, IFigure source, int state) { super(source); this.state = state; } /** * Marks this event as consumed so that it doesn't get passed on to other * listeners. */ public void consume() { consumed = true; } /** * Returns the event state mask, which is a bitwise OR'ing of the keyboard * modifier and the mouse button mask. * * @see org.eclipse.swt.SWT#MODIFIER_MASK * @see org.eclipse.swt.SWT#BUTTON_MASK * * @return the state */ public int getState() { return state; } /** * @return whether this event has been consumed. */ public boolean isConsumed() { return consumed; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/KeyEvent.java000066400000000000000000000025571166301720600260760ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; /** * An event caused by the user interacting with the keyboard. */ public class KeyEvent extends InputEvent { /** * The character that was pressed. * * @see org.eclipse.swt.events.KeyEvent#character */ public char character; /** * The keycode. * * @see org.eclipse.swt.events.KeyEvent#keyCode */ public int keycode; /** * Constructs a new KeyEvent. * * @param dispatcher * the event dispatcher * @param source * the source of the event * @param ke * an SWT key event used to supply the statemask, keycode and * character */ public KeyEvent(EventDispatcher dispatcher, IFigure source, org.eclipse.swt.events.KeyEvent ke) { super(dispatcher, source, ke.stateMask); character = ke.character; keycode = ke.keyCode; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/KeyListener.java000066400000000000000000000024401166301720600265710ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; /** * A listener interface for receiving {@link KeyEvent KeyEvents} from the * keyboard. */ public interface KeyListener { /** * Called when a key is pressed. * * @param ke * The KeyEvent object */ void keyPressed(KeyEvent ke); /** * Called when a key is released. * * @param ke * The KeyEvent object */ void keyReleased(KeyEvent ke); /** * An empty implementation of KeyListener for convenience. */ class Stub implements KeyListener { /** * @see org.eclipse.draw2d.KeyListener#keyPressed(KeyEvent) */ public void keyPressed(KeyEvent ke) { } /** * @see org.eclipse.draw2d.KeyListener#keyReleased(KeyEvent) */ public void keyReleased(KeyEvent ke) { } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/Label.java000066400000000000000000000437361166301720600253670ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Image; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Insets; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; /** * A figure that can display text and/or an image. */ public class Label extends Figure implements PositionConstants { private static String ELLIPSIS = "..."; //$NON-NLS-1$ private Image icon; private String text = "";//$NON-NLS-1$ private String subStringText; private Dimension textSize; private Dimension subStringTextSize; private Dimension iconSize = new Dimension(0, 0); private Point iconLocation; private Point textLocation; private int textAlignment = CENTER; private int iconAlignment = CENTER; private int labelAlignment = CENTER; private int textPlacement = EAST; private int iconTextGap = 3; /** * Construct an empty Label. * * @since 2.0 */ public Label() { } /** * Construct a Label with passed String as its text. * * @param s * the label text * @since 2.0 */ public Label(String s) { setText(s); } /** * Construct a Label with passed Image as its icon. * * @param i * the label image * @since 2.0 */ public Label(Image i) { setIcon(i); } /** * Construct a Label with passed String as text and passed Image as its * icon. * * @param s * the label text * @param i * the label image * @since 2.0 */ public Label(String s, Image i) { setText(s); setIcon(i); } private void alignOnHeight(Point loc, Dimension size, int alignment) { Insets insets = getInsets(); switch (alignment) { case TOP: loc.y = insets.top; break; case BOTTOM: loc.y = bounds.height - size.height - insets.bottom; break; default: loc.y = (bounds.height - size.height) / 2; } } private void alignOnWidth(Point loc, Dimension size, int alignment) { Insets insets = getInsets(); switch (alignment) { case LEFT: loc.x = insets.left; break; case RIGHT: loc.x = bounds.width - size.width - insets.right; break; default: loc.x = (bounds.width - size.width) / 2; } } private void calculateAlignment() { switch (textPlacement) { case EAST: case WEST: alignOnHeight(textLocation, getTextSize(), textAlignment); alignOnHeight(iconLocation, getIconSize(), iconAlignment); break; case NORTH: case SOUTH: alignOnWidth(textLocation, getSubStringTextSize(), textAlignment); alignOnWidth(iconLocation, getIconSize(), iconAlignment); break; } } /** * Calculates the size of the Label using the passed Dimension as the size * of the Label's text. * * @param txtSize * the precalculated size of the label's text * @return the label's size * @since 2.0 */ protected Dimension calculateLabelSize(Dimension txtSize) { int gap = getIconTextGap(); if (getIcon() == null || getText().equals("")) //$NON-NLS-1$ gap = 0; Dimension d = new Dimension(0, 0); if (textPlacement == WEST || textPlacement == EAST) { d.width = getIconSize().width + gap + txtSize.width; d.height = Math.max(getIconSize().height, txtSize.height); } else { d.width = Math.max(getIconSize().width, txtSize.width); d.height = getIconSize().height + gap + txtSize.height; } return d; } private void calculateLocations() { textLocation = new Point(); iconLocation = new Point(); calculatePlacement(); calculateAlignment(); Dimension offset = getSize().getDifference(getPreferredSize()); offset.width += getTextSize().width - getSubStringTextSize().width; switch (labelAlignment) { case CENTER: offset.scale(0.5f); break; case LEFT: offset.scale(0.0f); break; case RIGHT: offset.scale(1.0f); break; case TOP: offset.height = 0; offset.scale(0.5f); break; case BOTTOM: offset.height = offset.height * 2; offset.scale(0.5f); break; default: offset.scale(0.5f); break; } switch (textPlacement) { case EAST: case WEST: offset.height = 0; break; case NORTH: case SOUTH: offset.width = 0; break; } textLocation.translate(offset); iconLocation.translate(offset); } private void calculatePlacement() { int gap = getIconTextGap(); if (icon == null || text.equals("")) //$NON-NLS-1$ gap = 0; Insets insets = getInsets(); switch (textPlacement) { case EAST: iconLocation.x = insets.left; textLocation.x = getIconSize().width + gap + insets.left; break; case WEST: textLocation.x = insets.left; iconLocation.x = getSubStringTextSize().width + gap + insets.left; break; case NORTH: textLocation.y = insets.top; iconLocation.y = getTextSize().height + gap + insets.top; break; case SOUTH: textLocation.y = getIconSize().height + gap + insets.top; iconLocation.y = insets.top; } } /** * Calculates the size of the Label's text size. The text size calculated * takes into consideration if the Label's text is currently truncated. If * text size without considering current truncation is desired, use * {@link #calculateTextSize()}. * * @return the size of the label's text, taking into account truncation * @since 2.0 */ protected Dimension calculateSubStringTextSize() { return getTextUtilities().getTextExtents(getSubStringText(), getFont()); } /** * Calculates and returns the size of the Label's text. Note that this * Dimension is calculated using the Label's full text, regardless of * whether or not its text is currently truncated. If text size considering * current truncation is desired, use {@link #calculateSubStringTextSize()}. * * @return the size of the label's text, ignoring truncation * @since 2.0 */ protected Dimension calculateTextSize() { return getTextUtilities().getTextExtents(getText(), getFont()); } private void clearLocations() { iconLocation = textLocation = null; } /** * Returns the Label's icon. * * @return the label icon * @since 2.0 */ public Image getIcon() { return icon; } /** * Returns the current alignment of the Label's icon. The default is * {@link PositionConstants#CENTER}. * * @return the icon alignment * @since 2.0 */ public int getIconAlignment() { return iconAlignment; } /** * Returns the bounds of the Label's icon. * * @return the icon's bounds * @since 2.0 */ public Rectangle getIconBounds() { Rectangle bounds = getBounds(); return new Rectangle(bounds.getLocation().translate(getIconLocation()), getIconSize()); } /** * Returns the location of the Label's icon relative to the Label. * * @return the icon's location * @since 2.0 */ protected Point getIconLocation() { if (iconLocation == null) calculateLocations(); return iconLocation; } /** * Returns the gap in pixels between the Label's icon and its text. * * @return the gap * @since 2.0 */ public int getIconTextGap() { return iconTextGap; } /** * @see IFigure#getMinimumSize(int, int) */ public Dimension getMinimumSize(int w, int h) { if (minSize != null) return minSize; minSize = new Dimension(); if (getLayoutManager() != null) minSize.setSize(getLayoutManager().getMinimumSize(this, w, h)); Dimension labelSize = calculateLabelSize(getTextUtilities() .getTextExtents(getTruncationString(), getFont()) .intersect( getTextUtilities().getTextExtents(getText(), getFont()))); Insets insets = getInsets(); labelSize.expand(insets.getWidth(), insets.getHeight()); minSize.union(labelSize); return minSize; } /** * @see IFigure#getPreferredSize(int, int) */ public Dimension getPreferredSize(int wHint, int hHint) { if (prefSize == null) { prefSize = calculateLabelSize(getTextSize()); Insets insets = getInsets(); prefSize.expand(insets.getWidth(), insets.getHeight()); if (getLayoutManager() != null) prefSize.union(getLayoutManager().getPreferredSize(this, wHint, hHint)); } if (wHint >= 0 && wHint < prefSize.width) { Dimension minSize = getMinimumSize(wHint, hHint); Dimension result = prefSize.getCopy(); result.width = Math.min(result.width, wHint); result.width = Math.max(minSize.width, result.width); return result; } return prefSize; } /** * Calculates the amount of the Label's current text will fit in the Label, * including an elipsis "..." if truncation is required. * * @return the substring * @since 2.0 */ public String getSubStringText() { if (subStringText != null) return subStringText; subStringText = text; int widthShrink = getPreferredSize().width - getSize().width; if (widthShrink <= 0) return subStringText; Dimension effectiveSize = getTextSize().getExpanded(-widthShrink, 0); Font currentFont = getFont(); int dotsWidth = getTextUtilities().getTextExtents( getTruncationString(), currentFont).width; if (effectiveSize.width < dotsWidth) effectiveSize.width = dotsWidth; int subStringLength = getTextUtilities().getLargestSubstringConfinedTo( text, currentFont, effectiveSize.width - dotsWidth); subStringText = new String(text.substring(0, subStringLength) + getTruncationString()); return subStringText; } /** * Returns the size of the Label's current text. If the text is currently * truncated, the truncated text with its ellipsis is used to calculate the * size. * * @return the size of this label's text, taking into account truncation * @since 2.0 */ protected Dimension getSubStringTextSize() { if (subStringTextSize == null) subStringTextSize = calculateSubStringTextSize(); return subStringTextSize; } /** * Returns the text of the label. Note that this is the complete text of the * label, regardless of whether it is currently being truncated. Call * {@link #getSubStringText()} to return the label's current text contents * with truncation considered. * * @return the complete text of this label * @since 2.0 */ public String getText() { return text; } /** * Returns the current alignment of the Label's text. The default text * alignment is {@link PositionConstants#CENTER}. * * @return the text alignment */ public int getTextAlignment() { return textAlignment; } /** * Returns the bounds of the label's text. Note that the bounds are * calculated using the label's complete text regardless of whether the * label's text is currently truncated. * * @return the bounds of this label's complete text * @since 2.0 */ public Rectangle getTextBounds() { Rectangle bounds = getBounds(); return new Rectangle(bounds.getLocation().translate(getTextLocation()), textSize); } /** * Returns the location of the label's text relative to the label. * * @return the text location * @since 2.0 */ protected Point getTextLocation() { if (textLocation != null) return textLocation; calculateLocations(); return textLocation; } /** * Returns the current placement of the label's text relative to its icon. * The default text placement is {@link PositionConstants#EAST}. * * @return the text placement * @since 2.0 */ public int getTextPlacement() { return textPlacement; } /** * Returns the size of the label's complete text. Note that the text used to * make this calculation is the label's full text, regardless of whether the * label's text is currently being truncated and is displaying an ellipsis. * If the size considering current truncation is desired, call * {@link #getSubStringTextSize()}. * * @return the size of this label's complete text * @since 2.0 */ protected Dimension getTextSize() { if (textSize == null) textSize = calculateTextSize(); return textSize; } /** * @see IFigure#invalidate() */ public void invalidate() { prefSize = null; minSize = null; clearLocations(); textSize = null; subStringTextSize = null; subStringText = null; super.invalidate(); } /** * Returns true if the label's text is currently truncated and * is displaying an ellipsis, false otherwise. * * @return true if the label's text is truncated * @since 2.0 */ public boolean isTextTruncated() { return !getSubStringText().equals(getText()); } /** * @see Figure#paintFigure(Graphics) */ protected void paintFigure(Graphics graphics) { if (isOpaque()) super.paintFigure(graphics); Rectangle bounds = getBounds(); graphics.translate(bounds.x, bounds.y); if (icon != null) graphics.drawImage(icon, getIconLocation()); if (!isEnabled()) { graphics.translate(1, 1); graphics.setForegroundColor(ColorConstants.buttonLightest); graphics.drawText(getSubStringText(), getTextLocation()); graphics.translate(-1, -1); graphics.setForegroundColor(ColorConstants.buttonDarker); } graphics.drawText(getSubStringText(), getTextLocation()); graphics.translate(-bounds.x, -bounds.y); } /** * Sets the label's icon to the passed image. * * @param image * the new label image * @since 2.0 */ public void setIcon(Image image) { if (icon == image) return; icon = image; // Call repaint, in case the image dimensions are the same. repaint(); if (icon == null) setIconDimension(new Dimension()); else setIconDimension(new Dimension(image)); } /** * This method sets the alignment of the icon within the bounds of the * label. If the label is larger than the icon, then the icon will be * aligned according to this alignment. Valid values are: *

    *
  • {@link PositionConstants#CENTER} *
  • {@link PositionConstants#TOP} *
  • {@link PositionConstants#BOTTOM} *
  • {@link PositionConstants#LEFT} *
  • {@link PositionConstants#RIGHT} *
* * @param align * the icon alignment * @since 2.0 */ public void setIconAlignment(int align) { if (iconAlignment == align) return; iconAlignment = align; clearLocations(); repaint(); } /** * Sets the label's icon size to the passed Dimension. * * @param d * the new icon size * @deprecated the icon is automatically displayed at 1:1 * @since 2.0 */ public void setIconDimension(Dimension d) { if (d.equals(getIconSize())) return; iconSize = d; revalidate(); } /** * Sets the gap in pixels between the label's icon and text to the passed * value. The default is 4. * * @param gap * the gap * @since 2.0 */ public void setIconTextGap(int gap) { if (iconTextGap == gap) return; iconTextGap = gap; repaint(); revalidate(); } /** * Sets the alignment of the label (icon and text) within the figure. If * this figure's bounds are larger than the size needed to display the * label, the label will be aligned accordingly. Valid values are: *
    *
  • {@link PositionConstants#CENTER} *
  • {@link PositionConstants#TOP} *
  • {@link PositionConstants#BOTTOM} *
  • {@link PositionConstants#LEFT} *
  • {@link PositionConstants#RIGHT} *
* * @param align * label alignment */ public void setLabelAlignment(int align) { if (labelAlignment == align) return; labelAlignment = align; clearLocations(); repaint(); } /** * Sets the label's text. * * @param s * the new label text * @since 2.0 */ public void setText(String s) { // "text" will never be null. if (s == null) s = "";//$NON-NLS-1$ if (text.equals(s)) return; text = s; revalidate(); repaint(); } /** * Sets the alignment of the text relative to the icon within the label. The * text alignment must be orthogonal to the text placement. For example, if * the placement is EAST, then the text can be aligned using TOP, CENTER, or * BOTTOM. Valid values are: *
    *
  • {@link PositionConstants#CENTER} *
  • {@link PositionConstants#TOP} *
  • {@link PositionConstants#BOTTOM} *
  • {@link PositionConstants#LEFT} *
  • {@link PositionConstants#RIGHT} *
* * @see #setLabelAlignment(int) * @param align * the text alignment * @since 2.0 */ public void setTextAlignment(int align) { if (textAlignment == align) return; textAlignment = align; clearLocations(); repaint(); } /** * Sets the placement of the text relative to the icon within the label. * Valid values are: *
    *
  • {@link PositionConstants#EAST} *
  • {@link PositionConstants#NORTH} *
  • {@link PositionConstants#SOUTH} *
  • {@link PositionConstants#WEST} *
* * @param where * the text placement * @since 2.0 */ public void setTextPlacement(int where) { if (textPlacement == where) return; textPlacement = where; revalidate(); repaint(); } /** * Gets the TextUtilities instance to be used in measurement * calculations. * * @return a TextUtilities instance * @since 3.4 */ public TextUtilities getTextUtilities() { return TextUtilities.INSTANCE; } /** * Gets the string that will be appended to the text when the label is * truncated. By default, this returns an ellipsis. * * @return the string to append to the text when truncated * @since 3.4 */ protected String getTruncationString() { return ELLIPSIS; } /** * Gets the icon size * * @return the icon size * @since 3.4 */ protected Dimension getIconSize() { return iconSize; } /** * Returns the alignment of the entire label (icon and text). The default * label alignment is {@link PositionConstants#CENTER}. * * @return the label alignment * @since 3.5 */ public int getLabelAlignment() { return labelAlignment; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/LabelAnchor.java000066400000000000000000000027221166301720600265100ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Rectangle; /** * LabelAnchors must have an owner of type {@link Label}. The LabelAnchor * behaves like {@link ChopboxAnchor} but {@link Connection Connections} will * point to the center of its owner's icon as opposed to the center of the * entire owning Label. */ public class LabelAnchor extends ChopboxAnchor { /** * Constructs a LabelAnchor with no owner. * * @since 2.0 */ protected LabelAnchor() { } /** * Constructs a LabelAnchor with owner label. * * @param label * This LabelAnchor's owner * @since 2.0 */ public LabelAnchor(Label label) { super(label); } /** * Returns the bounds of this LabelAnchor's owning Label icon. * * @return The bounds of this LabelAnchor's owning Label icon * @since 2.0 */ protected Rectangle getBox() { Label label = (Label) getOwner(); return label.getIconBounds(); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/LabeledBorder.java000066400000000000000000000024651166301720600270300ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.graphics.Font; /** * LabeledBorders have a text message somewhere on them. The Font for the text * can be set. LabeledBorders should not change their Insets when the label * changes, therefore, Figures using this Border should repaint() when updating * the label, and revalidate() when changing the Font. */ public interface LabeledBorder extends Border { /** * Returns the label for this Border. * * @return The label for this Border */ String getLabel(); /** * Sets the Font for the label. * * @param f * The Font to be set */ void setFont(Font f); /** * Sets the text to be displayed as the label for this Border. * * @param l * The text */ void setLabel(String l); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/LabeledContainer.java000066400000000000000000000045561166301720600275400ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.graphics.Font; /** * A Container with a title bar describing the contents of the container. The * frame is generated by a {@link LabeledBorder}. */ public class LabeledContainer extends Figure { /** * Constructs a default container with a {@link GroupBoxBorder}. * * @since 2.0 */ public LabeledContainer() { this(new GroupBoxBorder()); } /** * Constructs a labeled container with the border given as input. * * @param border * the border * @since 2.0 */ public LabeledContainer(Border border) { setBorder(border); setOpaque(true); } private static LabeledBorder findLabeledBorder(Border border) { if (border instanceof LabeledBorder) return (LabeledBorder) border; if (border instanceof CompoundBorder) { CompoundBorder cb = (CompoundBorder) border; LabeledBorder labeled = findLabeledBorder(cb.getInnerBorder()); if (labeled == null) labeled = findLabeledBorder(cb.getOuterBorder()); return labeled; } return null; } /** * Returns the text of the LabeledContainer's label. * * @return the label text * @since 2.0 */ public String getLabel() { return getLabeledBorder().getLabel(); } /** * Returns the LabeledBorder of this container. * * @return the border * @since 2.0 */ protected LabeledBorder getLabeledBorder() { return findLabeledBorder(getBorder()); } /** * Sets the title of the container. * * @param s * the new title text * @since 2.0 */ public void setLabel(String s) { getLabeledBorder().setLabel(s); revalidate(); repaint(); } /** * Sets the font to be used for the container title. * * @param f * the new font * @since 2.0 */ public void setLabelFont(Font f) { getLabeledBorder().setFont(f); revalidate(); repaint(); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/Layer.java000066400000000000000000000031731166301720600254130ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Point; /** * A transparent figure intended to be added exclusively to a * {@link LayeredPane}, who has the responsibilty of managing its layers. */ public class Layer extends Figure { /** * Overridden to implement transparent behavior. * * @see IFigure#containsPoint(int, int) * */ public boolean containsPoint(int x, int y) { if (isOpaque()) return super.containsPoint(x, y); Point pt = Point.SINGLETON; pt.setLocation(x, y); translateFromParent(pt); x = pt.x; y = pt.y; for (int i = 0; i < getChildren().size(); i++) { IFigure child = (IFigure) getChildren().get(i); if (child.containsPoint(x, y)) return true; } return false; } /** * Overridden to implement transparency. * * @see IFigure#findFigureAt(int, int, TreeSearch) */ public IFigure findFigureAt(int x, int y, TreeSearch search) { if (!isEnabled()) return null; if (isOpaque()) return super.findFigureAt(x, y, search); IFigure f = super.findFigureAt(x, y, search); if (f == this) return null; return f; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/LayeredPane.java000066400000000000000000000102541166301720600265260ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.ArrayList; import java.util.List; /** * A figure capable of holding any number of layers. Only layers can be added to * this figure. Layers are added to this figure with thier respective keys, * which are used to identify them. */ public class LayeredPane extends Layer { private List layerKeys = new ArrayList(); /** * Constructs a new layered pane with no layers in it. */ public LayeredPane() { setLayoutManager(new StackLayout()); } /** * Adds the given layer figure, identifiable with the given key, at the * specified index. While adding the layer, it informs the surrounding * layers of the addition. * * @param figure * the layer * @param layerKey * the layer's key * @param index * the index where the layer should be added * @since 2.0 */ public void add(IFigure figure, Object layerKey, int index) { if (index == -1) index = layerKeys.size(); super.add(figure, null, index); layerKeys.add(index, layerKey); } /** * Adds the given layer, identifiable with the given key, under the * after layer provided in the input. * * @param layer * the layer * @param key * the layer's key * @param after * the layer under which the input layer should be added * @since 2.0 */ public void addLayerAfter(Layer layer, Object key, Object after) { int index = layerKeys.indexOf(after); add(layer, key, ++index); } /** * Adds the given layer, identifiable with the given key, above the * before layer provided in the input. * * @param layer * the layer * @param key * the layer's key * @param before * the layer above which the input layer should be added * @since 2.0 */ public void addLayerBefore(Layer layer, Object key, Object before) { int index = layerKeys.indexOf(before); add(layer, key, index); } /** * Returns the layer identified by the key given in the input. * * @param key * the key to identify the desired layer * @return the desired layer * @since 2.0 */ public Layer getLayer(Object key) { int index = layerKeys.indexOf(key); if (index == -1) return null; return (Layer) getChildren().get(index); } /** * Returns the layer at the specified index in this pane. * * @param index * the index of the desired layer * @return the desired layer * @since 2.0 */ protected Layer getLayer(int index) { return (Layer) getChildren().get(index); } /** * @see org.eclipse.draw2d.IFigure#remove(org.eclipse.draw2d.IFigure) */ public void remove(IFigure figure) { int index = getChildren().indexOf(figure); if (index != -1) layerKeys.remove(index); super.remove(figure); } /** * Removes the layer identified by the given key from this layered pane. * * @param key * the key of the layer to be removed * @since 2.0 */ public void removeLayer(Object key) { removeLayer(layerKeys.indexOf(key)); } /** * Removes the given layer from this layered pane. * * @deprecated call {@link IFigure#remove(IFigure)} instead * @param layer * the layer to be removed * @since 2.0 */ public void removeLayer(IFigure layer) { remove(layer); } /** * Removes the layer at the specified index from the list of layers in this * layered pane. It collapses the layers, occupying the space vacated by the * removed layer. * * @param index * the index of the layer to be removed * @since 2.0 */ protected void removeLayer(int index) { Layer removeLayer = getLayer(index); remove(removeLayer); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/LayoutAnimator.java000066400000000000000000000114321166301720600273040ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2005, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.HashMap; import java.util.List; import java.util.Map; import org.eclipse.draw2d.geometry.Rectangle; /** * Animates the layout of a figure's children. The animator will capture the * effects of a layout manager, and then play back the placement of children * using linear interpolation for each child's start and end locations. *

* To use an animator, hook it as a layout listener for the figure whose layout * is to be animated, by calling * {@link IFigure#addLayoutListener(LayoutListener)}. It is not necessary to * have an animator for every figure in a composition that is undergoing * animation. For example, if a figure without an animator moves during the * animation, it will continue to move and layout its children normally during * each step of the animation. *

* Animator must be used in conjunction with layouts. If figures are placed * manually using setBounds(), the animator may not be able to * track and playback the changes that occur. * * @since 3.2 */ public class LayoutAnimator extends Animator implements LayoutListener { static final LayoutAnimator INSTANCE = new LayoutAnimator(); /** * Constructs a new Animator. The default instance ({@link #getDefault()}) * can be used on all figures being animated. * * @since 3.2 */ protected LayoutAnimator() { } /** * Returns an object encapsulating the placement of children in a container. * This method is called to capture both the initial and final states. * * @param container * the container figure * @return the current state * @since 3.2 */ protected Object getCurrentState(IFigure container) { Map locations = new HashMap(); List children = container.getChildren(); IFigure child; for (int i = 0; i < children.size(); i++) { child = (IFigure) children.get(i); locations.put(child, child.getBounds().getCopy()); } return locations; } /** * Returns the default instance. * * @return the default instance * @since 3.2 */ public static LayoutAnimator getDefault() { return INSTANCE; } /** * Hooks invalidation in case animation is in progress. * * @see LayoutListener#invalidate(IFigure) */ public final void invalidate(IFigure container) { if (Animation.isInitialRecording()) Animation.hookAnimator(container, this); } /** * Hooks layout in case animation is in progress. * * @see org.eclipse.draw2d.LayoutListener#layout(org.eclipse.draw2d.IFigure) */ public final boolean layout(IFigure container) { if (Animation.isAnimating()) return Animation.hookPlayback(container, this); return false; } /** * Plays back the animated layout. * * @see Animator#playback(IFigure) */ protected boolean playback(IFigure container) { Map initial = (Map) Animation.getInitialState(this, container); Map ending = (Map) Animation.getFinalState(this, container); if (initial == null) return false; List children = container.getChildren(); float progress = Animation.getProgress(); float ssergorp = 1 - progress; Rectangle rect1, rect2; for (int i = 0; i < children.size(); i++) { IFigure child = (IFigure) children.get(i); rect1 = (Rectangle) initial.get(child); rect2 = (Rectangle) ending.get(child); // TODO need to change this to hide the figure until the end. if (rect1 == null) continue; child.setBounds(new Rectangle(Math.round(progress * rect2.x + ssergorp * rect1.x), Math.round(progress * rect2.y + ssergorp * rect1.y), Math.round(progress * rect2.width + ssergorp * rect1.width), Math.round(progress * rect2.height + ssergorp * rect1.height))); } return true; } /** * Hooks post layout in case animation is in progress. * * @see LayoutListener#postLayout(IFigure) */ public final void postLayout(IFigure container) { if (Animation.isFinalRecording()) Animation.hookNeedsCapture(container, this); } /** * This callback is unused. Reserved for possible future use. * * @see LayoutListener#remove(IFigure) */ public final void remove(IFigure child) { } /** * This callback is unused. Reserved for possible future use. * * @see LayoutListener#setConstraint(IFigure, Object) */ public final void setConstraint(IFigure child, Object constraint) { } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/LayoutListener.java000066400000000000000000000061071166301720600273220ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; /** * Classes which implement this interface provide callback hooks for various * layout related events. *

* Instances can be hooked to figures by calling * {@link IFigure#addLayoutListener(LayoutListener)}. Listeners will be made * aware of various steps of the layout mechanism, and even have the opportunity * to prevent normal layout from occurring. * * @since 3.1 */ public interface LayoutListener { /** * A stub implementation which implements all of the declared methods. * * @since 3.1 */ class Stub implements LayoutListener { /** * Stub which does nothing. * * @see LayoutListener#invalidate(IFigure) */ public void invalidate(IFigure container) { } /** * Stub which does nothing. * * @see LayoutListener#layout(IFigure) */ public boolean layout(IFigure container) { return false; } /** * Stub which does nothing. * * @see LayoutListener#postLayout(IFigure) */ public void postLayout(IFigure container) { } /** * Stub which does nothing. * * @see LayoutListener#remove(IFigure) */ public void remove(IFigure child) { } /** * Stub which does nothing. * * @see LayoutListener#setConstraint(IFigure, java.lang.Object) */ public void setConstraint(IFigure child, Object constraint) { } } /** * Called when a container has been invalidated. * * @param container * the invalidated Figure * @since 3.1 */ void invalidate(IFigure container); /** * Called prior to layout occurring. A listener may intercept a layout by * returning true. If the layout is intercepted, the * container's LayoutManager will not receive a layout call. * * @param container * the figure incurring a layout * @return true if the layout has been intercepted by the * listener * @since 3.1 */ boolean layout(IFigure container); /** * Called after layout has occurred. * * @since 3.1 * @param container * the figure incurring a layout */ void postLayout(IFigure container); /** * Called when a child is about to be removed from its parent. * * @since 3.1 * @param child * the child being removed */ void remove(IFigure child); /** * Called when a child's constraint is initialized or updated. * * @param child * the child being updated * @param constraint * the child's new constraint * @since 3.1 */ void setConstraint(IFigure child, Object constraint); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/LayoutManager.java000066400000000000000000000043531166301720600271100ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Dimension; /** * A helper for positioning child figures and determining the ideal size for a * figure with children. */ public interface LayoutManager { /** * Returns the constraint for the given figure. * * @param child * The figure * @return The constraint */ Object getConstraint(IFigure child); /** * Returns the minimum size of the given figure. * * @param container * The Figure * @param wHint * the width hint * @param hHint * the height hint * @return The minimum size */ Dimension getMinimumSize(IFigure container, int wHint, int hHint); /** * Returns the preferred size of the given figure, using width and height * hints. * * @param container * The figure * @param wHint * The width hint * @param hHint * The height hint * @return The preferred size */ Dimension getPreferredSize(IFigure container, int wHint, int hHint); /** * Tells the LayoutManager to throw away all cached information about the * figures it is responsible for. This method is called whenever the owning * figure is invalidated. */ void invalidate(); /** * Lays out the given figure. * * @param container * The figure */ void layout(IFigure container); /** * Removes the given child from this layout. * * @param child * the child being remoced */ void remove(IFigure child); /** * Sets the constraint for the given child. * * @param child * The figure * @param constraint * The constraint */ void setConstraint(IFigure child, Object constraint); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/LightweightSystem.java000066400000000000000000000370211166301720600300220ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.SWT; import org.eclipse.swt.accessibility.AccessibleControlEvent; import org.eclipse.swt.accessibility.AccessibleControlListener; import org.eclipse.swt.accessibility.AccessibleEvent; import org.eclipse.swt.accessibility.AccessibleListener; import org.eclipse.swt.events.ControlAdapter; import org.eclipse.swt.events.ControlEvent; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.FocusListener; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseListener; import org.eclipse.swt.events.MouseMoveListener; import org.eclipse.swt.events.MouseTrackListener; import org.eclipse.swt.events.TraverseEvent; import org.eclipse.swt.events.TraverseListener; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.draw2d.geometry.Rectangle; /** * The LightweightSystem is the link between SWT and Draw2d. It is the component * that provides the ability for {@link Figure Figures} to be hosted on an SWT * Canvas. *

* Normal procedure for using a LightweightSystem: *

    *
  1. Create an SWT Canvas. *
  2. Create a LightweightSystem passing it that Canvas. *
  3. Create a Draw2d Figure and call setContents(IFigure). This Figure will be * the top-level Figure of the Draw2d application. *
*/ public class LightweightSystem { private Canvas canvas; IFigure contents; private IFigure root; private EventDispatcher dispatcher; private UpdateManager manager = new DeferredUpdateManager(); private int ignoreResize; /** * Constructs a LightweightSystem on Canvas c. * * @param c * the canvas * @since 2.0 */ public LightweightSystem(Canvas c) { this(); setControl(c); } /** * Constructs a LightweightSystem without a Canvas. */ public LightweightSystem() { init(); } /** * Adds SWT listeners to the LightWeightSystem's Canvas. This allows for SWT * events to be dispatched and handled by its {@link EventDispatcher}. *

* WARNING: This method should not be overridden. * * @since 2.0 */ protected void addListeners() { EventHandler handler = createEventHandler(); canvas.getAccessible().addAccessibleListener(handler); canvas.getAccessible().addAccessibleControlListener(handler); canvas.addMouseListener(handler); canvas.addMouseMoveListener(handler); canvas.addMouseTrackListener(handler); canvas.addKeyListener(handler); canvas.addTraverseListener(handler); canvas.addFocusListener(handler); canvas.addDisposeListener(handler); canvas.addListener(SWT.MouseWheel, handler); canvas.addControlListener(new ControlAdapter() { public void controlResized(ControlEvent e) { LightweightSystem.this.controlResized(); } }); canvas.addListener(SWT.Paint, new Listener() { public void handleEvent(Event e) { LightweightSystem.this.paint(e.gc); } }); } /** * Resizes and revalidates the root figure when the control is resized. */ protected void controlResized() { if (ignoreResize > 0) return; Rectangle r = new Rectangle(canvas.getClientArea()); r.setLocation(0, 0); root.setBounds(r); root.revalidate(); getUpdateManager().performUpdate(); } /** * Returns this LightwightSystem's EventDispatcher. * * @return the event dispatcher * @since 2.0 */ protected EventDispatcher getEventDispatcher() { if (dispatcher == null) setEventDispatcher(new SWTEventDispatcher()); return dispatcher; } /** * Returns this LightweightSystem's root figure. * * @return the root figure * @since 2.0 */ public IFigure getRootFigure() { return root; } /** * Returns a new instance of this LightweightSystem's EventHandler. * * @return the newly created event handler * @since 2.0 */ protected final EventHandler createEventHandler() { return internalCreateEventHandler(); } /** * Creates and returns the root figure. * * @return the newly created root figure */ protected RootFigure createRootFigure() { RootFigure f = new RootFigure(); f.addNotify(); f.setOpaque(true); f.setLayoutManager(new StackLayout()); return f; } /** * Returns this LightweightSystem's UpdateManager. * * @return the update manager * @since 2.0 */ public UpdateManager getUpdateManager() { return manager; } /** * Initializes this LightweightSystem by setting the root figure. */ protected void init() { setRootPaneFigure(createRootFigure()); } EventHandler internalCreateEventHandler() { return new EventHandler(); } /** * Invokes this LightweightSystem's {@link UpdateManager} to paint this * LightweightSystem's Canvas and contents. * * @param gc * the GC used for painting * @since 2.0 */ public void paint(GC gc) { getUpdateManager().paint(gc); } /** * Sets the contents of the LightweightSystem to the passed figure. This * figure should be the top-level Figure in a Draw2d application. * * @param figure * the new root figure * @since 2.0 */ public void setContents(IFigure figure) { if (contents != null) root.remove(contents); contents = figure; root.add(contents); } /** * Sets the LightweightSystem's control to the passed Canvas. * * @param c * the canvas * @since 2.0 */ public void setControl(Canvas c) { if (canvas == c) return; canvas = c; if ((c.getStyle() & SWT.DOUBLE_BUFFERED) != 0) getUpdateManager().setGraphicsSource( new NativeGraphicsSource(canvas)); else getUpdateManager().setGraphicsSource( new BufferedGraphicsSource(canvas)); getEventDispatcher().setControl(c); addListeners(); // Size the root figure and contents to the current control's size Rectangle r = new Rectangle(canvas.getClientArea()); r.setLocation(0, 0); root.setBounds(r); root.revalidate(); } /** * Sets this LightweightSystem's EventDispatcher. * * @param dispatcher * the new event dispatcher * @since 2.0 */ public void setEventDispatcher(EventDispatcher dispatcher) { this.dispatcher = dispatcher; dispatcher.setRoot(root); dispatcher.setControl(canvas); } void setIgnoreResize(boolean value) { if (value) ignoreResize++; else ignoreResize--; } /** * Sets this LightweightSystem's root figure. * * @param root * the new root figure */ protected void setRootPaneFigure(RootFigure root) { getUpdateManager().setRoot(root); this.root = root; } /** * Sets this LightweightSystem's UpdateManager. * * @param um * the new update manager * @since 2.0 */ public void setUpdateManager(UpdateManager um) { manager = um; manager.setRoot(root); } /** * The figure at the root of the LightweightSystem. If certain properties * (i.e. font, background/foreground color) are not set, the RootFigure will * obtain these properties from LightweightSystem's Canvas. */ protected class RootFigure extends Figure { /** @see IFigure#getBackgroundColor() */ public Color getBackgroundColor() { if (bgColor != null) return bgColor; if (canvas != null) return canvas.getBackground(); return null; } /** @see IFigure#getFont() */ public Font getFont() { if (font != null) return font; if (canvas != null) return canvas.getFont(); return null; } /** @see IFigure#getForegroundColor() */ public Color getForegroundColor() { if (fgColor != null) return fgColor; if (canvas != null) return canvas.getForeground(); return null; } /** @see IFigure#getUpdateManager() */ public UpdateManager getUpdateManager() { return LightweightSystem.this.getUpdateManager(); } /** @see IFigure#internalGetEventDispatcher() */ public EventDispatcher internalGetEventDispatcher() { return getEventDispatcher(); } /** * @see IFigure#isMirrored() */ public boolean isMirrored() { return (LightweightSystem.this.canvas.getStyle() & SWT.MIRRORED) != 0; } /** @see Figure#isShowing() */ public boolean isShowing() { return true; } } /** * Listener used to get all necessary events from the Canvas and pass them * on to the {@link EventDispatcher}. */ protected class EventHandler implements MouseMoveListener, MouseListener, AccessibleControlListener, KeyListener, TraverseListener, FocusListener, AccessibleListener, MouseTrackListener, Listener, DisposeListener { /** @see FocusListener#focusGained(FocusEvent) */ public void focusGained(FocusEvent e) { getEventDispatcher().dispatchFocusGained(e); } /** @see FocusListener#focusLost(FocusEvent) */ public void focusLost(FocusEvent e) { getEventDispatcher().dispatchFocusLost(e); } /** @see AccessibleControlListener#getChild(AccessibleControlEvent) */ public void getChild(AccessibleControlEvent e) { EventDispatcher.AccessibilityDispatcher ad; ad = getEventDispatcher().getAccessibilityDispatcher(); if (ad != null) ad.getChild(e); } /** @see AccessibleControlListener#getChildAtPoint(AccessibleControlEvent) */ public void getChildAtPoint(AccessibleControlEvent e) { EventDispatcher.AccessibilityDispatcher ad; ad = getEventDispatcher().getAccessibilityDispatcher(); if (ad != null) ad.getChildAtPoint(e); } /** @see AccessibleControlListener#getChildCount(AccessibleControlEvent) */ public void getChildCount(AccessibleControlEvent e) { EventDispatcher.AccessibilityDispatcher ad; ad = getEventDispatcher().getAccessibilityDispatcher(); if (ad != null) ad.getChildCount(e); } /** @see AccessibleControlListener#getChildren(AccessibleControlEvent) */ public void getChildren(AccessibleControlEvent e) { EventDispatcher.AccessibilityDispatcher ad; ad = getEventDispatcher().getAccessibilityDispatcher(); if (ad != null) ad.getChildren(e); } /** @see AccessibleControlListener#getDefaultAction(AccessibleControlEvent) */ public void getDefaultAction(AccessibleControlEvent e) { EventDispatcher.AccessibilityDispatcher ad; ad = getEventDispatcher().getAccessibilityDispatcher(); if (ad != null) ad.getDefaultAction(e); } /** @see AccessibleListener#getDescription(AccessibleEvent) */ public void getDescription(AccessibleEvent e) { EventDispatcher.AccessibilityDispatcher ad; ad = getEventDispatcher().getAccessibilityDispatcher(); if (ad != null) ad.getDescription(e); } /** @see AccessibleControlListener#getFocus(AccessibleControlEvent) */ public void getFocus(AccessibleControlEvent e) { EventDispatcher.AccessibilityDispatcher ad; ad = getEventDispatcher().getAccessibilityDispatcher(); if (ad != null) ad.getFocus(e); } /** @see AccessibleListener#getHelp(AccessibleEvent) */ public void getHelp(AccessibleEvent e) { EventDispatcher.AccessibilityDispatcher ad; ad = getEventDispatcher().getAccessibilityDispatcher(); if (ad != null) ad.getHelp(e); } /** @see AccessibleListener#getKeyboardShortcut(AccessibleEvent) */ public void getKeyboardShortcut(AccessibleEvent e) { EventDispatcher.AccessibilityDispatcher ad; ad = getEventDispatcher().getAccessibilityDispatcher(); if (ad != null) ad.getKeyboardShortcut(e); } /** @see AccessibleControlListener#getLocation(AccessibleControlEvent) */ public void getLocation(AccessibleControlEvent e) { EventDispatcher.AccessibilityDispatcher ad; ad = getEventDispatcher().getAccessibilityDispatcher(); if (ad != null) ad.getLocation(e); } /** @see AccessibleListener#getName(AccessibleEvent) */ public void getName(AccessibleEvent e) { EventDispatcher.AccessibilityDispatcher ad; ad = getEventDispatcher().getAccessibilityDispatcher(); if (ad != null) ad.getName(e); } /** @see AccessibleControlListener#getRole(AccessibleControlEvent) */ public void getRole(AccessibleControlEvent e) { EventDispatcher.AccessibilityDispatcher ad; ad = getEventDispatcher().getAccessibilityDispatcher(); if (ad != null) ad.getRole(e); } /** @see AccessibleControlListener#getSelection(AccessibleControlEvent) */ public void getSelection(AccessibleControlEvent e) { EventDispatcher.AccessibilityDispatcher ad; ad = getEventDispatcher().getAccessibilityDispatcher(); if (ad != null) ad.getSelection(e); } /** @see AccessibleControlListener#getState(AccessibleControlEvent) */ public void getState(AccessibleControlEvent e) { EventDispatcher.AccessibilityDispatcher ad; ad = getEventDispatcher().getAccessibilityDispatcher(); if (ad != null) ad.getState(e); } /** @see AccessibleControlListener#getValue(AccessibleControlEvent) */ public void getValue(AccessibleControlEvent e) { EventDispatcher.AccessibilityDispatcher ad; ad = getEventDispatcher().getAccessibilityDispatcher(); if (ad != null) ad.getValue(e); } /** * @see Listener#handleEvent(org.eclipse.swt.widgets.Event) * @since 3.1 */ public void handleEvent(Event event) { // Mouse wheel events if (event.type == SWT.MouseWheel) getEventDispatcher().dispatchMouseWheelScrolled(event); } /** @see KeyListener#keyPressed(KeyEvent) */ public void keyPressed(KeyEvent e) { getEventDispatcher().dispatchKeyPressed(e); } /** @see KeyListener#keyReleased(KeyEvent) */ public void keyReleased(KeyEvent e) { getEventDispatcher().dispatchKeyReleased(e); } /** @see TraverseListener#keyTraversed(TraverseEvent) */ public void keyTraversed(TraverseEvent e) { /* * Doit is almost always false by default for Canvases with * KeyListeners. Set to true to allow normal behavior. For example, * in Dialogs ESC should close. */ e.doit = true; getEventDispatcher().dispatchKeyTraversed(e); } /** @see MouseListener#mouseDoubleClick(MouseEvent) */ public void mouseDoubleClick(MouseEvent e) { getEventDispatcher().dispatchMouseDoubleClicked(e); } /** @see MouseListener#mouseDown(MouseEvent) */ public void mouseDown(MouseEvent e) { getEventDispatcher().dispatchMousePressed(e); } /** @see MouseTrackListener#mouseEnter(MouseEvent) */ public void mouseEnter(MouseEvent e) { getEventDispatcher().dispatchMouseEntered(e); } /** @see MouseTrackListener#mouseExit(MouseEvent) */ public void mouseExit(MouseEvent e) { getEventDispatcher().dispatchMouseExited(e); } /** @see MouseTrackListener#mouseHover(MouseEvent) */ public void mouseHover(MouseEvent e) { getEventDispatcher().dispatchMouseHover(e); } /** @see MouseMoveListener#mouseMove(MouseEvent) */ public void mouseMove(MouseEvent e) { getEventDispatcher().dispatchMouseMoved(e); } /** @see MouseListener#mouseUp(MouseEvent) */ public void mouseUp(MouseEvent e) { getEventDispatcher().dispatchMouseReleased(e); } /** @see DisposeListener#widgetDisposed(DisposeEvent) */ public void widgetDisposed(DisposeEvent e) { getUpdateManager().dispose(); } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/LineBorder.java000066400000000000000000000104761166301720600263700ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.graphics.Color; import org.eclipse.draw2d.geometry.Insets; /** * Provides for a line border with sides of equal widths. */ public class LineBorder extends AbstractBorder { private int width = 1; private Color color; private int style = Graphics.LINE_SOLID; /** * Constructs a LineBorder with the specified color and of the specified * width and style. * * @param color * The color of the border. * @param width * The width of the border in pixels. * @param style * The style of the border. For the list of valid values, see * {@link org.eclipse.draw2d.Graphics} * @since 3.5 */ public LineBorder(Color color, int width, int style) { setColor(color); setWidth(width); setStyle(style); } /** * Constructs a LineBorder with the specified color and of the specified * width. * * @param color * The color of the border. * @param width * The width of the border in pixels. * @since 2.0 */ public LineBorder(Color color, int width) { this(color, width, Graphics.LINE_SOLID); } /** * Constructs a LineBorder with the specified color and a width of 1 pixel. * * @param color * The color of the border. * @since 2.0 */ public LineBorder(Color color) { this(color, 1); } /** * Constructs a black LineBorder with the specified width. * * @param width * The width of the border in pixels. * @since 2.0 */ public LineBorder(int width) { this(null, width); } /** * Constructs a default black LineBorder with a width of one pixel. * * @since 2.0 */ public LineBorder() { } /** * Returns the line color of this border. * * @return The line color of this border */ public Color getColor() { return color; } /** * Returns the space used by the border for the figure provided as input. In * this border all sides always have equal width. * * @param figure * The figure this border belongs to * @return This border's insets */ public Insets getInsets(IFigure figure) { return new Insets(getWidth()); } /** * Returns the line width of this border. * * @return The line width of this border */ public int getWidth() { return width; } /** * Returns true since this border is opaque. Being opaque it is * responsible to fill in the area within its boundaries. * * @return true since this border is opaque */ public boolean isOpaque() { return true; } /** * @see org.eclipse.draw2d.Border#paint(IFigure, Graphics, Insets) */ public void paint(IFigure figure, Graphics graphics, Insets insets) { tempRect.setBounds(getPaintRectangle(figure, insets)); if (getWidth() % 2 == 1) { tempRect.width--; tempRect.height--; } tempRect.shrink(getWidth() / 2, getWidth() / 2); graphics.setLineWidth(getWidth()); graphics.setLineStyle(getStyle()); if (getColor() != null) graphics.setForegroundColor(getColor()); graphics.drawRectangle(tempRect); } /** * Sets the line color for this border. * * @param color * The line color */ public void setColor(Color color) { this.color = color; } /** * Sets the line width for this border. * * @param width * The line width */ public void setWidth(int width) { if (width > 0) { this.width = width; } } /** * Returns the line style for this border. * * @return The line style for this border * @since 3.5 */ public int getStyle() { return style; } /** * Sets the line type of this border. * * @param style * For the list of valid values, see * {@link org.eclipse.draw2d.Graphics} * @since 3.5 */ public void setStyle(int style) { this.style = style; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/Locator.java000066400000000000000000000014211166301720600257340ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; /** * Controls the location of an IFigure. */ public interface Locator { /** * Relocates the given IFigure. * * @param target * The figure to relocate */ void relocate(IFigure target); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ManhattanConnectionRouter.java000066400000000000000000000226371166301720600315010ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.PointList; import org.eclipse.draw2d.geometry.Ray; import org.eclipse.draw2d.geometry.Rectangle; /** * Provides a {@link Connection} with an orthogonal route between the * Connection's source and target anchors. */ public final class ManhattanConnectionRouter extends AbstractRouter { private Map rowsUsed = new HashMap(); private Map colsUsed = new HashMap(); // private Hashtable offsets = new Hashtable(7); private Map reservedInfo = new HashMap(); private class ReservedInfo { public List reservedRows = new ArrayList(2); public List reservedCols = new ArrayList(2); } private static Ray UP = new Ray(0, -1), DOWN = new Ray(0, 1), LEFT = new Ray(-1, 0), RIGHT = new Ray(1, 0); /** * @see ConnectionRouter#invalidate(Connection) */ public void invalidate(Connection connection) { removeReservedLines(connection); } private int getColumnNear(Connection connection, int r, int n, int x) { int min = Math.min(n, x), max = Math.max(n, x); if (min > r) { max = min; min = r - (min - r); } if (max < r) { min = max; max = r + (r - max); } int proximity = 0; int direction = -1; if (r % 2 == 1) r--; Integer i; while (proximity < r) { i = new Integer(r + proximity * direction); if (!colsUsed.containsKey(i)) { colsUsed.put(i, i); reserveColumn(connection, i); return i.intValue(); } int j = i.intValue(); if (j <= min) return j + 2; if (j >= max) return j - 2; if (direction == 1) direction = -1; else { direction = 1; proximity += 2; } } return r; } /** * Returns the direction the point p is in relation to the given * rectangle. Possible values are LEFT (-1,0), RIGHT (1,0), UP (0,-1) and * DOWN (0,1). * * @param r * the rectangle * @param p * the point * @return the direction from r to p */ protected Ray getDirection(Rectangle r, Point p) { int i, distance = Math.abs(r.x - p.x); Ray direction; direction = LEFT; i = Math.abs(r.y - p.y); if (i <= distance) { distance = i; direction = UP; } i = Math.abs(r.bottom() - p.y); if (i <= distance) { distance = i; direction = DOWN; } i = Math.abs(r.right() - p.x); if (i < distance) { distance = i; direction = RIGHT; } return direction; } protected Ray getEndDirection(Connection conn) { ConnectionAnchor anchor = conn.getTargetAnchor(); Point p = getEndPoint(conn); Rectangle rect; if (anchor.getOwner() == null) rect = new Rectangle(p.x - 1, p.y - 1, 2, 2); else { rect = conn.getTargetAnchor().getOwner().getBounds().getCopy(); conn.getTargetAnchor().getOwner().translateToAbsolute(rect); } return getDirection(rect, p); } protected int getRowNear(Connection connection, int r, int n, int x) { int min = Math.min(n, x), max = Math.max(n, x); if (min > r) { max = min; min = r - (min - r); } if (max < r) { min = max; max = r + (r - max); } int proximity = 0; int direction = -1; if (r % 2 == 1) r--; Integer i; while (proximity < r) { i = new Integer(r + proximity * direction); if (!rowsUsed.containsKey(i)) { rowsUsed.put(i, i); reserveRow(connection, i); return i.intValue(); } int j = i.intValue(); if (j <= min) return j + 2; if (j >= max) return j - 2; if (direction == 1) direction = -1; else { direction = 1; proximity += 2; } } return r; } protected Ray getStartDirection(Connection conn) { ConnectionAnchor anchor = conn.getSourceAnchor(); Point p = getStartPoint(conn); Rectangle rect; if (anchor.getOwner() == null) rect = new Rectangle(p.x - 1, p.y - 1, 2, 2); else { rect = conn.getSourceAnchor().getOwner().getBounds().getCopy(); conn.getSourceAnchor().getOwner().translateToAbsolute(rect); } return getDirection(rect, p); } protected void processPositions(Ray start, Ray end, List positions, boolean horizontal, Connection conn) { removeReservedLines(conn); int pos[] = new int[positions.size() + 2]; if (horizontal) pos[0] = start.x; else pos[0] = start.y; int i; for (i = 0; i < positions.size(); i++) { pos[i + 1] = ((Integer) positions.get(i)).intValue(); } if (horizontal == (positions.size() % 2 == 1)) pos[++i] = end.x; else pos[++i] = end.y; PointList points = new PointList(); points.addPoint(new Point(start.x, start.y)); Point p; int current, prev, min, max; boolean adjust; for (i = 2; i < pos.length - 1; i++) { horizontal = !horizontal; prev = pos[i - 1]; current = pos[i]; adjust = (i != pos.length - 2); if (horizontal) { if (adjust) { min = pos[i - 2]; max = pos[i + 2]; pos[i] = current = getRowNear(conn, current, min, max); } p = new Point(prev, current); } else { if (adjust) { min = pos[i - 2]; max = pos[i + 2]; pos[i] = current = getColumnNear(conn, current, min, max); } p = new Point(current, prev); } points.addPoint(p); } points.addPoint(new Point(end.x, end.y)); conn.setPoints(points); } /** * @see ConnectionRouter#remove(Connection) */ public void remove(Connection connection) { removeReservedLines(connection); } protected void removeReservedLines(Connection connection) { ReservedInfo rInfo = (ReservedInfo) reservedInfo.get(connection); if (rInfo == null) return; for (int i = 0; i < rInfo.reservedRows.size(); i++) { rowsUsed.remove(rInfo.reservedRows.get(i)); } for (int i = 0; i < rInfo.reservedCols.size(); i++) { colsUsed.remove(rInfo.reservedCols.get(i)); } reservedInfo.remove(connection); } protected void reserveColumn(Connection connection, Integer column) { ReservedInfo info = (ReservedInfo) reservedInfo.get(connection); if (info == null) { info = new ReservedInfo(); reservedInfo.put(connection, info); } info.reservedCols.add(column); } protected void reserveRow(Connection connection, Integer row) { ReservedInfo info = (ReservedInfo) reservedInfo.get(connection); if (info == null) { info = new ReservedInfo(); reservedInfo.put(connection, info); } info.reservedRows.add(row); } /** * @see ConnectionRouter#route(Connection) */ public void route(Connection conn) { if ((conn.getSourceAnchor() == null) || (conn.getTargetAnchor() == null)) return; int i; Point startPoint = getStartPoint(conn); conn.translateToRelative(startPoint); Point endPoint = getEndPoint(conn); conn.translateToRelative(endPoint); Ray start = new Ray(startPoint); Ray end = new Ray(endPoint); Ray average = start.getAveraged(end); Ray direction = new Ray(start, end); Ray startNormal = getStartDirection(conn); Ray endNormal = getEndDirection(conn); List positions = new ArrayList(5); boolean horizontal = startNormal.isHorizontal(); if (horizontal) positions.add(new Integer(start.y)); else positions.add(new Integer(start.x)); horizontal = !horizontal; if (startNormal.dotProduct(endNormal) == 0) { if ((startNormal.dotProduct(direction) >= 0) && (endNormal.dotProduct(direction) <= 0)) { // 0 } else { // 2 if (startNormal.dotProduct(direction) < 0) i = startNormal.similarity(start.getAdded(startNormal .getScaled(10))); else { if (horizontal) i = average.y; else i = average.x; } positions.add(new Integer(i)); horizontal = !horizontal; if (endNormal.dotProduct(direction) > 0) i = endNormal.similarity(end.getAdded(endNormal .getScaled(10))); else { if (horizontal) i = average.y; else i = average.x; } positions.add(new Integer(i)); horizontal = !horizontal; } } else { if (startNormal.dotProduct(endNormal) > 0) { // 1 if (startNormal.dotProduct(direction) >= 0) i = startNormal.similarity(start.getAdded(startNormal .getScaled(10))); else i = endNormal.similarity(end.getAdded(endNormal .getScaled(10))); positions.add(new Integer(i)); horizontal = !horizontal; } else { // 3 or 1 if (startNormal.dotProduct(direction) < 0) { i = startNormal.similarity(start.getAdded(startNormal .getScaled(10))); positions.add(new Integer(i)); horizontal = !horizontal; } if (horizontal) i = average.y; else i = average.x; positions.add(new Integer(i)); horizontal = !horizontal; if (startNormal.dotProduct(direction) < 0) { i = endNormal.similarity(end.getAdded(endNormal .getScaled(10))); positions.add(new Integer(i)); horizontal = !horizontal; } } } if (horizontal) positions.add(new Integer(end.y)); else positions.add(new Integer(end.x)); processPositions(start, end, positions, startNormal.isHorizontal(), conn); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/MarginBorder.java000066400000000000000000000036531166301720600267150ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Insets; /** * A border that provides blank padding. */ public class MarginBorder extends AbstractBorder { /** * This border's insets. */ protected Insets insets; /** * Constructs a MarginBorder with dimensions specified by insets. * * @param insets * The Insets for the border * @since 2.0 */ public MarginBorder(Insets insets) { this.insets = insets; } /** * Constructs a MarginBorder with padding specified by the passed values. * * @param t * Top padding * @param l * Left padding * @param b * Bottom padding * @param r * Right padding * @since 2.0 */ public MarginBorder(int t, int l, int b, int r) { this(new Insets(t, l, b, r)); } /** * Constructs a MarginBorder with equal padding on all sides. * * @param allsides * Padding size for all sides of the border. * @since 2.0 */ public MarginBorder(int allsides) { this(new Insets(allsides)); } /** * @see org.eclipse.draw2d.Border#getInsets(IFigure) */ public Insets getInsets(IFigure figure) { return insets; } /** * This method does nothing, since this border is just for spacing. * * @see org.eclipse.draw2d.Border#paint(IFigure, Graphics, Insets) */ public void paint(IFigure figure, Graphics graphics, Insets insets) { } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/MidpointLocator.java000066400000000000000000000042351166301720600274460ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Point; /** * A ConnectionLocator that is used to place figures at the midpoint between two * points on a {@link org.eclipse.draw2d.Connection}. */ public class MidpointLocator extends ConnectionLocator { private int index; /** * Constructs a MidpointLocator with associated Connection c and * index i. The points at index i and i+1 on the connection are used * to calculate the midpoint of the line segment. * * @param c * the connection associated with the locator * @param i * the point from where the connection's midpoint will be * calculated. * @since 2.0 */ public MidpointLocator(Connection c, int i) { super(c); index = i; } /** * Returns this MidpointLocator's index. This integer represents the * position of the start point in this MidpointLocator's associated * {@link Connection} from where midpoint calculation will be made. * * @return the locator's index * @since 2.0 */ protected int getIndex() { return index; } /** * Returns the point of reference associated with this locator. This point * will be midway between points at 'index' and 'index' + 1. * * @return the reference point * @since 2.0 */ protected Point getReferencePoint() { Connection conn = getConnection(); Point p = Point.SINGLETON; Point p1 = conn.getPoints().getPoint(getIndex()); Point p2 = conn.getPoints().getPoint(getIndex() + 1); conn.translateToAbsolute(p1); conn.translateToAbsolute(p2); p.x = (p2.x - p1.x) / 2 + p1.x; p.y = (p2.y - p1.y) / 2 + p1.y; return p; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/MouseEvent.java000066400000000000000000000045311166301720600264300ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Point; /** * An event caused by the user interacting with the mouse. */ public class MouseEvent extends InputEvent { /** The X coordinate of the mouse event. */ public int x; /** The Y coordinate of the mouse event. */ public int y; /** The button that was pressed or released: {1, 2, 3}. */ public int button; /** * Constructs a new MouseEvent. * * @param dispatcher * the event dispatcher * @param source * the source of the event * @param me * an SWT mouse event used to supply the state mask, button and * position * @since 3.7 */ public MouseEvent(EventDispatcher dispatcher, IFigure source, org.eclipse.swt.events.MouseEvent me) { super(dispatcher, source, me.stateMask); this.button = me.button; Point pt = Point.SINGLETON; pt.setLocation(me.x, me.y); source.translateToRelative(pt); this.x = pt.x; this.y = pt.y; } /** * Constructor for MouseEvent. * * @param x * @param y * @param dispatcher * @param f * @param button * @param stateMask * @since 3.6 * @deprecated Use * {@link #MouseEvent(EventDispatcher, IFigure, org.eclipse.swt.events.MouseEvent)} * instead. */ public MouseEvent(int x, int y, EventDispatcher dispatcher, IFigure f, int button, int stateMask) { super(dispatcher, f, stateMask); Point pt = Point.SINGLETON; pt.setLocation(x, y); f.translateToRelative(pt); this.button = button; this.x = pt.x; this.y = pt.y; } /** * @return the location of this mouse event */ public Point getLocation() { return new Point(x, y); } /** * @see Object#toString() */ public String toString() { return "MouseEvent(" + x + ',' + y + ") to Figure: " + source;//$NON-NLS-2$//$NON-NLS-1$ } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/MouseListener.java000066400000000000000000000033151166301720600271330ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; /** * A listener interface for receiving mouse button events. */ public interface MouseListener { /** * Called when a mouse button has been pressed while over the listened to * object. * * @param me * The MouseEvent object */ void mousePressed(MouseEvent me); /** * Called when a pressed mouse button has been released. * * @param me * The MouseEvent object */ void mouseReleased(MouseEvent me); /** * Called when a mouse button has been double clicked over the listened to * object. * * @param me * The MouseEvent object */ void mouseDoubleClicked(MouseEvent me); /** * An empty implementation of MouseListener for convenience. */ public class Stub implements MouseListener { /** * @see org.eclipse.draw2d.MouseListener#mousePressed(MouseEvent) */ public void mousePressed(MouseEvent me) { } /** * @see org.eclipse.draw2d.MouseListener#mouseReleased(MouseEvent) */ public void mouseReleased(MouseEvent me) { } /** * @see org.eclipse.draw2d.MouseListener#mouseDoubleClicked(MouseEvent) */ public void mouseDoubleClicked(MouseEvent me) { } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/MouseMotionListener.java000066400000000000000000000044301166301720600303200ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; /** * A listener interface for receiving mouse motion events. */ public interface MouseMotionListener { /** * Called when the mouse has moved over the listened to object while a * button was pressed. * * @param me * The MouseEvent object */ void mouseDragged(MouseEvent me); /** * Called when the mouse has entered the listened to object. * * @param me * The MouseEvent object */ void mouseEntered(MouseEvent me); /** * Called when the mouse has exited the listened to object. * * @param me * The MouseEvent object */ void mouseExited(MouseEvent me); /** * Called when the mouse hovers over the listened to object. * * @param me * The MouseEvent object */ void mouseHover(MouseEvent me); /** * Called when the mouse has moved over the listened to object. * * @param me * The MouseEvent object */ void mouseMoved(MouseEvent me); /** * An empty implementation of MouseMotionListener for convenience. */ public class Stub implements MouseMotionListener { /** * @see org.eclipse.draw2d.MouseMotionListener#mouseDragged(MouseEvent) */ public void mouseDragged(MouseEvent me) { } /** * @see org.eclipse.draw2d.MouseMotionListener#mouseEntered(MouseEvent) */ public void mouseEntered(MouseEvent me) { } /** * @see org.eclipse.draw2d.MouseMotionListener#mouseExited(MouseEvent) */ public void mouseExited(MouseEvent me) { } /** * @see org.eclipse.draw2d.MouseMotionListener#mouseMoved(MouseEvent) */ public void mouseMoved(MouseEvent me) { } /** * @see org.eclipse.draw2d.MouseMotionListener#mouseHover(MouseEvent) */ public void mouseHover(MouseEvent me) { } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/NativeGraphicsSource.java000066400000000000000000000031261166301720600304250ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2005, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.widgets.Control; import org.eclipse.draw2d.geometry.Rectangle; /** * A graphics source that posts a paint request to the control rather than * constructing GC on it directly. This allows the OS's native painting * mechanism to be used directly, including any double-buffering that the OS may * provide for free. * * @since 3.2 */ public final class NativeGraphicsSource implements GraphicsSource { private final Control canvas; /** * Constructs a new graphics source on the given control. * * @param canvas * the control * @since 3.2 */ public NativeGraphicsSource(Control canvas) { this.canvas = canvas; } /** * Always returns null, because * * @see GraphicsSource#getGraphics(Rectangle) */ public Graphics getGraphics(Rectangle r) { canvas.redraw(r.x, r.y, r.width, r.height, false); canvas.update(); return null; } /** * Does nothing. * * @see GraphicsSource#flushGraphics(Rectangle) */ public void flushGraphics(Rectangle region) { } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/OrderedLayout.java000066400000000000000000000130321166301720600271140ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Transposer; /** * Abstract superclass for layout managers that arrange their children in * columns/rows. * * @since 3.7 */ public abstract class OrderedLayout extends AbstractHintLayout { /** Constant to specify components to be aligned in the center */ public static final int ALIGN_CENTER = 0; /** Constant to specify components to be aligned on the left/top */ public static final int ALIGN_TOPLEFT = 1; /** Constant to specify components to be aligned on the right/bottom */ public static final int ALIGN_BOTTOMRIGHT = 2; /** * Constant to specify components should be layed out horizontally * * @deprecated Pulled up from derived layout manager and deprecated here * because unused. */ public static final boolean HORIZONTAL = true; /** * Constant to specify components should be layed out vertically * * @deprecated Pulled up from derived layout manager and deprecated here * because unused. */ public static final boolean VERTICAL = false; /** * The horizontal property. * * @deprecated Use {@link #setHorizontal(boolean)} and * {@link #isHorizontal()} instead. */ protected boolean horizontal; /** * The alignment along the minor axis. * * @deprecated Use {@link #getMinorAlignment()} and * {@link #setMinorAlignment(int)} instead. */ protected int minorAlignment; /** * Transposer object that may be used in layout calculations. Will be * automatically enabled/disabled dependent on the default and the actual * orientation. * * @noreference This field is not intended to be referenced by clients. */ protected Transposer transposer = new Transposer(); /** * Constructs a new {@link OrderedLayout} with the default orientation and a * minor alignment of {@link #ALIGN_TOPLEFT}. */ public OrderedLayout() { setHorizontal(getDefaultOrientation() == PositionConstants.HORIZONTAL); setMinorAlignment(ALIGN_TOPLEFT); } /** * Returns the default orientation of this layout. * * @return one of {@link PositionConstants#HORIZONTAL} or * {@link PositionConstants#VERTICAL} */ protected abstract int getDefaultOrientation(); /** * Returns the minor alignment of the layout. Minor minor axis is the axis * perpendicular to the overall orientation set in the constructor. * * @return the minor alignment */ public int getMinorAlignment() { return minorAlignment; } /** * Returns true if the orientation of the layout is horizontal. * * @return true if the orientation of the layout is horizontal */ public boolean isHorizontal() { return horizontal; } /** * Returns whether figures should obtain the same height/width in the minor * axis. * * @return whether children are to be stretched in the minor axis. * * @TODO: Made abstract here, so that derived layout managers can guarantee * backwards compatibility for their exposed fields. Can be made * concrete in the next major release, removing implementations in * the derived layout managers. */ public abstract boolean isStretchMinorAxis(); /** * Sets the orientation of the layout. * * @param flag * true if this layout should be horizontal, * false otherwise. */ public void setHorizontal(boolean flag) { if (horizontal == flag) return; invalidate(); horizontal = flag; updateTransposerEnabledState(); } /** * Sets the alignment of the children contained in the layout. Possible * values are {@link #ALIGN_CENTER}, {@link #ALIGN_BOTTOMRIGHT} and * {@link #ALIGN_TOPLEFT}. * * @param align * the minor alignment */ public void setMinorAlignment(int align) { minorAlignment = align; } /** * Causes children that are smaller in the dimension of the minor axis to be * stretched to fill the minor axis. The minor axis is the opposite of the * orientation. That is, in horizontal orientation, all figures will have * the same height. If in vertical orientation, all figures will have the * same width. * * @param value * whether children should be stretched in the minor axis. * @TODO: Made abstract here, so that derived layout managers can guarantee * backwards compatibility for their exposed fields. Can be made * concrete in the next major release, removing implementations in * the derived layout managers. */ public abstract void setStretchMinorAxis(boolean value); /** * Updates the enabled state of the {@link #transposer} in case the layout * has a different orientation that its default one. */ private void updateTransposerEnabledState() { // enable transposer if the current orientation differs from the default // orientation, disable it otherwise transposer.setEnabled(isHorizontal() && getDefaultOrientation() == PositionConstants.VERTICAL || !isHorizontal() && getDefaultOrientation() == PositionConstants.HORIZONTAL); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/Orientable.java000066400000000000000000000024671166301720600264300ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; /** * An interface for objects that can be either horizontally or vertically * oriented. */ public interface Orientable extends PositionConstants, IFigure { /** * A constant representing a horizontal orientation. */ int HORIZONTAL = 0; /** * A constant representing a vertical orientation. */ int VERTICAL = 1; /** * Sets the orientation. Can be either {@link #HORIZONTAL} or * {@link #VERTICAL}. * * @param orientation * The orientation */ void setOrientation(int orientation); /** * Sets the direction the orientable figure will face. Can be one of many * directional constants defined in {@link PositionConstants}. * * @param direction * The direction */ void setDirection(int direction); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/Panel.java000066400000000000000000000022421166301720600253720ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; /** * A General purpose Container. This figure is opaque by default, and will fill * its entire bounds with either the background color that is set on the figure, * or the IGraphics current background color if none has been set. Opaque * figures help to optimize painting. *

* Note that the paintFigure() method in the superclass Figure actually fills * the bounds of this figure. */ public class Panel extends Figure { /** * Returns true as this is an opaque figure. * * @return the opaque state of this figure * @since 2.0 */ public boolean isOpaque() { return true; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/Polygon.java000066400000000000000000000035721166301720600257710ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation * Alex Selkov - Fix for Bug# 22701 * Alexander Shatalin (Borland) - Contribution for Bug 238874 *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Geometry; /** * Renders a {@link org.eclipse.draw2d.geometry.PointList} as a polygonal shape. * This class is similar to Polyline, except the PointList is closed and can be * filled in as a solid shape. * * @see Polyline */ public class Polygon extends Polyline { /** * Returns whether the point (x,y) is contained inside this polygon. * * @param x * the X coordinate * @param y * the Y coordinate * @return whether the point (x,y) is contained in this polygon */ public boolean containsPoint(int x, int y) { if (!getBounds().contains(x, y)) return false; return shapeContainsPoint(x, y) || childrenContainsPoint(x, y); } protected boolean shapeContainsPoint(int x, int y) { return Geometry.polygonContainsPoint(points, x, y); } /** * Fill the Polygon with the background color set by g. * * @param g * the Graphics object * @since 2.0 */ protected void fillShape(Graphics g) { g.fillPolygon(getPoints()); } /** * Draw the outline of the Polygon. * * @param g * the Graphics object * @since 2.0 */ protected void outlineShape(Graphics g) { g.drawPolygon(getPoints()); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/PolygonDecoration.java000066400000000000000000000100441166301720600277710ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.graphics.Color; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.PointList; import org.eclipse.draw2d.geometry.Transform; /** * A rotatable, polygon shaped decoration most commonly used for decorating the * ends of {@link org.eclipse.draw2d.Polyline polylines}. */ public class PolygonDecoration extends Polygon implements RotatableDecoration { /** * Template for a triangle that points to the right when the rotation angle * is 0 */ public static final PointList TRIANGLE_TIP = new PointList(); /** * Template for a triangle that points to the left when the rotation angle * is 0 */ public static final PointList INVERTED_TRIANGLE_TIP = new PointList(); static { TRIANGLE_TIP.addPoint(0, 0); TRIANGLE_TIP.addPoint(-1, 1); TRIANGLE_TIP.addPoint(-1, -1); INVERTED_TRIANGLE_TIP.addPoint(0, 1); INVERTED_TRIANGLE_TIP.addPoint(0, -1); INVERTED_TRIANGLE_TIP.addPoint(-1, 0); } private Point location = new Point(); private PointList template = TRIANGLE_TIP; private Transform transform = new Transform(); /** * Constructs a PolygonDecoration. Defaults the PolygonDecoration to fill * its region with black. * * @since 2.0 */ public PolygonDecoration() { setFill(true); setScale(7, 3); } /** * @see org.eclipse.draw2d.IFigure#getBackgroundColor() */ public Color getLocalBackgroundColor() { if (super.getLocalBackgroundColor() == null) return getForegroundColor(); return super.getLocalBackgroundColor(); } /** * Returns the points in the PolygonDecoration as a PointList. * * @return the points in this PolygonDecoration * @since 2.0 */ public PointList getPoints() { if (points == null) { points = new PointList(); for (int i = 0; i < template.size(); i++) points.addPoint(transform.getTransformed(template.getPoint(i))); } return points; } /** * Sets the location of this PolygonDecoration. * * @param p * the new location */ public void setLocation(Point p) { points = null; bounds = null; location.setLocation(p); transform.setTranslation(p.x, p.y); } /** * Sets the PolygonDecorations point template to the passed PointList. This * template is an outline of the PolygonDecoration's region. (The default * value is TRIANGLE_TIP which is a triangle whose tip is pointing to the * right). * * @param pl * the PointList outline to use as the PolygonDecoration's region * @since 2.0 */ public void setTemplate(PointList pl) { erase(); template = pl; points = null; bounds = null; repaint(); } /** * Sets the amount of scaling to be done along X and Y axes on the * PolygonDecoration's template. * * @param x * X scaling * @param y * Y scaling * @since 2.0 */ public void setScale(double x, double y) { points = null; bounds = null; transform.setScale(x, y); } /** * Sets the rotation of this decoration so that the decoration points toward * the given reference point. * * @param ref * the reference point */ public void setReferencePoint(Point ref) { Point pt = Point.SINGLETON; pt.setLocation(ref); pt.negate().translate(location); setRotation(Math.atan2(pt.y, pt.x)); } /** * Sets the angle by which rotation is to be done on the PolygonDecoration. * * @param angle * Angle of rotation * @since 2.0 */ public void setRotation(double angle) { points = null; bounds = null; transform.setRotation(angle); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/PolygonShape.java000066400000000000000000000030131166301720600267400ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2008, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Alexander Shatalin (Borland) - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Geometry; import org.eclipse.draw2d.geometry.Point; /** * Renders a {@link org.eclipse.draw2d.geometry.PointList} as a polygonal shape. * This class is similar to {@link PolylineShape}, except the * {@link org.eclipse.draw2d.geometry.PointList} is closed and can be filled in * as a solid shape. * * @see PolylineShape * @since 3.5 */ public class PolygonShape extends AbstractPointListShape { protected boolean shapeContainsPoint(int x, int y) { Point location = getLocation(); return Geometry.polygonContainsPoint(points, x - location.x, y - location.y); } protected void fillShape(Graphics graphics) { graphics.pushState(); graphics.translate(getLocation()); graphics.fillPolygon(getPoints()); graphics.popState(); } protected void outlineShape(Graphics graphics) { graphics.pushState(); graphics.translate(getLocation()); graphics.drawPolygon(getPoints()); graphics.popState(); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/Polyline.java000066400000000000000000000074711166301720600261370ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation * Alexander Shatalin (Borland) - Contribution for Bug 238874 *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Geometry; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.PointList; import org.eclipse.draw2d.geometry.Rectangle; /** * Renders a {@link PointList} as a series of line segments. A Polyline figure * should be positioned by manipulating its points, NOT by calling * {@link Figure#setBounds(Rectangle)}. *

* A polyline's bounds will be calculated automatically based on its PointList. * The bounds will be the smallest Rectangle large enough to render the line * properly. Children should not be added to a Polyline and will not affect the * bounds calculation. */ public class Polyline extends AbstractPointListShape { private int tolerance = 2; private static final Rectangle LINEBOUNDS = Rectangle.SINGLETON; { setFill(false); bounds = null; } /** * @see org.eclipse.draw2d.IFigure#containsPoint(int, int) */ public boolean containsPoint(int x, int y) { int tolerance = (int) Math.max(getLineWidthFloat() / 2.0f, this.tolerance); LINEBOUNDS.setBounds(getBounds()); LINEBOUNDS.expand(tolerance, tolerance); if (!LINEBOUNDS.contains(x, y)) return false; return shapeContainsPoint(x, y) || childrenContainsPoint(x, y); } protected boolean shapeContainsPoint(int x, int y) { return Geometry.polylineContainsPoint(points, x, y, tolerance); } /** * Null implementation for a line. * * @see org.eclipse.draw2d.Shape#fillShape(Graphics) */ protected void fillShape(Graphics g) { } /** * @see org.eclipse.draw2d.IFigure#getBounds() */ public Rectangle getBounds() { if (bounds == null) { int expand = (int) (getLineWidthFloat() / 2.0f); bounds = getPoints().getBounds().getExpanded(expand, expand); } return bounds; } /** * @return false because Polyline's aren't filled */ public boolean isOpaque() { return false; } /** * @see Shape#outlineShape(Graphics) */ protected void outlineShape(Graphics g) { g.drawPolyline(points); } /** * @see Figure#primTranslate(int, int) */ public void primTranslate(int x, int y) { } /** * Erases the Polyline and removes all of its {@link Point Points}. * * @since 2.0 */ public void removeAllPoints() { super.removeAllPoints(); bounds = null; } /** * @see org.eclipse.draw2d.Shape#setLineWidth(int) */ public void setLineWidth(int w) { if (getLineWidthFloat() == w) { return; } if (w < getLineWidthFloat()) { // The bounds will become smaller, so // erase must occur first. erase(); } bounds = null; super.setLineWidthFloat(w); } /** * Sets the list of points to be used by this polyline connection. Removes * any previously existing points. The polyline will hold onto the given * list by reference. * * @param points * new set of points * @since 2.0 */ public void setPoints(PointList points) { super.setPoints(points); firePropertyChange(Connection.PROPERTY_POINTS, null, points); } /** * Sets the tolerance * * @param tolerance * the new tolerance value of the Polyline */ public void setTolerance(int tolerance) { this.tolerance = tolerance; } public void repaint() { bounds = null; super.repaint(); } }eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/PolylineConnection.java000066400000000000000000000243001166301720600301450ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.ArrayList; import java.util.List; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; /** * An implementation of {@link Connection} based on Polyline. PolylineConnection * adds the following additional features: *

    *
  • * A {@link ConnectionRouter} may be provided which will be used to determine * the connections points. *
  • * Children may be added. The bounds calculation is extended such that the * bounds is the smallest Rectangle which is large enough to display the * Polyline and all of its children figures. *
  • * A {@link DelegatingLayout} is set as the default layout. A delegating layout * allows children to position themselves via {@link Locator Locators}. *
*

*/ public class PolylineConnection extends Polyline implements Connection, AnchorListener { private ConnectionAnchor startAnchor, endAnchor; private ConnectionRouter connectionRouter = ConnectionRouter.NULL; private RotatableDecoration startArrow, endArrow; { setLayoutManager(new DelegatingLayout()); addPoint(new Point(0, 0)); addPoint(new Point(100, 100)); } /** * Hooks the source and target anchors. * * @see Figure#addNotify() */ public void addNotify() { super.addNotify(); hookSourceAnchor(); hookTargetAnchor(); } /** * Appends the given routing listener to the list of listeners. * * @param listener * the routing listener * @since 3.2 */ public void addRoutingListener(RoutingListener listener) { if (connectionRouter instanceof RoutingNotifier) { RoutingNotifier notifier = (RoutingNotifier) connectionRouter; notifier.listeners.add(listener); } else connectionRouter = new RoutingNotifier(connectionRouter, listener); } /** * Called by the anchors of this connection when they have moved, * revalidating this polyline connection. * * @param anchor * the anchor that moved */ public void anchorMoved(ConnectionAnchor anchor) { revalidate(); } /** * Returns the bounds which holds all the points in this polyline * connection. Returns any previously existing bounds, else calculates by * unioning all the children's dimensions. * * @return the bounds */ public Rectangle getBounds() { if (bounds == null) { super.getBounds(); for (int i = 0; i < getChildren().size(); i++) { IFigure child = (IFigure) getChildren().get(i); bounds.union(child.getBounds()); } } return bounds; } /** * Returns the ConnectionRouter used to layout this connection. * Will not return null. * * @return this connection's router */ public ConnectionRouter getConnectionRouter() { if (connectionRouter instanceof RoutingNotifier) return ((RoutingNotifier) connectionRouter).realRouter; return connectionRouter; } /** * Returns this connection's routing constraint from its connection router. * May return null. * * @return the connection's routing constraint */ public Object getRoutingConstraint() { if (getConnectionRouter() != null) return getConnectionRouter().getConstraint(this); else return null; } /** * @return the anchor at the start of this polyline connection (may be null) */ public ConnectionAnchor getSourceAnchor() { return startAnchor; } /** * @return the source decoration (may be null) */ protected RotatableDecoration getSourceDecoration() { return startArrow; } /** * @return the anchor at the end of this polyline connection (may be null) */ public ConnectionAnchor getTargetAnchor() { return endAnchor; } /** * @return the target decoration (may be null) * * @since 2.0 */ protected RotatableDecoration getTargetDecoration() { return endArrow; } private void hookSourceAnchor() { if (getSourceAnchor() != null) getSourceAnchor().addAnchorListener(this); } private void hookTargetAnchor() { if (getTargetAnchor() != null) getTargetAnchor().addAnchorListener(this); } /** * Layouts this polyline. If the start and end anchors are present, the * connection router is used to route this, after which it is laid out. It * also fires a moved method. */ public void layout() { if (getSourceAnchor() != null && getTargetAnchor() != null) connectionRouter.route(this); Rectangle oldBounds = bounds; super.layout(); bounds = null; if (!getBounds().contains(oldBounds)) { getParent().translateToParent(oldBounds); getUpdateManager().addDirtyRegion(getParent(), oldBounds); } repaint(); fireFigureMoved(); } /** * Called just before the receiver is being removed from its parent. Results * in removing itself from the connection router. * * @since 2.0 */ public void removeNotify() { unhookSourceAnchor(); unhookTargetAnchor(); connectionRouter.remove(this); super.removeNotify(); } /** * Removes the first occurence of the given listener. * * @param listener * the listener being removed * @since 3.2 */ public void removeRoutingListener(RoutingListener listener) { if (connectionRouter instanceof RoutingNotifier) { RoutingNotifier notifier = (RoutingNotifier) connectionRouter; notifier.listeners.remove(listener); if (notifier.listeners.isEmpty()) connectionRouter = notifier.realRouter; } } /** * @see IFigure#revalidate() */ public void revalidate() { super.revalidate(); connectionRouter.invalidate(this); } /** * Sets the connection router which handles the layout of this polyline. * Generally set by the parent handling the polyline connection. * * @param cr * the connection router */ public void setConnectionRouter(ConnectionRouter cr) { if (cr == null) cr = ConnectionRouter.NULL; ConnectionRouter oldRouter = getConnectionRouter(); if (oldRouter != cr) { connectionRouter.remove(this); if (connectionRouter instanceof RoutingNotifier) ((RoutingNotifier) connectionRouter).realRouter = cr; else connectionRouter = cr; firePropertyChange(Connection.PROPERTY_CONNECTION_ROUTER, oldRouter, cr); revalidate(); } } /** * Sets the routing constraint for this connection. * * @param cons * the constraint */ public void setRoutingConstraint(Object cons) { if (connectionRouter != null) connectionRouter.setConstraint(this, cons); revalidate(); } /** * Sets the anchor to be used at the start of this polyline connection. * * @param anchor * the new source anchor */ public void setSourceAnchor(ConnectionAnchor anchor) { if (anchor == startAnchor) return; unhookSourceAnchor(); // No longer needed, revalidate does this. // getConnectionRouter().invalidate(this); startAnchor = anchor; if (getParent() != null) hookSourceAnchor(); revalidate(); } /** * Sets the decoration to be used at the start of the {@link Connection}. * * @param dec * the new source decoration * @since 2.0 */ public void setSourceDecoration(RotatableDecoration dec) { if (startArrow == dec) return; if (startArrow != null) remove(startArrow); startArrow = dec; if (startArrow != null) add(startArrow, new ArrowLocator(this, ConnectionLocator.SOURCE)); } /** * Sets the anchor to be used at the end of the polyline connection. Removes * this listener from the old anchor and adds it to the new anchor. * * @param anchor * the new target anchor */ public void setTargetAnchor(ConnectionAnchor anchor) { if (anchor == endAnchor) return; unhookTargetAnchor(); // No longer needed, revalidate does this. // getConnectionRouter().invalidate(this); endAnchor = anchor; if (getParent() != null) hookTargetAnchor(); revalidate(); } /** * Sets the decoration to be used at the end of the {@link Connection}. * * @param dec * the new target decoration */ public void setTargetDecoration(RotatableDecoration dec) { if (endArrow == dec) return; if (endArrow != null) remove(endArrow); endArrow = dec; if (endArrow != null) add(endArrow, new ArrowLocator(this, ConnectionLocator.TARGET)); } private void unhookSourceAnchor() { if (getSourceAnchor() != null) getSourceAnchor().removeAnchorListener(this); } private void unhookTargetAnchor() { if (getTargetAnchor() != null) getTargetAnchor().removeAnchorListener(this); } final class RoutingNotifier implements ConnectionRouter { ConnectionRouter realRouter; List listeners = new ArrayList(1); RoutingNotifier(ConnectionRouter router, RoutingListener listener) { realRouter = router; listeners.add(listener); } public Object getConstraint(Connection connection) { return realRouter.getConstraint(connection); } public void invalidate(Connection connection) { for (int i = 0; i < listeners.size(); i++) ((RoutingListener) listeners.get(i)).invalidate(connection); realRouter.invalidate(connection); } public void route(Connection connection) { boolean consumed = false; for (int i = 0; i < listeners.size(); i++) consumed |= ((RoutingListener) listeners.get(i)) .route(connection); if (!consumed) realRouter.route(connection); for (int i = 0; i < listeners.size(); i++) ((RoutingListener) listeners.get(i)).postRoute(connection); } public void remove(Connection connection) { for (int i = 0; i < listeners.size(); i++) ((RoutingListener) listeners.get(i)).remove(connection); realRouter.remove(connection); } public void setConstraint(Connection connection, Object constraint) { for (int i = 0; i < listeners.size(); i++) ((RoutingListener) listeners.get(i)).setConstraint(connection, constraint); realRouter.setConstraint(connection, constraint); } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/PolylineDecoration.java000066400000000000000000000061511166301720600301410ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.PointList; import org.eclipse.draw2d.geometry.Transform; /** * A decorative Figure intended to be placed on a {@link Polyline}. It has the * default shape of right-pointing triangle. */ public class PolylineDecoration extends Polyline implements RotatableDecoration { /** A triangle template */ public static final PointList TRIANGLE_TIP = new PointList(); static { TRIANGLE_TIP.addPoint(-1, 1); TRIANGLE_TIP.addPoint(0, 0); TRIANGLE_TIP.addPoint(-1, -1); } private Point location = new Point(); private PointList template = TRIANGLE_TIP; private Transform transform = new Transform(); /** * Constructs a PolylineDecoration. Defaults the PolylineDecoration to fill * its region with black. * * @since 2.0 */ public PolylineDecoration() { setBackgroundColor(ColorConstants.black); setScale(7, 3); } /** * @see Polyline#getPoints() */ public PointList getPoints() { if (points == null) { points = new PointList(); for (int i = 0; i < template.size(); i++) points.addPoint(transform.getTransformed(template.getPoint(i))); } return points; } /** * @see IFigure#setLocation(Point) */ public void setLocation(Point p) { points = null; bounds = null; location.setLocation(p); transform.setTranslation(p.x, p.y); } /** * Sets the PolylineDecoration's point template. This template is an outline * of the PolylineDecoration's region. (The default value is TRIANGLE_TIP * which is a triangle whose tip is pointing to the right). * * @param pl * the template * @since 2.0 */ public void setTemplate(PointList pl) { erase(); template = pl; points = null; bounds = null; repaint(); } /** * Sets the amount of scaling to be done along X and Y axes on the * PolylineDecoration's template. * * @param x * the x scale * @param y * the y scale * @since 2.0 */ public void setScale(double x, double y) { points = null; bounds = null; transform.setScale(x, y); } /** * @see RotatableDecoration#setReferencePoint(Point) */ public void setReferencePoint(Point ref) { Point pt = Point.SINGLETON; pt.setLocation(ref); pt.negate().translate(location); setRotation(Math.atan2(pt.y, pt.x)); } /** * Sets the angle by which rotation is to be done on the PolylineDecoration. * * @param angle * the angle of rotation * @since 2.0 */ public void setRotation(double angle) { points = null; bounds = null; transform.setRotation(angle); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/PolylineShape.java000066400000000000000000000035431166301720600271140ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2008, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Alexander Shatalin (Borland) - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Geometry; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.PointList; import org.eclipse.draw2d.geometry.Rectangle; /** * Renders a {@link PointList} as a series of line segments. All points from the * {@link PointList} are recognized as a relative points, so you can move/resize * this figure normally by calling {@link Figure#setBounds(Rectangle)}. * * @since 3.5 */ public class PolylineShape extends AbstractPointListShape { private int tolerance = 2; /** * @return true if the distance between specified point and closest segment * of this PolyLine is less then {@link PolylineShape#tolerance} */ protected boolean shapeContainsPoint(int x, int y) { Point location = getLocation(); return Geometry.polylineContainsPoint(points, x - location.x, y - location.y, tolerance); } protected void fillShape(Graphics graphics) { } protected void outlineShape(Graphics graphics) { graphics.pushState(); graphics.translate(getLocation()); graphics.drawPolyline(points); graphics.popState(); } /** * Setting tolerance parameter. This parameter will be used in * {@link PolylineShape#shapeContainsPoint(int, int)} */ public void setTolerance(int tolerance) { this.tolerance = tolerance; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/PopUpHelper.java000066400000000000000000000125111166301720600265360ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; import org.eclipse.draw2d.geometry.Dimension; /** * Provides abstract support for classes that manage popups. Popups in Draw2d * consist of a LightweightSystem object with an SWT shell as its Control. * Desired popup behavior is attained by adding appropriate listeners to this * shell. */ public abstract class PopUpHelper { private Shell shell; private LightweightSystem lws; private boolean tipShowing; /** * The Control this PopUpHelper's tooltip will belong to. */ protected Control control; /** * These style bits should be used when creating the Shell. * * @see #createShell() */ protected final int shellStyle; /** * Constructs a PopUpHelper to assist with popups on Control c. * * @param c * the Control * @since 2.0 */ protected PopUpHelper(Control c) { this(c, SWT.ON_TOP | SWT.NO_TRIM); } /** * Constructs a PopUpHelper to display the given shell style popup. * * @param c * the control on which the popup is active. * @param shellStyle * the SWT style bits for the shell * @since 3.1 */ protected PopUpHelper(Control c, int shellStyle) { control = c; this.shellStyle = shellStyle | SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE; } /** * Creates and returns the LightweightSystem object used by PopUpHelper to * draw upon. * * @return the newly created LightweightSystem * @since 2.0 */ protected LightweightSystem createLightweightSystem() { return new LightweightSystem(); } /** * Creates a new Shell object with the style specified for this helper. * * @return the newly created Shell * @since 2.0 */ protected Shell createShell() { return new Shell(control.getShell(), shellStyle); } /** * Dispose of this PopUpHelper object. * * @since 2.0 */ public void dispose() { if (isShowing()) hide(); if (shell != null && !shell.isDisposed()) shell.dispose(); } /** * Returns this PopUpHelper's shell. If no shell exists for this * PopUpHelper, a new shell is created and hookShellListeners() is called. * * @return the Shell * @since 2.0 */ protected Shell getShell() { if (shell == null) { shell = createShell(); hookShellListeners(); } return shell; } /** * Returns the size needed to display the shell's trim. This method should * not be called until the shell has been created. * * @return the size of the shells trim. * @since 3.1 */ protected Dimension getShellTrimSize() { Rectangle trim = shell.computeTrim(0, 0, 0, 0); return new Dimension(trim.width, trim.height); } /** * Returns this PopUpHelper's LightweightSystem. If no LightweightSystem * exists for this PopUpHelper, a new LightweightSystem is created with this * PopUpHelper's Shell as its Control. * * @return the LightweightSystem * @since 2.0 */ protected LightweightSystem getLightweightSystem() { if (lws == null) { lws = createLightweightSystem(); lws.setControl(getShell()); } return lws; } /** * Hides this PopUpHelper's Shell. * * @since 2.0 */ protected void hide() { if (shell != null && !shell.isDisposed()) shell.setVisible(false); tipShowing = false; } /** * Desired popup helper behavior is achieved by writing listeners that * manipulate the behavior of the PopUpHelper's Shell. Override this method * and add these listeners here. * * @since 2.0 */ protected abstract void hookShellListeners(); /** * Returns true if this PopUpHelper's Shell is visible, * false otherwise. * * @return true if this PopUpHelper's Shell is visible * @since 2.0 */ public boolean isShowing() { return tipShowing; } /** * Sets the background color of this PopUpHelper's Shell. * * @param c * the new background color * @since 2.0 */ public void setBackgroundColor(Color c) { getShell().setBackground(c); } /** * Sets the foreground color of this PopUpHelper's Shell. * * @param c * the new foreground color * @since 2.0 */ public void setForegroundColor(Color c) { getShell().setForeground(c); } /** * Sets the bounds on this PopUpHelper's Shell. * * @param x * the x coordinate * @param y * the y coordinate * @param width * the width * @param height * the height * @since 2.0 */ protected void setShellBounds(int x, int y, int width, int height) { getShell().setBounds(x, y, width, height); } /** * Displays this PopUpHelper's Shell. * * @since 2.0 */ protected void show() { getShell().setVisible(true); tipShowing = true; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/PositionConstants.java000066400000000000000000000057231166301720600300430ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; /** * Constants representing cardinal directions and relative positions. Some of * these constants can be grouped as follows: * * * * * * * * * * * * * * * *
LEFT, CENTER, RIGHTUsed to describe horizontal position.
TOP, MIDDLE, BOTTOMUsed to describe vertical position.
NORTH, SOUTH, EAST, WESTUsed to describe the four positions relative to an object's center point. * May also be used when describing which direction an object is facing.
* NOTE: If you have a use for all four of these possibilities, do not use TOP, * BOTTOM, RIGHT, LEFT in place of NORTH, SOUTH, EAST, WEST.
*/ public interface PositionConstants { /** None */ int NONE = 0; /** Left */ int LEFT = 1; /** Center (Horizontal) */ int CENTER = 2; /** Right */ int RIGHT = 4; /** Bit-wise OR of LEFT, CENTER, and RIGHT */ int LEFT_CENTER_RIGHT = LEFT | CENTER | RIGHT; /** * Used to signify left alignment regardless of orientation (i.e., LTR or * RTL) */ int ALWAYS_LEFT = 64; /** * Used to signify right alignment regardless of orientation (i.e., LTR or * RTL) */ int ALWAYS_RIGHT = 128; /** Top */ int TOP = 8; /** Middle (Vertical) */ int MIDDLE = 16; /** Bottom */ int BOTTOM = 32; /** Bit-wise OR of TOP, MIDDLE, and BOTTOM */ int TOP_MIDDLE_BOTTOM = TOP | MIDDLE | BOTTOM; /** North */ int NORTH = 1; /** South */ int SOUTH = 4; /** West */ int WEST = 8; /** East */ int EAST = 16; /** A constant indicating horizontal direction */ int HORIZONTAL = 64; /** A constant indicating vertical direction */ int VERTICAL = 128; /** North-East: a bit-wise OR of {@link #NORTH} and {@link #EAST} */ int NORTH_EAST = NORTH | EAST; /** North-West: a bit-wise OR of {@link #NORTH} and {@link #WEST} */ int NORTH_WEST = NORTH | WEST; /** South-East: a bit-wise OR of {@link #SOUTH} and {@link #EAST} */ int SOUTH_EAST = SOUTH | EAST; /** South-West: a bit-wise OR of {@link #SOUTH} and {@link #WEST} */ int SOUTH_WEST = SOUTH | WEST; /** North-South: a bit-wise OR of {@link #NORTH} and {@link #SOUTH} */ int NORTH_SOUTH = NORTH | SOUTH; /** East-West: a bit-wise OR of {@link #EAST} and {@link #WEST} */ int EAST_WEST = EAST | WEST; /** North-South-East-West: a bit-wise OR of all 4 directions. */ int NSEW = NORTH_SOUTH | EAST_WEST; }eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/PrintFigureOperation.java000066400000000000000000000133361166301720600304600ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation * Sven Mller - Added tiling support *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.printing.Printer; import org.eclipse.swt.widgets.Display; import org.eclipse.draw2d.geometry.Rectangle; /** * Class responsible for printing Figures. * * @author Dan Lee * @author Eric Bordeau * @author Sven Mller */ public class PrintFigureOperation extends PrintOperation { /** * The default print mode. Prints at 100% scale and tiles horizontally * and/or vertically, if necessary. */ public static final int TILE = 1; /** * A print mode that scales the printer graphics so that the entire printed * image fits on one page. */ public static final int FIT_PAGE = 2; /** * A print mode that scales the printer graphics so that the width of the * printed image fits on one page and tiles vertically, if necessary. */ public static final int FIT_WIDTH = 3; /** * A print mode that scales the printer graphics so that the height of the * printed image fits on one page and tiles horizontally, if necessary. */ public static final int FIT_HEIGHT = 4; private IFigure printSource; private Color oldBGColor; private int printMode = TILE; /** * Constructor for PrintFigureOperation. *

* Note: Descendants must call setPrintSource(IFigure) to set the IFigure * that is to be printed. * * @see org.eclipse.draw2d.PrintOperation#PrintOperation(Printer) */ protected PrintFigureOperation(Printer p) { super(p); } /** * Constructor for PrintFigureOperation. * * @param p * Printer to print on * @param srcFigure * Figure to print */ public PrintFigureOperation(Printer p, IFigure srcFigure) { super(p); setPrintSource(srcFigure); } /** * @return SWT.RIGHT_TO_LEFT if the print source is mirrored; * SWT.LEFT_TO_RIGHT otherwise * @see org.eclipse.draw2d.PrintOperation#getGraphicsOrientation() */ int getGraphicsOrientation() { return getPrintSource().isMirrored() ? SWT.RIGHT_TO_LEFT : SWT.LEFT_TO_RIGHT; } /** * Returns the current print mode. The print mode is one of: * {@link #FIT_HEIGHT}, {@link #FIT_PAGE}, or {@link #FIT_WIDTH}. * * @return the print mode */ protected int getPrintMode() { return printMode; } /** * Returns the printSource. * * @return IFigure The source IFigure */ protected IFigure getPrintSource() { return printSource; } /** * @see org.eclipse.draw2d.PrintOperation#preparePrintSource() */ protected void preparePrintSource() { oldBGColor = getPrintSource().getLocalBackgroundColor(); getPrintSource().setBackgroundColor(ColorConstants.white); } /** * Prints the pages based on the current print mode. * * @see org.eclipse.draw2d.PrintOperation#printPages() */ protected void printPages() { Graphics graphics = getFreshPrinterGraphics(); IFigure figure = getPrintSource(); setupPrinterGraphicsFor(graphics, figure); Rectangle bounds = figure.getBounds(); int x = bounds.x, y = bounds.y; Rectangle clipRect = new Rectangle(); while (y < bounds.y + bounds.height) { while (x < bounds.x + bounds.width) { graphics.pushState(); getPrinter().startPage(); graphics.translate(-x, -y); graphics.getClip(clipRect); clipRect.setLocation(x, y); graphics.clipRect(clipRect); figure.paint(graphics); getPrinter().endPage(); graphics.popState(); x += clipRect.width; } x = bounds.x; y += clipRect.height; } } /** * @see org.eclipse.draw2d.PrintOperation#restorePrintSource() */ protected void restorePrintSource() { getPrintSource().setBackgroundColor(oldBGColor); oldBGColor = null; } /** * Sets the print mode. Possible values are {@link #TILE}, * {@link #FIT_HEIGHT}, {@link #FIT_WIDTH} and {@link #FIT_PAGE}. * * @param mode * the print mode */ public void setPrintMode(int mode) { printMode = mode; } /** * Sets the printSource. * * @param printSource * The printSource to set */ protected void setPrintSource(IFigure printSource) { this.printSource = printSource; } /** * Sets up Graphics object for the given IFigure. * * @param graphics * The Graphics to setup * @param figure * The IFigure used to setup graphics */ protected void setupPrinterGraphicsFor(Graphics graphics, IFigure figure) { double dpiScale = (double) getPrinter().getDPI().x / Display.getCurrent().getDPI().x; Rectangle printRegion = getPrintRegion(); // put the print region in display coordinates printRegion.width /= dpiScale; printRegion.height /= dpiScale; Rectangle bounds = figure.getBounds(); double xScale = (double) printRegion.width / bounds.width; double yScale = (double) printRegion.height / bounds.height; switch (getPrintMode()) { case FIT_PAGE: graphics.scale(Math.min(xScale, yScale) * dpiScale); break; case FIT_WIDTH: graphics.scale(xScale * dpiScale); break; case FIT_HEIGHT: graphics.scale(yScale * dpiScale); break; default: graphics.scale(dpiScale); } graphics.setForegroundColor(figure.getForegroundColor()); graphics.setBackgroundColor(figure.getBackgroundColor()); graphics.setFont(figure.getFont()); } }eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/PrintOperation.java000066400000000000000000000122711166301720600273130ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.printing.Printer; import org.eclipse.draw2d.geometry.Insets; import org.eclipse.draw2d.geometry.Rectangle; /** * Implementation of draw2d's printing capabilities. * * @author Dan Lee * @author Eric Bordeau */ public abstract class PrintOperation { private GC printerGC; // Note: Only one GC instance should be created per // print job private Insets printMargin = new Insets(0, 0, 0, 0); private Printer printer; private PrinterGraphics printerGraphics; private SWTGraphics g; /** * Creates a new PrintOperation */ public PrintOperation() { } /** * Creates a new PrintOperation on Printer p * * @param p * The printer to print on */ public PrintOperation(Printer p) { setPrinter(p); } /** * Disposes the PrinterGraphics and GC objects associated with this * PrintOperation. */ protected void cleanup() { if (g != null) { printerGraphics.dispose(); g.dispose(); } if (printerGC != null) printerGC.dispose(); } /** * Returns a new PrinterGraphics setup for the Printer associated with this * PrintOperation. * * @return PrinterGraphics The new PrinterGraphics */ protected PrinterGraphics getFreshPrinterGraphics() { if (printerGraphics != null) { printerGraphics.dispose(); g.dispose(); printerGraphics = null; g = null; } g = new SWTGraphics(printerGC); printerGraphics = new PrinterGraphics(g, printer); setupGraphicsForPage(printerGraphics); return printerGraphics; } /** * This method is invoked by the {@link #run(String)} method to determine * the orientation of the GC to be used for printing. This default * implementation always returns SWT.LEFT_TO_RIGHT. * * @return SWT.LEFT_TO_RIGHT or SWT.RIGHT_TO_LEFT * @since 3.1 * @TODO Make protected post-3.1 */ int getGraphicsOrientation() { return SWT.LEFT_TO_RIGHT; } /** * Returns the printer. * * @return Printer */ public Printer getPrinter() { return printer; } /** * Returns a Rectangle that represents the region that can be printed to. * The x, y, height, and width values are using the printers coordinates. * * @return the print region */ public Rectangle getPrintRegion() { org.eclipse.swt.graphics.Rectangle trim = printer.computeTrim(0, 0, 0, 0); org.eclipse.swt.graphics.Point printerDPI = printer.getDPI(); Insets notAvailable = new Insets(-trim.y, -trim.x, trim.height + trim.y, trim.width + trim.x); Insets userPreferred = new Insets( (printMargin.top * printerDPI.x) / 72, (printMargin.left * printerDPI.x) / 72, (printMargin.bottom * printerDPI.x) / 72, (printMargin.right * printerDPI.x) / 72); Rectangle paperBounds = new Rectangle(printer.getBounds()); Rectangle printRegion = paperBounds.getCropped(notAvailable); printRegion.intersect(paperBounds.getCropped(userPreferred)); printRegion.translate(trim.x, trim.y); return printRegion; } /** * This method contains all operations performed to sourceFigure prior to * being printed. */ protected void preparePrintSource() { } /** * This method is responsible for printing pages. (A page is printed by * calling Printer.startPage(), followed by painting to the PrinterGraphics * object, and then calling Printer.endPage()). */ protected abstract void printPages(); /** * This method contains all operations performed to sourceFigure after being * printed. */ protected void restorePrintSource() { } /** * Sets the print job into motion. * * @param jobName * A String representing the name of the print job */ public void run(String jobName) { preparePrintSource(); if (printer.startJob(jobName)) { printerGC = new GC(getPrinter(), getGraphicsOrientation()); printPages(); printer.endJob(); } restorePrintSource(); cleanup(); } /** * Sets the printer. * * @param printer * The printer to set */ public void setPrinter(Printer printer) { this.printer = printer; } /** * Sets the page margin in pels (logical pixels) to the passed Insets.(72 * pels == 1 inch) * * @param margin * The margin to set on the page */ public void setPrintMargin(Insets margin) { printMargin = margin; } /** * Manipulates the PrinterGraphics to position it to paint in the desired * region of the page. (Default is the top left corner of the page). * * @param pg * The PrinterGraphics to setup */ protected void setupGraphicsForPage(PrinterGraphics pg) { Rectangle printRegion = getPrintRegion(); pg.clipRect(printRegion); pg.translate(printRegion.getTopLeft()); } }eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/PrinterGraphics.java000066400000000000000000000072271166301720600274470ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.LineAttributes; import org.eclipse.swt.printing.Printer; import org.eclipse.swt.widgets.Display; /** * A scalable graphics object used to print to a printer. * * @author danlee */ public class PrinterGraphics extends ScaledGraphics { Map imageCache = new HashMap(); Printer printer; /** * Creates a new PrinterGraphics with Graphics g, using Printer p * * @param g * Graphics object to draw with * @param p * Printer to print to */ public PrinterGraphics(Graphics g, Printer p) { super(g); printer = p; } Font createFont(FontData data) { return new Font(printer, data); } private Image printerImage(Image image) { Image result = (Image) imageCache.get(image); if (result != null) return result; result = new Image(printer, image.getImageData()); imageCache.put(image, result); return result; } /** * @see org.eclipse.draw2d.ScaledGraphics#dispose() */ public void dispose() { super.dispose(); // Dispose printer images Iterator iter = imageCache.values().iterator(); while (iter.hasNext()) { Image printerImage = ((Image) iter.next()); printerImage.dispose(); } imageCache.clear(); } /** * @see org.eclipse.draw2d.Graphics#drawImage(Image, int, int) */ public void drawImage(Image srcImage, int x, int y) { super.drawImage(printerImage(srcImage), x, y); } /** * @see Graphics#drawImage(Image, int, int, int, int, int, int, int, int) */ public void drawImage(Image srcImage, int sx, int sy, int sw, int sh, int tx, int ty, int tw, int th) { super.drawImage(printerImage(srcImage), sx, sy, sw, sh, tx, ty, tw, th); } int zoomFontHeight(int height) { return (int) (height * zoom * Display.getCurrent().getDPI().y / printer.getDPI().y + 0.0000001); } /** * @see org.eclipse.draw2d.ScaledGraphics#zoomLineWidth(float) */ float zoomLineWidth(float w) { return (float) (w * zoom); } /** * Overridden to translate dashes to printer specific values. * * @see org.eclipse.draw2d.ScaledGraphics#setLineAttributes(org.eclipse.swt.graphics.LineAttributes) */ public void setLineAttributes(LineAttributes attributes) { if (attributes.style == SWT.LINE_CUSTOM && attributes.dash != null && attributes.dash.length > 0) { float[] newDashes = new float[attributes.dash.length]; float printerDot = (float) (printer.getDPI().y / Display.getCurrent().getDPI().y + 0.0000001); for (int i = 0; i < attributes.dash.length; i++) { newDashes[i] = attributes.dash[i] * printerDot; } // make a copy of attributes, we dont's want it changed on figure // (or display will be affected) super.setLineAttributes(new LineAttributes(attributes.width, attributes.cap, attributes.join, attributes.style, newDashes, attributes.dashOffset * printerDot, attributes.miterLimit)); } else { super.setLineAttributes(attributes); } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/PuristicScrollPane.java000066400000000000000000000067371166301720600301350ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Research Group Software Construction, * RWTH Aachen University, Germany - initial API and implementation */ package org.eclipse.draw2d; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; /** * A {@link ScrollPane} with transparent {@link ScrollBar}s. * * @author Alexander Nyssen * @author Philip Ritzkopf * * @since 3.6 */ public class PuristicScrollPane extends ScrollPane { /** * A {@link ScrollBar} with no thumb and non-opaque buttons. * * @author Alexander Nyssen * @author Philip Ritzkopf */ public class PuristicScrollBar extends ScrollBar { /** * Instantiates a new transparent scroll bar. * * @param isHorizontal * whether this scroll bar is used as a horizontal one. */ public PuristicScrollBar(boolean isHorizontal) { super(); setHorizontal(isHorizontal); setOpaque(false); } /** * @see org.eclipse.draw2d.ScrollBar#createDefaultDownButton() */ protected Clickable createDefaultDownButton() { Clickable buttonDown = super.createDefaultDownButton(); buttonDown.setBorder(null); buttonDown.setOpaque(false); return buttonDown; } /** * @see org.eclipse.draw2d.ScrollBar#createDefaultThumb() */ protected IFigure createDefaultThumb() { return null; } /** * @see org.eclipse.draw2d.ScrollBar#createDefaultUpButton() */ protected Clickable createDefaultUpButton() { Clickable buttonUp = super.createDefaultUpButton(); buttonUp.setBorder(null); buttonUp.setOpaque(false); return buttonUp; } /** * @see org.eclipse.draw2d.ScrollBar#createPageDown() */ protected Clickable createPageDown() { return null; } /** * @see org.eclipse.draw2d.ScrollBar#createPageUp() */ protected Clickable createPageUp() { return null; } /** * @see PropertyChangeListener#propertyChange(java.beans. * PropertyChangeEvent ) */ public void propertyChange(PropertyChangeEvent event) { if (event.getSource() instanceof RangeModel) { getButtonDown().setVisible( getValue() != getMaximum() - getExtent()); getButtonUp().setVisible(getValue() != getMinimum()); } super.propertyChange(event); } } public PuristicScrollPane() { // layout to ensure, viewport gets complete client area setLayoutManager(new ScrollPaneLayout() { public void layout(IFigure parent) { // scroll panes are layouted normally super.layout(parent); // viewport gets complete client area ScrollPane scrollpane = (ScrollPane) parent; Viewport viewport = scrollpane.getViewport(); viewport.setBounds(parent.getClientArea()); } }); } /** * @see org.eclipse.draw2d.ScrollPane#createVerticalScrollBar() */ protected void createVerticalScrollBar() { PuristicScrollBar verticalScrollBar = new PuristicScrollBar(false); setVerticalScrollBar(verticalScrollBar); } /** * @see org.eclipse.draw2d.ScrollPane#createHorizontalScrollBar() */ protected void createHorizontalScrollBar() { PuristicScrollBar horizontalScrollBar = new PuristicScrollBar(true); setHorizontalScrollBar(horizontalScrollBar); } }eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/RangeModel.java000066400000000000000000000063501166301720600263540ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.beans.PropertyChangeListener; /** * This interface represents a range of possible values as well as the current * values. There is a minumum and maximum value, a current value, and the * extent. One use for a RangeModel is a scrollbar. There is a minimum value * (the top of the scrollbar), a maximum value (the bottom of the scrollbar), a * current value (the top of the thumb), and an extent (the length of the * thumb). */ public interface RangeModel { /** Value property name */ String PROPERTY_VALUE = "value"; //$NON-NLS-1$ /** Extent property name */ String PROPERTY_EXTENT = "extent"; //$NON-NLS-1$ /** Minimum property name */ String PROPERTY_MINIMUM = "minimum"; //$NON-NLS-1$ /** Maximum property name */ String PROPERTY_MAXIMUM = "maximum"; //$NON-NLS-1$ /** * Registers listener as a PropertyChangeListener of this RangeModel. * Listeners will be notified of changes to {@link #PROPERTY_VALUE value}, * {@link #PROPERTY_EXTENT extent}, {@link #PROPERTY_MINIMUM minimum} and * {@link #PROPERTY_MAXIMUM maximum} properties. * * @param listener * The listener to add */ void addPropertyChangeListener(PropertyChangeListener listener); /** * Returns the extent. * * @return The extent */ int getExtent(); /** * Returns the maximum value in the range. * * @return The maximum value */ int getMaximum(); /** * Returns the minimum value in the range. * * @return The minimum value */ int getMinimum(); /** * Returns the current value. * * @return The current value */ int getValue(); /** * Returns true if this RangeModel is enabled. * * @return true if this Rangel Model is enabled */ boolean isEnabled(); /** * Removes the given listener from this RangeModel's list of * PropertyChangeListeners. * * @param listener * The listener to remove */ void removePropertyChangeListener(PropertyChangeListener listener); /** * Sets min, extent, and max all at once. * * @param min * the new mininum * @param extent * the new extent * @param max * the new maximum */ void setAll(int min, int extent, int max); /** * Sets the extent. * * @param extent * The extent */ void setExtent(int extent); /** * Sets the maximum value of the range. * * @param max * The maximum value */ void setMaximum(int max); /** * Sets the minimum value of the range. * * @param min * The minimum value */ void setMinimum(int min); /** * Sets the current value. * * @param value * The current value */ void setValue(int value); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/RectangleFigure.java000066400000000000000000000025551166301720600274100ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Rectangle; /** * Draws a rectangle whose size is determined by the bounds set to it. */ public class RectangleFigure extends Shape { /** * Creates a RectangleFigure. */ public RectangleFigure() { } /** * @see Shape#fillShape(Graphics) */ protected void fillShape(Graphics graphics) { graphics.fillRectangle(getBounds()); } /** * @see Shape#outlineShape(Graphics) */ protected void outlineShape(Graphics graphics) { float lineInset = Math.max(1.0f, getLineWidthFloat()) / 2.0f; int inset1 = (int) Math.floor(lineInset); int inset2 = (int) Math.ceil(lineInset); Rectangle r = Rectangle.SINGLETON.setBounds(getBounds()); r.x += inset1; r.y += inset1; r.width -= inset1 + inset2; r.height -= inset1 + inset2; graphics.drawRectangle(r); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/RelativeBendpoint.java000066400000000000000000000073421166301720600277570ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.PrecisionPoint; /** * RelativeBendpoint is a Bendpoint that calculates its location based on its * distance from the start and end points of the {@link Connection}, as well as * its weight. See {@link #setWeight(float)} for a description of what behavior * different weights will provide. */ public class RelativeBendpoint implements Bendpoint { private Connection connection; private float weight = 0.5f; private Dimension d1, d2; /** * Constructs a new RelativeBendpoint. * * @since 2.0 */ public RelativeBendpoint() { } /** * Constructs a new RelativeBendpoint and associates it with the given * Connection. * * @param conn * The Connection this Bendpoint is associated with * @since 2.0 */ public RelativeBendpoint(Connection conn) { setConnection(conn); } /** * Returns the Connection this Bendpoint is associated with. * * @return The Connection this Bendpoint is associated with * @since 2.0 */ protected Connection getConnection() { return connection; } /** * Calculates and returns this Bendpoint's new location. * * @return This Bendpoint's new location * @since 2.0 */ public Point getLocation() { PrecisionPoint a1 = new PrecisionPoint(getConnection() .getSourceAnchor().getReferencePoint()); PrecisionPoint a2 = new PrecisionPoint(getConnection() .getTargetAnchor().getReferencePoint()); getConnection().translateToRelative(a1); getConnection().translateToRelative(a2); return new PrecisionPoint( (a1.preciseX() + d1.preciseWidth()) * (1.0 - weight) + weight * (a2.preciseX() + d2.preciseWidth()), (a1.preciseY() + d1.preciseHeight()) * (1.0 - weight) + weight * (a2.preciseY() + d2.preciseHeight())); } /** * Sets the Connection this bendpoint should be associated with. * * @param conn * The Connection this bendpoint should be associated with * @since 2.0 */ public void setConnection(Connection conn) { connection = conn; } /** * Sets the Dimensions representing the X and Y distances this Bendpoint is * from the start and end points of the Connection. These Dimensions are * generally set once and are used in calculating the Bendpoint's location. * * @param dim1 * The X and Y distances this Bendpoint is from the start of the * Connection * @param dim2 * The X and Y distances this Bendpoint is from the end of the * Connection * @since 2.0 */ public void setRelativeDimensions(Dimension dim1, Dimension dim2) { d1 = dim1; d2 = dim2; } /** * Sets the weight this Bendpoint should use to calculate its location. The * weight should be between 0.0 and 1.0. A weight of 0.0 will cause the * Bendpoint to follow the start point, while a weight of 1.0 will cause the * Bendpoint to follow the end point. A weight of 0.5 (the default) will * cause the Bendpoint to maintain its original aspect ratio between the * start and end points. * * @param w * The weight * @since 2.0 */ public void setWeight(float w) { weight = w; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/RelativeLocator.java000066400000000000000000000106501166301720600274340ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.PrecisionRectangle; import org.eclipse.draw2d.geometry.Rectangle; /** * Places a handle relative to a figure's bounds. The placement is determined by * indicating the figure to which the placement is relative, and two * floating-point value indicating the horizontal and vertical offset from that * figure's top-left corner. The values (0.0, 0.0) would indicate the figure's * top-left corner, while the values (1.0, 1.0) would indicate the figure's * bottom-right corner. *

* Constants such as {@link PositionConstants#NORTH NORTH} and * {@link PositionConstants#SOUTH SOUTH} can be used to set the placement. */ public class RelativeLocator implements Locator { private double relativeX; private double relativeY; private IFigure reference; /** * Null constructor. The reference figure must be set before use. The * relative locations will default to (0.0, 0.0). * * @since 2.0 */ public RelativeLocator() { relativeX = 0.0; relativeY = 0.0; } /** * Constructs a RelativeLocator with the given reference figure and relative * location. The location is a constant from {@link PositionConstants} used * as a convenient and readable way to set both the relativeX and relativeY * values. * * @param reference * the reference figure * @param location * one of NORTH, NORTH_EAST, etc. * @since 2.0 */ public RelativeLocator(IFigure reference, int location) { setReferenceFigure(reference); switch (location & PositionConstants.NORTH_SOUTH) { case PositionConstants.NORTH: relativeY = 0; break; case PositionConstants.SOUTH: relativeY = 1.0; break; default: relativeY = 0.5; } switch (location & PositionConstants.EAST_WEST) { case PositionConstants.WEST: relativeX = 0; break; case PositionConstants.EAST: relativeX = 1.0; break; default: relativeX = 0.5; } } /** * Constructs a RelativeLocator with the given reference Figure and offset * ratios. * * @param reference * the reference figure * @param relativeX * the relative X offset * @param relativeY * the relative Y offset * @since 2.0 */ public RelativeLocator(IFigure reference, double relativeX, double relativeY) { setReferenceFigure(reference); this.relativeX = relativeX; this.relativeY = relativeY; } /** * Returns the Reference Box in the Reference Figure's coordinate system. * The returned Rectangle may be by reference, and should not be * modified. * * @return the reference box * @since 2.0 */ protected Rectangle getReferenceBox() { return getReferenceFigure().getBounds(); } /** * Returns the Figure this locator is relative to. * * @return the reference figure * @since 2.0 */ protected IFigure getReferenceFigure() { return reference; } /** * Relocates the target using the relative offset locations. * * @see org.eclipse.draw2d.Locator#relocate(org.eclipse.draw2d.IFigure) */ public void relocate(IFigure target) { IFigure reference = getReferenceFigure(); Rectangle targetBounds = new PrecisionRectangle(getReferenceBox() .getResized(-1, -1)); reference.translateToAbsolute(targetBounds); target.translateToRelative(targetBounds); targetBounds.resize(1, 1); Dimension targetSize = target.getPreferredSize(); targetBounds.x += (int) (targetBounds.width * relativeX - ((targetSize.width + 1) / 2)); targetBounds.y += (int) (targetBounds.height * relativeY - ((targetSize.height + 1) / 2)); targetBounds.setSize(targetSize); target.setBounds(targetBounds); } /** * Sets the reference figure this locator uses to place the target figure. * * @param reference * the reference figure * @since 2.0 */ public void setReferenceFigure(IFigure reference) { this.reference = reference; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/RotatableDecoration.java000066400000000000000000000017521166301720600302650ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Point; /** * An IFigure that can be rotated. */ public interface RotatableDecoration extends IFigure { /** * Sets the location of this figure. * * @param p * The location */ void setLocation(Point p); /** * Sets the reference point used to determine the rotation angle. * * @param p * The reference point */ void setReferencePoint(Point p); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/RoundedRectangle.java000066400000000000000000000044211166301720600275610ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Rectangle; /** * Draws a Rectangle whose corners are rounded in appearance. The size of the * rectangle is determined by the bounds set to it. */ public class RoundedRectangle extends Shape { /** * The width and height radii applied to each corner. * * @deprecated Use {@link #getCornerDimensions()} instead. */ protected Dimension corner = new Dimension(8, 8); /** * Constructs a round cornered rectangle. */ public RoundedRectangle() { } /** * @see Shape#fillShape(Graphics) */ protected void fillShape(Graphics graphics) { graphics.fillRoundRectangle(getBounds(), corner.width, corner.height); } /** * @see Shape#outlineShape(Graphics) */ protected void outlineShape(Graphics graphics) { float lineInset = Math.max(1.0f, getLineWidthFloat()) / 2.0f; int inset1 = (int) Math.floor(lineInset); int inset2 = (int) Math.ceil(lineInset); Rectangle r = Rectangle.SINGLETON.setBounds(getBounds()); r.x += inset1; r.y += inset1; r.width -= inset1 + inset2; r.height -= inset1 + inset2; graphics.drawRoundRectangle(r, Math.max(0, corner.width - (int) lineInset), Math.max(0, corner.height - (int) lineInset)); } /** * Sets the dimensions of each corner. This will form the radii of the arcs * which form the corners. * * @param d * the dimensions of the corner * @since 2.0 */ public void setCornerDimensions(Dimension d) { corner.width = d.width; corner.height = d.height; } /** * Returns the dimensions used for each corner. * * @return the dimensions of the corner. * @since 3.7 */ public Dimension getCornerDimensions() { return corner.getCopy(); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/RoutingAnimator.java000066400000000000000000000137241166301720600274640ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2005, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.PointList; /** * Animates the routing of a connection. The animator will capture the effects * of the connection's router, and the play back the placement of the routing, * interpolating the intermediate routes. *

* To use a routing animator, hook it as a routing listener for the connection * whose points are to be animated, by calling * {@link PolylineConnection#addRoutingListener(RoutingListener)}. An animator * is active only when the Animation utility is activated. * * @since 3.2 */ public class RoutingAnimator extends Animator implements RoutingListener { static final RoutingAnimator INSTANCE = new RoutingAnimator(); /** * Constructs a routing animator for use with one or more connections. The * default instance ({@link #getDefault()} can be used on any number of * connections. * * @since 3.2 */ protected RoutingAnimator() { } /** * Overridden to sync initial and final states. * * @see Animator#playbackStarting(IFigure) */ public void playbackStarting(IFigure connection) { reconcileStates((Connection) connection); } /** * Returns the current state of the connection. Currently, this is a copy of * the list of points. However this Object could change in future releases * and should not be considered API. * * @see Animator#getCurrentState(IFigure) */ protected Object getCurrentState(IFigure connection) { return ((Connection) connection).getPoints().getCopy(); } /** * Returns the default instance. * * @return the default instance * @since 3.2 */ public static RoutingAnimator getDefault() { return INSTANCE; } /** * Hooks invalidate for animation purposes. * * @see RoutingListener#invalidate(Connection) */ public final void invalidate(Connection conn) { if (Animation.isInitialRecording()) Animation.hookAnimator(conn, this); } /** * Plays back the interpolated state. * * @see Animator#playback(IFigure) */ protected boolean playback(IFigure figure) { Connection conn = (Connection) figure; PointList list1 = (PointList) Animation.getInitialState(this, conn); PointList list2 = (PointList) Animation.getFinalState(this, conn); if (list1 == null) { conn.setVisible(false); return true; } float progress = Animation.getProgress(); if (list1.size() == list2.size()) { Point pt1 = new Point(), pt2 = new Point(); PointList points = conn.getPoints(); points.removeAllPoints(); for (int i = 0; i < list1.size(); i++) { list1.getPoint(pt2, i); list2.getPoint(pt1, i); pt1.x = Math.round(pt1.x * progress + (1 - progress) * pt2.x); pt1.y = Math.round(pt1.y * progress + (1 - progress) * pt2.y); points.addPoint(pt1); } conn.setPoints(points); } return true; } /** * Hooks post routing for animation purposes. * * @see RoutingListener#postRoute(Connection) */ public final void postRoute(Connection connection) { if (Animation.isFinalRecording()) Animation.hookNeedsCapture(connection, this); } private void reconcileStates(Connection conn) { PointList points1 = (PointList) Animation.getInitialState(this, conn); PointList points2 = (PointList) Animation.getFinalState(this, conn); if (points1 != null && points1.size() != points2.size()) { Point p = new Point(), q = new Point(); int size1 = points1.size() - 1; int size2 = points2.size() - 1; int i1 = size1; int i2 = size2; double current1 = 1.0; double current2 = 1.0; double prev1 = 1.0; double prev2 = 1.0; while (i1 > 0 || i2 > 0) { if (Math.abs(current1 - current2) < 0.1 && i1 > 0 && i2 > 0) { // Both points are the same, use them and go on; prev1 = current1; prev2 = current2; i1--; i2--; current1 = (double) i1 / size1; current2 = (double) i2 / size2; } else if (current1 < current2) { // 2 needs to catch up // current1 < current2 < prev1 points1.getPoint(p, i1); points1.getPoint(q, i1 + 1); p.x = (int) (((q.x * (current2 - current1) + p.x * (prev1 - current2)) / (prev1 - current1))); p.y = (int) (((q.y * (current2 - current1) + p.y * (prev1 - current2)) / (prev1 - current1))); points1.insertPoint(p, i1 + 1); prev1 = prev2 = current2; i2--; current2 = (double) i2 / size2; } else { // 1 needs to catch up // current2< current1 < prev2 points2.getPoint(p, i2); points2.getPoint(q, i2 + 1); p.x = (int) (((q.x * (current1 - current2) + p.x * (prev2 - current1)) / (prev2 - current2))); p.y = (int) (((q.y * (current1 - current2) + p.y * (prev2 - current1)) / (prev2 - current2))); points2.insertPoint(p, i2 + 1); prev2 = prev1 = current1; i1--; current1 = (double) i1 / size1; } } } } /** * This callback is unused. Reserved for possible future use. * * @see RoutingListener#remove(Connection) */ public final void remove(Connection connection) { } /** * Hooks route to intercept routing during animation playback. * * @see RoutingListener#route(Connection) */ public final boolean route(Connection conn) { return Animation.isAnimating() && Animation.hookPlayback(conn, this); } /** * This callback is unused. Reserved for possible future use. * * @see RoutingListener#setConstraint(Connection, Object) */ public final void setConstraint(Connection connection, Object constraint) { } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/RoutingListener.java000066400000000000000000000050051166301720600274700ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2005, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; /** * Classes which implement this interface provide callback hooks for various * routing related events. *

* Instances can be hooked to a {@link PolylineConnection} by calling * {@link PolylineConnection#addRoutingListener(RoutingListener)}. * * @since 3.2 */ public interface RoutingListener { /** * Called when the connection has been invalidated. * * @param connection * the connection * @since 3.2 */ void invalidate(Connection connection); /** * Called after normal routing has completed. * * @param connection * the routed connection * @since 3.2 */ void postRoute(Connection connection); /** * Called when a connection has been removed from its router. * * @param connection * the connection * @since 3.2 */ void remove(Connection connection); /** * Called prior to routing occurring. A listener may intercept routing by * returning true. If intercepted, the connection's * ConnectionRouter will not perform routing. * * @param connection * the connection being routed * @return true if routing has been performed by the listener * @since 3.2 */ boolean route(Connection connection); /** * Called when the connection's routing constraint has been set or * initialized. * * @param connection * the connection * @param constraint * the new constraint * @since 3.2 */ void setConstraint(Connection connection, Object constraint); /** * A stub implementation which implements all required methods. * * @since 3.2 */ class Stub implements RoutingListener { public void invalidate(Connection connection) { } public void postRoute(Connection connection) { } public void remove(Connection connection) { } public boolean route(Connection connection) { return false; } public void setConstraint(Connection connection, Object constraint) { } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/SWTEventDispatcher.java000066400000000000000000000407711166301720600300320ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.SWT; import org.eclipse.swt.accessibility.AccessibleControlEvent; import org.eclipse.swt.accessibility.AccessibleControlListener; import org.eclipse.swt.accessibility.AccessibleEvent; import org.eclipse.swt.accessibility.AccessibleListener; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.TraverseEvent; import org.eclipse.swt.graphics.Cursor; import org.eclipse.swt.widgets.Control; /** * The SWTEventDispatcher provides draw2d with the ability to dispatch SWT * Events. The {@link org.eclipse.draw2d.LightweightSystem} adds SWT event * listeners on its Canvas. When the Canvas receives an SWT event, it calls the * appropriate dispatcher method in SWTEventDispatcher. */ public class SWTEventDispatcher extends EventDispatcher { /** * Used to tell if any button is pressed without regard to the specific * button. * * @deprecated Use {@link SWT#BUTTON_MASK} instead. */ protected static final int ANY_BUTTON = SWT.BUTTON_MASK; private boolean figureTraverse = true; private boolean captured; private IFigure root; private IFigure mouseTarget; private IFigure cursorTarget; private IFigure focusOwner; private IFigure hoverSource; private MouseEvent currentEvent; private Cursor cursor; /** The control this dispatcher is listening to. */ protected org.eclipse.swt.widgets.Control control; private ToolTipHelper toolTipHelper; private FocusTraverseManager focusManager = new FocusTraverseManager(); /** * Implements {@link EventDispatcher.AccessibilityDispatcher} but does * nothing in the implementation. */ protected class FigureAccessibilityDispatcher extends AccessibilityDispatcher { /** @see AccessibleControlListener#getChildAtPoint(AccessibleControlEvent) */ public void getChildAtPoint(AccessibleControlEvent e) { } /** @see AccessibleControlListener#getChildCount(AccessibleControlEvent) */ public void getChildCount(AccessibleControlEvent e) { } /** @see AccessibleControlListener#getChildren(AccessibleControlEvent) */ public void getChildren(AccessibleControlEvent e) { } /** @see AccessibleControlListener#getDefaultAction(AccessibleControlEvent) */ public void getDefaultAction(AccessibleControlEvent e) { } /** @see AccessibleListener#getDescription(AccessibleEvent) */ public void getDescription(AccessibleEvent e) { } /** @see AccessibleControlListener#getFocus(AccessibleControlEvent) */ public void getFocus(AccessibleControlEvent e) { } /** @see AccessibleListener#getHelp(AccessibleEvent) */ public void getHelp(AccessibleEvent e) { } /** @see AccessibleListener#getKeyboardShortcut(AccessibleEvent) */ public void getKeyboardShortcut(AccessibleEvent e) { } /** @see AccessibleControlListener#getLocation(AccessibleControlEvent) */ public void getLocation(AccessibleControlEvent e) { } /** @see AccessibleListener#getName(AccessibleEvent) */ public void getName(AccessibleEvent e) { } /** @see AccessibleControlListener#getRole(AccessibleControlEvent) */ public void getRole(AccessibleControlEvent e) { } /** @see AccessibleControlListener#getSelection(AccessibleControlEvent) */ public void getSelection(AccessibleControlEvent e) { } /** @see AccessibleControlListener#getState(AccessibleControlEvent) */ public void getState(AccessibleControlEvent e) { } /** @see AccessibleControlListener#getValue(AccessibleControlEvent) */ public void getValue(AccessibleControlEvent e) { } } /** * @see EventDispatcher#dispatchFocusGained(org.eclipse.swt.events.FocusEvent) */ public void dispatchFocusGained(org.eclipse.swt.events.FocusEvent e) { IFigure currentFocusOwner = getFocusTraverseManager() .getCurrentFocusOwner(); /* * Upon focus gained, if there is no current focus owner, set focus on * first focusable child. */ if (currentFocusOwner == null) currentFocusOwner = getFocusTraverseManager() .getNextFocusableFigure(root, focusOwner); setFocus(currentFocusOwner); } /** * @see EventDispatcher#dispatchFocusLost(org.eclipse.swt.events.FocusEvent) */ public void dispatchFocusLost(org.eclipse.swt.events.FocusEvent e) { setFocus(null); } /** * @see EventDispatcher#dispatchKeyPressed(org.eclipse.swt.events.KeyEvent) */ public void dispatchKeyPressed(org.eclipse.swt.events.KeyEvent e) { if (focusOwner != null) { KeyEvent event = new KeyEvent(this, focusOwner, e); focusOwner.handleKeyPressed(event); } } /** * @see EventDispatcher#dispatchKeyReleased(org.eclipse.swt.events.KeyEvent) */ public void dispatchKeyReleased(org.eclipse.swt.events.KeyEvent e) { if (focusOwner != null) { KeyEvent event = new KeyEvent(this, focusOwner, e); focusOwner.handleKeyReleased(event); } } /** * @see EventDispatcher#dispatchKeyTraversed(TraverseEvent) */ public void dispatchKeyTraversed(TraverseEvent e) { if (!figureTraverse) return; IFigure nextFigure = null; if (e.detail == SWT.TRAVERSE_TAB_NEXT) nextFigure = getFocusTraverseManager().getNextFocusableFigure(root, focusOwner); else if (e.detail == SWT.TRAVERSE_TAB_PREVIOUS) nextFigure = getFocusTraverseManager().getPreviousFocusableFigure( root, focusOwner); if (nextFigure != null) { e.doit = false; setFocus(nextFigure); } } /** * @see EventDispatcher#dispatchMouseHover(org.eclipse.swt.events.MouseEvent) */ public void dispatchMouseHover(org.eclipse.swt.events.MouseEvent me) { receive(me); if (mouseTarget != null) mouseTarget.handleMouseHover(currentEvent); /* * Check Tooltip source. Get Tooltip source's Figure. Set that tooltip * as the lws contents on the helper. */ if (hoverSource != null) { toolTipHelper = getToolTipHelper(); IFigure tip = hoverSource.getToolTip(); Control control = (Control) me.getSource(); org.eclipse.swt.graphics.Point absolute; absolute = control.toDisplay(new org.eclipse.swt.graphics.Point( me.x, me.y)); toolTipHelper.displayToolTipNear(hoverSource, tip, absolute.x, absolute.y); } } /** * @see EventDispatcher#dispatchMouseDoubleClicked(org.eclipse.swt.events.MouseEvent) */ public void dispatchMouseDoubleClicked(org.eclipse.swt.events.MouseEvent me) { receive(me); if (mouseTarget != null) mouseTarget.handleMouseDoubleClicked(currentEvent); } /** * @see EventDispatcher#dispatchMouseEntered(org.eclipse.swt.events.MouseEvent) */ public void dispatchMouseEntered(org.eclipse.swt.events.MouseEvent me) { receive(me); } /** * @see EventDispatcher#dispatchMouseExited(org.eclipse.swt.events.MouseEvent) */ public void dispatchMouseExited(org.eclipse.swt.events.MouseEvent me) { setHoverSource(null, me); if (mouseTarget != null) { currentEvent = new MouseEvent(this, mouseTarget, me); mouseTarget.handleMouseExited(currentEvent); releaseCapture(); mouseTarget = null; } } /** * @see EventDispatcher#dispatchMousePressed(org.eclipse.swt.events.MouseEvent) */ public void dispatchMousePressed(org.eclipse.swt.events.MouseEvent me) { receive(me); if (mouseTarget != null) { mouseTarget.handleMousePressed(currentEvent); if (currentEvent.isConsumed()) setCapture(mouseTarget); } } /** * @see EventDispatcher#dispatchMouseMoved(org.eclipse.swt.events.MouseEvent) */ public void dispatchMouseMoved(org.eclipse.swt.events.MouseEvent me) { receive(me); if (mouseTarget != null) { if ((me.stateMask & SWT.BUTTON_MASK) != 0) mouseTarget.handleMouseDragged(currentEvent); else mouseTarget.handleMouseMoved(currentEvent); } } /** * @see EventDispatcher#dispatchMouseReleased(org.eclipse.swt.events.MouseEvent) */ public void dispatchMouseReleased(org.eclipse.swt.events.MouseEvent me) { receive(me); if (mouseTarget != null) { mouseTarget.handleMouseReleased(currentEvent); } releaseCapture(); receive(me); } /** * @see EventDispatcher#getAccessibilityDispatcher() */ protected AccessibilityDispatcher getAccessibilityDispatcher() { return null; } /** * Returns the current mouse event. * * @return the current mouse event; can be null */ protected MouseEvent getCurrentEvent() { return currentEvent; } private IFigure getCurrentToolTip() { if (hoverSource != null) return hoverSource.getToolTip(); else return null; } /** * Returns the figure that the cursor is over. * * @return the cursor target */ protected IFigure getCursorTarget() { return cursorTarget; } /** * Returns the ToolTipHelper used to display tooltips on hover events. * * @return the ToolTipHelper */ protected ToolTipHelper getToolTipHelper() { if (toolTipHelper == null) toolTipHelper = new ToolTipHelper(control); return toolTipHelper; } /** * Returns the FocusTraverseManager which is used to determine which figure * will get focus when a TAB or ALT+TAB key sequence occurs. * * @return the FocusTraverseManager */ protected final FocusTraverseManager getFocusTraverseManager() { if (focusManager == null) { focusManager = new FocusTraverseManager(); } return focusManager; } /** * @see EventDispatcher#getFocusOwner() * @since 3.6 */ public IFigure getFocusOwner() { return focusOwner; } /** * Returns the figure that is the target of mouse events. This may not be * the figure beneath the cursor because another figure may have captured * the mouse and will continue to get mouse events until capture is * released. * * @return the mouse target */ protected IFigure getMouseTarget() { return mouseTarget; } /** * Returns the root figure for this dispatcher. * * @return the root figure */ protected IFigure getRoot() { return root; } /** * @see EventDispatcher#isCaptured() */ public boolean isCaptured() { return captured; } private void receive(org.eclipse.swt.events.MouseEvent me) { currentEvent = null; updateFigureUnderCursor(me); if (captured) { if (mouseTarget != null) currentEvent = new MouseEvent(this, mouseTarget, me); } else { IFigure f = root.findMouseEventTargetAt(me.x, me.y); if (f == mouseTarget) { if (mouseTarget != null) currentEvent = new MouseEvent(this, mouseTarget, me); return; } if (mouseTarget != null) { currentEvent = new MouseEvent(this, mouseTarget, me); mouseTarget.handleMouseExited(currentEvent); } setMouseTarget(f); if (mouseTarget != null) { currentEvent = new MouseEvent(this, mouseTarget, me); mouseTarget.handleMouseEntered(currentEvent); } } } /** * @see EventDispatcher#releaseCapture() */ protected void releaseCapture() { captured = false; } /** * @see EventDispatcher#requestFocus(IFigure) */ public void requestFocus(IFigure fig) { setFocus(fig); } /** * @see EventDispatcher#requestRemoveFocus(IFigure) */ public void requestRemoveFocus(IFigure fig) { if (getFocusOwner() == fig) setFocus(null); if (mouseTarget == fig) mouseTarget = null; if (cursorTarget == fig) cursorTarget = null; if (hoverSource == fig) hoverSource = null; getFocusTraverseManager().setCurrentFocusOwner(null); } /** * @see EventDispatcher#setCapture(IFigure) */ protected void setCapture(IFigure figure) { captured = true; mouseTarget = figure; } /** * @see EventDispatcher#setControl(Control) */ public void setControl(Control c) { if (c == control) return; if (control != null && !control.isDisposed()) throw new RuntimeException( "Can not set control again once it has been set"); //$NON-NLS-1$ if (c != null) c.addDisposeListener(new org.eclipse.swt.events.DisposeListener() { public void widgetDisposed(DisposeEvent e) { if (toolTipHelper != null) toolTipHelper.dispose(); } }); control = c; } /** * Sets the mouse cursor. * * @param c * the new cursor */ protected void setCursor(Cursor c) { if (c == null && cursor == null) { return; } else if ((c != cursor) || (!c.equals(cursor))) { cursor = c; if (control != null && !control.isDisposed()) control.setCursor(c); } } /** * Enables key traversal via TAB and ALT+TAB if traverse is * true. Disables it otherwise. * * @param traverse * whether key traversal should be enabled */ public void setEnableKeyTraversal(boolean traverse) { figureTraverse = traverse; } /** * Sets the figure under the mouse cursor. * * @param f * the new figure under the cursor */ protected void setFigureUnderCursor(IFigure f) { if (cursorTarget == f) return; cursorTarget = f; updateCursor(); } /** * Sets the focus figure. If the figure currently with focus is not * null, {@link IFigure#handleFocusLost(FocusEvent)} is called * on the current focused figure. If the new focus figure is not * null, this will call * {@link IFigure#handleFocusGained(FocusEvent)} on the new focused figure. * * @param fig * the new focus figure */ protected void setFocus(IFigure fig) { if (fig == focusOwner) return; FocusEvent fe = new FocusEvent(focusOwner, fig); IFigure oldOwner = focusOwner; focusOwner = fig; if (oldOwner != null) oldOwner.handleFocusLost(fe); if (fig != null) getFocusTraverseManager().setCurrentFocusOwner(fig); if (focusOwner != null) focusOwner.handleFocusGained(fe); } /** * Sets the figure that the mouse cursor is hovering over. * * @param figure * the new hover source * @param me * the mouse event */ protected void setHoverSource(Figure figure, org.eclipse.swt.events.MouseEvent me) { hoverSource = figure; if (figure != null) { Control control = (Control) me.getSource(); org.eclipse.swt.graphics.Point absolute; absolute = control.toDisplay(new org.eclipse.swt.graphics.Point( me.x, me.y)); toolTipHelper = getToolTipHelper(); toolTipHelper.updateToolTip(hoverSource, getCurrentToolTip(), absolute.x, absolute.y); } else if (toolTipHelper != null) { // Update with null to clear hoverSource in ToolTipHelper toolTipHelper.updateToolTip(hoverSource, getCurrentToolTip(), me.x, me.y); } } /** * Sets the given figure to be the target of future mouse events. * * @param figure * the new mouse target */ protected void setMouseTarget(IFigure figure) { mouseTarget = figure; } /** * @see EventDispatcher#setRoot(IFigure) */ public void setRoot(IFigure figure) { root = figure; } /** * @see EventDispatcher#updateCursor() */ protected void updateCursor() { Cursor newCursor = null; if (cursorTarget != null) newCursor = cursorTarget.getCursor(); setCursor(newCursor); } /** * Updates the figure under the cursor, unless the mouse is captured, in * which case all mouse events will be routed to the figure that captured * the mouse. * * @param me * the mouse event */ protected void updateFigureUnderCursor(org.eclipse.swt.events.MouseEvent me) { if (!captured) { IFigure f = root.findFigureAt(me.x, me.y); setFigureUnderCursor(f); if (cursorTarget != hoverSource) updateHoverSource(me); } } /** * Updates the figure that will receive hover events. The hover source must * have a tooltip. If the figure under the mouse doesn't have a tooltip set, * this method will walk up the ancestor hierarchy until either a figure * with a tooltip is found or it gets to the root figure. * * @param me * the mouse event */ protected void updateHoverSource(org.eclipse.swt.events.MouseEvent me) { /* * Derive source from figure under cursor. Set the source in * setHoverSource(); If figure.getToolTip() is null, get parent's * toolTip Continue parent traversal until a toolTip is found or root is * reached. */ if (cursorTarget != null) { boolean sourceFound = false; Figure source = (Figure) cursorTarget; while (!sourceFound && source.getParent() != null) { if (source.getToolTip() != null) sourceFound = true; else source = (Figure) source.getParent(); } setHoverSource(source, me); } else { setHoverSource(null, me); } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/SWTGraphics.java000066400000000000000000001146331166301720600265010ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.ArrayList; import java.util.List; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontMetrics; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.LineAttributes; import org.eclipse.swt.graphics.Path; import org.eclipse.swt.graphics.PathData; import org.eclipse.swt.graphics.Pattern; import org.eclipse.swt.graphics.Region; import org.eclipse.swt.graphics.TextLayout; import org.eclipse.swt.graphics.Transform; import org.eclipse.swt.widgets.Display; import org.eclipse.draw2d.geometry.PointList; import org.eclipse.draw2d.geometry.Rectangle; /** * A concrete implementation of Graphics using an SWT * GC. There are 2 states contained in this graphics class -- the * applied state which is the actual state of the GC and the current state which * is the current state of this graphics object. Certain properties can be * changed multiple times and the GC won't be updated until it's actually used. *

* WARNING: This class is not intended to be subclassed. */ public class SWTGraphics extends Graphics { /** * An internal type used to represent and update the GC's clipping. * * @since 3.1 */ interface Clipping { /** * Sets the clip's bounding rectangle into the provided argument and * returns it for convenince. * * @param rect * the rect * @return the given rect * @since 3.1 */ Rectangle getBoundingBox(Rectangle rect); Clipping getCopy(); void intersect(int left, int top, int right, int bottom); void scale(float horizontal, float vertical); void setOn(GC gc, int translateX, int translateY); void translate(float dx, float dy); } /** * Any state stored in this class is only applied when it is needed by a * specific graphics call. * * @since 3.1 */ static class LazyState { Color bgColor; Color fgColor; Font font; int graphicHints; LineAttributes lineAttributes; Clipping relativeClip; } static class RectangleClipping implements Clipping { private float top, left, bottom, right; RectangleClipping(float left, float top, float right, float bottom) { this.left = left; this.right = right; this.bottom = bottom; this.top = top; } RectangleClipping(org.eclipse.swt.graphics.Rectangle rect) { left = rect.x; top = rect.y; right = rect.x + rect.width; bottom = rect.y + rect.height; } RectangleClipping(Rectangle rect) { left = rect.x; top = rect.y; right = rect.right(); bottom = rect.bottom(); } public Rectangle getBoundingBox(Rectangle rect) { rect.x = (int) left; rect.y = (int) top; rect.width = (int) Math.ceil(right) - rect.x; rect.height = (int) Math.ceil(bottom) - rect.y; return rect; } public Clipping getCopy() { return new RectangleClipping(left, top, right, bottom); } public void intersect(int left, int top, final int right, final int bottom) { this.left = Math.max(this.left, left); this.right = Math.min(this.right, right); this.top = Math.max(this.top, top); this.bottom = Math.min(this.bottom, bottom); // use left/top -1 to ensure ceiling function doesn't add a pixel if (this.right < this.left || this.bottom < this.top) { this.right = this.left - 1; this.bottom = this.top - 1; } } public void scale(float horz, float vert) { left /= horz; right /= horz; top /= vert; bottom /= vert; } public void setOn(GC gc, int translateX, int translateY) { int xInt = (int) Math.floor(left); int yInt = (int) Math.floor(top); gc.setClipping(xInt + translateX, yInt + translateY, (int) Math.ceil(right) - xInt, (int) Math.ceil(bottom) - yInt); } public void translate(float dx, float dy) { left += dx; right += dx; top += dy; bottom += dy; } } /** * Contains the entire state of the Graphics. */ static class State extends LazyState implements Cloneable { float affineMatrix[]; int alpha; Pattern bgPattern; int dx, dy; Pattern fgPattern; public Object clone() throws CloneNotSupportedException { State clone = (State) super.clone(); clone.lineAttributes = SWTGraphics.clone(clone.lineAttributes); return clone; } /** * Copies all state information from the given State to this State * * @param state * The State to copy from */ public void copyFrom(State state) { bgColor = state.bgColor; fgColor = state.fgColor; lineAttributes = SWTGraphics.clone(state.lineAttributes); dx = state.dx; dy = state.dy; bgPattern = state.bgPattern; fgPattern = state.fgPattern; font = state.font; graphicHints = state.graphicHints; affineMatrix = state.affineMatrix; relativeClip = state.relativeClip; alpha = state.alpha; } } static final int AA_MASK; static final int AA_SHIFT; static final int AA_WHOLE_NUMBER = 1; static final int ADVANCED_GRAPHICS_MASK; static final int ADVANCED_HINTS_DEFAULTS; static final int ADVANCED_HINTS_MASK; static final int ADVANCED_SHIFT; static final int FILL_RULE_MASK; static final int FILL_RULE_SHIFT; static final int FILL_RULE_WHOLE_NUMBER = -1; static final int INTERPOLATION_MASK; static final int INTERPOLATION_SHIFT; static final int INTERPOLATION_WHOLE_NUMBER = 1; static final int TEXT_AA_MASK; static final int TEXT_AA_SHIFT; static final int XOR_MASK; static final int XOR_SHIFT; static { XOR_SHIFT = 3; AA_SHIFT = 8; TEXT_AA_SHIFT = 10; INTERPOLATION_SHIFT = 12; FILL_RULE_SHIFT = 14; ADVANCED_SHIFT = 15; AA_MASK = 3 << AA_SHIFT; FILL_RULE_MASK = 1 << FILL_RULE_SHIFT; // If changed to more than 1-bit, // check references! INTERPOLATION_MASK = 3 << INTERPOLATION_SHIFT; TEXT_AA_MASK = 3 << TEXT_AA_SHIFT; XOR_MASK = 1 << XOR_SHIFT; ADVANCED_GRAPHICS_MASK = 1 << ADVANCED_SHIFT; ADVANCED_HINTS_MASK = TEXT_AA_MASK | AA_MASK | INTERPOLATION_MASK; ADVANCED_HINTS_DEFAULTS = ((SWT.DEFAULT + AA_WHOLE_NUMBER) << TEXT_AA_SHIFT) | ((SWT.DEFAULT + AA_WHOLE_NUMBER) << AA_SHIFT) | ((SWT.DEFAULT + INTERPOLATION_WHOLE_NUMBER) << INTERPOLATION_SHIFT); } private final LazyState appliedState = new LazyState(); private final State currentState = new State(); private boolean elementsNeedUpdate; private GC gc; private boolean sharedClipping; private List stack = new ArrayList(); private int stackPointer = 0; Transform transform; private int translateX = 0; private int translateY = 0; /** * Constructs a new SWTGraphics that draws to the Canvas using the given GC. * * @param gc * the GC */ public SWTGraphics(GC gc) { this.gc = gc; init(); } /** * If the background color has changed, this change will be pushed to the * GC. Also calls {@link #checkGC()}. */ protected final void checkFill() { if (!currentState.bgColor.equals(appliedState.bgColor) && currentState.bgPattern == null) { gc.setBackground(appliedState.bgColor = currentState.bgColor); } checkGC(); } /** * If the rendering hints or the clip region has changed, these changes will * be pushed to the GC. Rendering hints include anti-alias, xor, join, cap, * line style, fill rule, interpolation, and other settings. */ protected final void checkGC() { if (appliedState.relativeClip != currentState.relativeClip) { appliedState.relativeClip = currentState.relativeClip; currentState.relativeClip.setOn(gc, translateX, translateY); } if (appliedState.graphicHints != currentState.graphicHints) { reconcileHints(gc, appliedState.graphicHints, currentState.graphicHints); appliedState.graphicHints = currentState.graphicHints; } } /** * If the line width, line style, foreground or background colors have * changed, these changes will be pushed to the GC. Also calls * {@link #checkGC()}. */ protected final void checkPaint() { checkGC(); if (!currentState.fgColor.equals(appliedState.fgColor) && currentState.fgPattern == null) { gc.setForeground(appliedState.fgColor = currentState.fgColor); } LineAttributes lineAttributes = currentState.lineAttributes; if (!appliedState.lineAttributes.equals(lineAttributes)) { if (getAdvanced()) { gc.setLineAttributes(lineAttributes); } else { gc.setLineWidth((int) lineAttributes.width); gc.setLineCap(lineAttributes.cap); gc.setLineJoin(lineAttributes.join); gc.setLineStyle(lineAttributes.style); if (lineAttributes.dash != null) { gc.setLineDash(convertFloatArrayToInt(lineAttributes.dash)); } } appliedState.lineAttributes = clone(lineAttributes); } if (!currentState.bgColor.equals(appliedState.bgColor) && currentState.bgPattern == null) { gc.setBackground(appliedState.bgColor = currentState.bgColor); } } /** * @since 3.1 */ private void checkSharedClipping() { if (sharedClipping) { sharedClipping = false; boolean previouslyApplied = (appliedState == currentState.relativeClip); currentState.relativeClip = currentState.relativeClip.getCopy(); if (previouslyApplied) { appliedState.relativeClip = currentState.relativeClip; } } } /** * If the font has changed, this change will be pushed to the GC. Also calls * {@link #checkPaint()} and {@link #checkFill()}. */ protected final void checkText() { checkPaint(); if (!appliedState.font.equals(currentState.font)) { gc.setFont(appliedState.font = currentState.font); } } /** * @see Graphics#clipRect(Rectangle) */ public void clipRect(Rectangle rect) { if (currentState.relativeClip == null) { throw new IllegalStateException( "The current clipping area does not " + //$NON-NLS-1$ "support intersection."); //$NON-NLS-1$ } checkSharedClipping(); currentState.relativeClip.intersect(rect.x, rect.y, rect.right(), rect.bottom()); appliedState.relativeClip = null; } /** * @see Graphics#dispose() */ public void dispose() { while (stackPointer > 0) { popState(); } if (transform != null) { transform.dispose(); } } /** * @see Graphics#drawArc(int, int, int, int, int, int) */ public void drawArc(int x, int y, int width, int height, int offset, int length) { checkPaint(); gc.drawArc(x + translateX, y + translateY, width, height, offset, length); } /** * @see Graphics#drawFocus(int, int, int, int) */ public void drawFocus(int x, int y, int w, int h) { checkPaint(); gc.drawFocus(x + translateX, y + translateY, w + 1, h + 1); } /** * @see Graphics#drawImage(Image, int, int) */ public void drawImage(Image srcImage, int x, int y) { checkGC(); gc.drawImage(srcImage, x + translateX, y + translateY); } /** * @see Graphics#drawImage(Image, int, int, int, int, int, int, int, int) */ public void drawImage(Image srcImage, int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2) { checkGC(); gc.drawImage(srcImage, x1, y1, w1, h1, x2 + translateX, y2 + translateY, w2, h2); } /** * @see Graphics#drawLine(int, int, int, int) */ public void drawLine(int x1, int y1, int x2, int y2) { checkPaint(); gc.drawLine(x1 + translateX, y1 + translateY, x2 + translateX, y2 + translateY); } /** * @see Graphics#drawOval(int, int, int, int) */ public void drawOval(int x, int y, int width, int height) { checkPaint(); gc.drawOval(x + translateX, y + translateY, width, height); } /** * This method requires advanced graphics support. A check should be made to * ensure advanced graphics is supported in the user's environment before * calling this method. See {@link GC#getAdvanced()}. * * @see Graphics#drawPath(Path) */ public void drawPath(Path path) { checkPaint(); initTransform(false); gc.drawPath(path); } /** * @see Graphics#drawPoint(int, int) */ public void drawPoint(int x, int y) { checkPaint(); gc.drawPoint(x + translateX, y + translateY); } /** * @see Graphics#drawPolygon(int[]) */ public void drawPolygon(int[] points) { checkPaint(); try { translatePointArray(points, translateX, translateY); gc.drawPolygon(points); } finally { translatePointArray(points, -translateX, -translateY); } } /** * @see Graphics#drawPolygon(PointList) */ public void drawPolygon(PointList points) { drawPolygon(points.toIntArray()); } /** * @see Graphics#drawPolyline(int[]) */ public void drawPolyline(int[] points) { checkPaint(); try { translatePointArray(points, translateX, translateY); gc.drawPolyline(points); } finally { translatePointArray(points, -translateX, -translateY); } } /** * @see Graphics#drawPolyline(PointList) */ public void drawPolyline(PointList points) { drawPolyline(points.toIntArray()); } /** * @see Graphics#drawRectangle(int, int, int, int) */ public void drawRectangle(int x, int y, int width, int height) { checkPaint(); gc.drawRectangle(x + translateX, y + translateY, width, height); } /** * @see Graphics#drawRoundRectangle(Rectangle, int, int) */ public void drawRoundRectangle(Rectangle r, int arcWidth, int arcHeight) { checkPaint(); gc.drawRoundRectangle(r.x + translateX, r.y + translateY, r.width, r.height, arcWidth, arcHeight); } /** * @see Graphics#drawString(String, int, int) */ public void drawString(String s, int x, int y) { checkText(); gc.drawString(s, x + translateX, y + translateY, true); } /** * @see Graphics#drawText(String, int, int) */ public void drawText(String s, int x, int y) { checkText(); gc.drawText(s, x + translateX, y + translateY, true); } /** * @see Graphics#drawTextLayout(TextLayout, int, int, int, int, Color, * Color) */ public void drawTextLayout(TextLayout layout, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground) { // $TODO probably just call checkPaint since Font and BG color don't // apply checkText(); layout.draw(gc, x + translateX, y + translateY, selectionStart, selectionEnd, selectionForeground, selectionBackground); } /** * @see Graphics#fillArc(int, int, int, int, int, int) */ public void fillArc(int x, int y, int width, int height, int offset, int length) { checkFill(); gc.fillArc(x + translateX, y + translateY, width, height, offset, length); } /** * @see Graphics#fillGradient(int, int, int, int, boolean) */ public void fillGradient(int x, int y, int w, int h, boolean vertical) { checkPaint(); gc.fillGradientRectangle(x + translateX, y + translateY, w, h, vertical); } /** * @see Graphics#fillOval(int, int, int, int) */ public void fillOval(int x, int y, int width, int height) { checkFill(); gc.fillOval(x + translateX, y + translateY, width, height); } /** * This method requires advanced graphics support. A check should be made to * ensure advanced graphics is supported in the user's environment before * calling this method. See {@link GC#getAdvanced()}. * * @see Graphics#fillPath(Path) */ public void fillPath(Path path) { checkFill(); initTransform(false); gc.fillPath(path); } /** * @see Graphics#fillPolygon(int[]) */ public void fillPolygon(int[] points) { checkFill(); try { translatePointArray(points, translateX, translateY); gc.fillPolygon(points); } finally { translatePointArray(points, -translateX, -translateY); } } /** * @see Graphics#fillPolygon(PointList) */ public void fillPolygon(PointList points) { fillPolygon(points.toIntArray()); } /** * @see Graphics#fillRectangle(int, int, int, int) */ public void fillRectangle(int x, int y, int width, int height) { checkFill(); gc.fillRectangle(x + translateX, y + translateY, width, height); } /** * @see Graphics#fillRoundRectangle(Rectangle, int, int) */ public void fillRoundRectangle(Rectangle r, int arcWidth, int arcHeight) { checkFill(); gc.fillRoundRectangle(r.x + translateX, r.y + translateY, r.width, r.height, arcWidth, arcHeight); } /** * @see Graphics#fillString(String, int, int) */ public void fillString(String s, int x, int y) { checkText(); gc.drawString(s, x + translateX, y + translateY, false); } /** * @see Graphics#fillText(String, int, int) */ public void fillText(String s, int x, int y) { checkText(); gc.drawText(s, x + translateX, y + translateY, false); } /** * @see Graphics#getAlpha() */ public int getAlpha() { return currentState.alpha; } /** * @see Graphics#getAntialias() */ public int getAntialias() { return ((currentState.graphicHints & AA_MASK) >> AA_SHIFT) - AA_WHOLE_NUMBER; } public boolean getAdvanced() { return (currentState.graphicHints & ADVANCED_GRAPHICS_MASK) != 0; } /** * @see Graphics#getBackgroundColor() */ public Color getBackgroundColor() { return currentState.bgColor; } /** * @see Graphics#getClip(Rectangle) */ public Rectangle getClip(Rectangle rect) { if (currentState.relativeClip != null) { currentState.relativeClip.getBoundingBox(rect); return rect; } else { throw new IllegalStateException( "Clipping can no longer be queried due to transformations"); //$NON-NLS-1$ } } /** * @see Graphics#getFillRule() */ public int getFillRule() { return ((currentState.graphicHints & FILL_RULE_MASK) >> FILL_RULE_SHIFT) - FILL_RULE_WHOLE_NUMBER; } /** * @see Graphics#getFont() */ public Font getFont() { return currentState.font; } /** * @see Graphics#getFontMetrics() */ public FontMetrics getFontMetrics() { checkText(); return gc.getFontMetrics(); } /** * @see Graphics#getForegroundColor() */ public Color getForegroundColor() { return currentState.fgColor; } /** * @see Graphics#getInterpolation() */ public int getInterpolation() { return ((currentState.graphicHints & INTERPOLATION_MASK) >> INTERPOLATION_SHIFT) - INTERPOLATION_WHOLE_NUMBER; } /** * @since 3.5 */ public void getLineAttributes(LineAttributes lineAttributes) { copyLineAttributes(lineAttributes, currentState.lineAttributes); } /** * @see Graphics#getLineCap() */ public int getLineCap() { return currentState.lineAttributes.cap; } /** * @see Graphics#getLineJoin() */ public int getLineJoin() { return currentState.lineAttributes.join; } /** * @see Graphics#getLineStyle() */ public int getLineStyle() { return currentState.lineAttributes.style; } /** * @see Graphics#getLineWidth() */ public int getLineWidth() { return (int) currentState.lineAttributes.width; } public float getLineWidthFloat() { return currentState.lineAttributes.width; } public float getLineMiterLimit() { return currentState.lineAttributes.miterLimit; } /** * @since 3.5 */ public float[] getLineDash() { return (float[]) currentState.lineAttributes.dash.clone(); } /** * @since 3.5 */ public float getLineDashOffset() { return currentState.lineAttributes.dashOffset; } /** * @see Graphics#getTextAntialias() */ public int getTextAntialias() { return ((currentState.graphicHints & TEXT_AA_MASK) >> TEXT_AA_SHIFT) - AA_WHOLE_NUMBER; } /** * @see Graphics#getXORMode() */ public boolean getXORMode() { return (currentState.graphicHints & XOR_MASK) != 0; } /** * Called by constructor, initializes all State information for currentState */ protected void init() { currentState.bgColor = appliedState.bgColor = gc.getBackground(); currentState.fgColor = appliedState.fgColor = gc.getForeground(); currentState.font = appliedState.font = gc.getFont(); currentState.lineAttributes = gc.getLineAttributes(); appliedState.lineAttributes = clone(currentState.lineAttributes); currentState.graphicHints |= gc.getLineStyle(); currentState.graphicHints |= gc.getAdvanced() ? ADVANCED_GRAPHICS_MASK : 0; currentState.graphicHints |= gc.getXORMode() ? XOR_MASK : 0; appliedState.graphicHints = currentState.graphicHints; currentState.relativeClip = new RectangleClipping(gc.getClipping()); currentState.alpha = gc.getAlpha(); } private void initTransform(boolean force) { if (!force && translateX == 0 && translateY == 0) { return; } if (transform == null) { transform = new Transform(Display.getCurrent()); elementsNeedUpdate = true; transform.translate(translateX, translateY); translateX = 0; translateY = 0; gc.setTransform(transform); currentState.graphicHints |= ADVANCED_GRAPHICS_MASK; } } /** * @see Graphics#popState() */ public void popState() { stackPointer--; restoreState((State) stack.get(stackPointer)); } /** * @see Graphics#pushState() */ public void pushState() { if (currentState.relativeClip == null) { throw new IllegalStateException( "The clipping has been modified in" + //$NON-NLS-1$ "a way that cannot be saved and restored."); //$NON-NLS-1$ } try { State s; currentState.dx = translateX; currentState.dy = translateY; if (elementsNeedUpdate) { elementsNeedUpdate = false; transform.getElements(currentState.affineMatrix = new float[6]); } if (stack.size() > stackPointer) { s = (State) stack.get(stackPointer); s.copyFrom(currentState); } else { stack.add(currentState.clone()); } sharedClipping = true; stackPointer++; } catch (CloneNotSupportedException e) { throw new RuntimeException(e); } } private static void reconcileHints(GC gc, int applied, int hints) { int changes = hints ^ applied; if ((changes & XOR_MASK) != 0) { gc.setXORMode((hints & XOR_MASK) != 0); } // Check to see if there is anything remaining changes &= ~XOR_MASK; if (changes != 0) { if ((changes & INTERPOLATION_MASK) != 0) { gc.setInterpolation(((hints & INTERPOLATION_MASK) >> INTERPOLATION_SHIFT) - INTERPOLATION_WHOLE_NUMBER); } if ((changes & FILL_RULE_MASK) != 0) { gc.setFillRule(((hints & FILL_RULE_MASK) >> FILL_RULE_SHIFT) - FILL_RULE_WHOLE_NUMBER); } if ((changes & AA_MASK) != 0) { gc.setAntialias(((hints & AA_MASK) >> AA_SHIFT) - AA_WHOLE_NUMBER); } if ((changes & TEXT_AA_MASK) != 0) { gc.setTextAntialias(((hints & TEXT_AA_MASK) >> TEXT_AA_SHIFT) - AA_WHOLE_NUMBER); } // If advanced was flagged, but none of the conditions which trigger // advanced // actually got applied, force advanced graphics on. if ((changes & ADVANCED_GRAPHICS_MASK) != 0) { if ((hints & ADVANCED_GRAPHICS_MASK) != 0 && !gc.getAdvanced()) { gc.setAdvanced(true); } } } } /** * @see Graphics#restoreState() */ public void restoreState() { restoreState((State) stack.get(stackPointer - 1)); } /** * Sets all State information to that of the given State, called by * restoreState() * * @param s * the State */ protected void restoreState(State s) { /* * We must set the transformation matrix first since it affects things * like clipping regions and patterns. */ setAffineMatrix(s.affineMatrix); currentState.relativeClip = s.relativeClip; sharedClipping = true; // If the GC is currently advanced, but it was not when pushed, revert if (gc.getAdvanced() && (s.graphicHints & ADVANCED_GRAPHICS_MASK) == 0) { // Set applied clip to null to force a re-setting of the clipping. appliedState.relativeClip = null; gc.setAdvanced(false); appliedState.graphicHints &= ~ADVANCED_HINTS_MASK; appliedState.graphicHints |= ADVANCED_HINTS_DEFAULTS; } setBackgroundColor(s.bgColor); setBackgroundPattern(s.bgPattern); setForegroundColor(s.fgColor); setForegroundPattern(s.fgPattern); setAlpha(s.alpha); setLineAttributes(s.lineAttributes); setFont(s.font); // This method must come last because above methods will incorrectly set // advanced state setGraphicHints(s.graphicHints); translateX = currentState.dx = s.dx; translateY = currentState.dy = s.dy; } /** * This method requires advanced graphics support. A check should be made to * ensure advanced graphics is supported in the user's environment before * calling this method. See {@link GC#getAdvanced()}. * * @see Graphics#rotate(float) */ public void rotate(float degrees) { // Flush clipping, patter, etc., before applying transform checkGC(); initTransform(true); transform.rotate(degrees); gc.setTransform(transform); elementsNeedUpdate = true; // Can no longer operate or maintain clipping appliedState.relativeClip = currentState.relativeClip = null; } /** * @see Graphics#scale(double) */ public void scale(double factor) { scale((float) factor, (float) factor); } /** * This method requires advanced graphics support. A check should be made to * ensure advanced graphics is supported in the user's environment before * calling this method. See {@link GC#getAdvanced()}. * * @see org.eclipse.draw2d.Graphics#scale(float, float) */ public void scale(float horizontal, float vertical) { // Flush any clipping before scaling checkGC(); initTransform(true); transform.scale(horizontal, vertical); gc.setTransform(transform); elementsNeedUpdate = true; checkSharedClipping(); if (currentState.relativeClip != null) currentState.relativeClip.scale(horizontal, vertical); } private void setAffineMatrix(float[] m) { if (!elementsNeedUpdate && currentState.affineMatrix == m) return; currentState.affineMatrix = m; if (m != null) transform.setElements(m[0], m[1], m[2], m[3], m[4], m[5]); else if (transform != null) { transform.dispose(); transform = null; elementsNeedUpdate = false; } gc.setTransform(transform); } /** * This method requires advanced graphics support. A check should be made to * ensure advanced graphics is supported in the user's environment before * calling this method. See {@link GC#getAdvanced()}. * * @see Graphics#setAlpha(int) */ public void setAlpha(int alpha) { currentState.graphicHints |= ADVANCED_GRAPHICS_MASK; if (currentState.alpha != alpha) gc.setAlpha(this.currentState.alpha = alpha); } /** * This method requires advanced graphics support. A check should be made to * ensure advanced graphics is supported in the user's environment before * calling this method. See {@link GC#getAdvanced()}. * * @see Graphics#setAntialias(int) */ public void setAntialias(int value) { currentState.graphicHints &= ~AA_MASK; currentState.graphicHints |= ADVANCED_GRAPHICS_MASK | (value + AA_WHOLE_NUMBER) << AA_SHIFT; } public void setAdvanced(boolean value) { if (value) { currentState.graphicHints |= ADVANCED_GRAPHICS_MASK; } else { currentState.graphicHints &= ~ADVANCED_GRAPHICS_MASK; } } /** * @see Graphics#setBackgroundColor(Color) */ public void setBackgroundColor(Color color) { currentState.bgColor = color; if (currentState.bgPattern != null) { currentState.bgPattern = null; // Force the BG color to be stale appliedState.bgColor = null; } } /** * @see Graphics#setBackgroundPattern(Pattern) */ public void setBackgroundPattern(Pattern pattern) { currentState.graphicHints |= ADVANCED_GRAPHICS_MASK; if (currentState.bgPattern == pattern) { return; } currentState.bgPattern = pattern; if (pattern != null) { initTransform(true); } gc.setBackgroundPattern(pattern); } /** * This method requires advanced graphics support. A check should be made to * ensure advanced graphics is supported in the user's environment before * calling this method. See {@link GC#getAdvanced()}. * * @see Graphics#setClip(Path) */ public void setClip(Path path) { initTransform(false); if (((appliedState.graphicHints ^ currentState.graphicHints) & FILL_RULE_MASK) != 0) { // If there is a pending change to the fill rule, apply it first. gc.setFillRule(((currentState.graphicHints & FILL_RULE_MASK) >> FILL_RULE_SHIFT) - FILL_RULE_WHOLE_NUMBER); // As long as the FILL_RULE is stored in a single bit, just toggling // it works. appliedState.graphicHints ^= FILL_RULE_MASK; } gc.setClipping(path); appliedState.relativeClip = currentState.relativeClip = null; } /** * Simple implementation of clipping a Path within the context of current * clipping rectangle for now (not region)

  • Note that this method wipes * out the clipping rectangle area, hence if clients need to reset it call * {@link #restoreState()} * * @see org.eclipse.draw2d.Graphics#clipPath(org.eclipse.swt.graphics.Path) */ public void clipPath(Path path) { initTransform(false); if (((appliedState.graphicHints ^ currentState.graphicHints) & FILL_RULE_MASK) != 0) { // If there is a pending change to the fill rule, apply it first. gc.setFillRule(((currentState.graphicHints & FILL_RULE_MASK) >> FILL_RULE_SHIFT) - FILL_RULE_WHOLE_NUMBER); // As long as the FILL_RULE is stored in a single bit, just toggling // it works. appliedState.graphicHints ^= FILL_RULE_MASK; } Rectangle clipping = currentState.relativeClip != null ? getClip(new Rectangle()) : new Rectangle(); if (!clipping.isEmpty()) { Path flatPath = new Path(path.getDevice(), path, 0.01f); PathData pathData = flatPath.getPathData(); flatPath.dispose(); Region region = new Region(path.getDevice()); loadPath(region, pathData.points, pathData.types); region.intersect(new org.eclipse.swt.graphics.Rectangle(clipping.x, clipping.y, clipping.width, clipping.height)); gc.setClipping(region); appliedState.relativeClip = currentState.relativeClip = null; region.dispose(); } } /** * @see Graphics#setClip(Rectangle) */ public void setClip(Rectangle rect) { currentState.relativeClip = new RectangleClipping(rect); } /** * @see Graphics#setFillRule(int) */ public void setFillRule(int rule) { currentState.graphicHints &= ~FILL_RULE_MASK; currentState.graphicHints |= (rule + FILL_RULE_WHOLE_NUMBER) << FILL_RULE_SHIFT; } /** * @see Graphics#setFont(Font) */ public void setFont(Font f) { currentState.font = f; } /** * @see Graphics#setForegroundColor(Color) */ public void setForegroundColor(Color color) { currentState.fgColor = color; if (currentState.fgPattern != null) { currentState.fgPattern = null; // Force fgColor to be stale appliedState.fgColor = null; } } /** * @see Graphics#setForegroundPattern(Pattern) */ public void setForegroundPattern(Pattern pattern) { currentState.graphicHints |= ADVANCED_GRAPHICS_MASK; if (currentState.fgPattern == pattern) { return; } currentState.fgPattern = pattern; if (pattern != null) { initTransform(true); } gc.setForegroundPattern(pattern); } private void setGraphicHints(int hints) { currentState.graphicHints = hints; } /** * This method requires advanced graphics support. A check should be made to * ensure advanced graphics is supported in the user's environment before * calling this method. See {@link GC#getAdvanced()}. * * @see Graphics#setInterpolation(int) */ public void setInterpolation(int interpolation) { // values range [-1, 3] currentState.graphicHints &= ~INTERPOLATION_MASK; currentState.graphicHints |= ADVANCED_GRAPHICS_MASK | (interpolation + INTERPOLATION_WHOLE_NUMBER) << INTERPOLATION_SHIFT; } public void setLineAttributes(LineAttributes lineAttributes) { copyLineAttributes(currentState.lineAttributes, lineAttributes); } /** * @see Graphics#setLineCap(int) */ public void setLineCap(int value) { currentState.lineAttributes.cap = value; } /** * @see Graphics#setLineDash(int[]) */ public void setLineDash(int[] dashes) { float[] fArray = null; if (dashes != null) { fArray = new float[dashes.length]; for (int i = 0; i < dashes.length; i++) { fArray[i] = dashes[i]; } } setLineDash(fArray); } /** * @param value * @since 3.5 */ public void setLineDash(float[] value) { if (value != null) { // validate dash values for (int i = 0; i < value.length; i++) { if (value[i] <= 0) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } } currentState.lineAttributes.dash = (float[]) value.clone(); currentState.lineAttributes.style = SWT.LINE_CUSTOM; } else { currentState.lineAttributes.dash = null; currentState.lineAttributes.style = SWT.LINE_SOLID; } } /** * @since 3.5 */ public void setLineDashOffset(float value) { currentState.lineAttributes.dashOffset = value; } /** * @see Graphics#setLineJoin(int) */ public void setLineJoin(int value) { currentState.lineAttributes.join = value; } /** * @see Graphics#setLineStyle(int) */ public void setLineStyle(int value) { currentState.lineAttributes.style = value; } /** * @see Graphics#setLineWidth(int) */ public void setLineWidth(int width) { currentState.lineAttributes.width = width; } public void setLineWidthFloat(float value) { currentState.lineAttributes.width = value; } public void setLineMiterLimit(float value) { currentState.lineAttributes.miterLimit = value; } /** * This method requires advanced graphics support. A check should be made to * ensure advanced graphics is supported in the user's environment before * calling this method. See {@link GC#getAdvanced()}. * * @see Graphics#setTextAntialias(int) */ public void setTextAntialias(int value) { currentState.graphicHints &= ~TEXT_AA_MASK; currentState.graphicHints |= ADVANCED_GRAPHICS_MASK | (value + AA_WHOLE_NUMBER) << TEXT_AA_SHIFT; } /** * @see Graphics#setXORMode(boolean) */ public void setXORMode(boolean xor) { currentState.graphicHints &= ~XOR_MASK; if (xor) { currentState.graphicHints |= XOR_MASK; } } /** * This method requires advanced graphics support. A check should be made to * ensure advanced graphics is supported in the user's environment before * calling this method. See {@link GC#getAdvanced()}. * * @see Graphics#shear(float, float) */ public void shear(float horz, float vert) { // Flush any clipping changes before shearing checkGC(); initTransform(true); float matrix[] = new float[6]; transform.getElements(matrix); transform.setElements(matrix[0] + matrix[2] * vert, matrix[1] + matrix[3] * vert, matrix[0] * horz + matrix[2], matrix[1] * horz + matrix[3], matrix[4], matrix[5]); gc.setTransform(transform); elementsNeedUpdate = true; // Can no longer track clipping changes appliedState.relativeClip = currentState.relativeClip = null; } /** * This method may require advanced graphics support if using a transform, * in this case, a check should be made to ensure advanced graphics is * supported in the user's environment before calling this method. See * {@link GC#getAdvanced()}. * * @see Graphics#translate(int, int) */ public void translate(int dx, int dy) { if (dx == 0 && dy == 0) return; if (transform != null) { // Flush clipping, pattern, etc. before applying transform checkGC(); transform.translate(dx, dy); elementsNeedUpdate = true; gc.setTransform(transform); } else { translateX += dx; translateY += dy; } checkSharedClipping(); if (currentState.relativeClip != null) currentState.relativeClip.translate(-dx, -dy); } /** * This method requires advanced graphics support. A check should be made to * ensure advanced graphics is supported in the user's environment before * calling this method. See {@link GC#getAdvanced()}. * * @see Graphics#translate(float, float) */ public void translate(float dx, float dy) { initTransform(true); checkGC(); transform.translate(dx, dy); elementsNeedUpdate = true; gc.setTransform(transform); checkSharedClipping(); if (currentState.relativeClip != null) currentState.relativeClip.translate(-dx, -dy); } private void translatePointArray(int[] points, int translateX, int translateY) { if (translateX == 0 && translateY == 0) return; for (int i = 0; (i + 1) < points.length; i += 2) { points[i] += translateX; points[i + 1] += translateY; } } /** * Countermeasure against LineAttributes class not having its own clone() * method. * * @since 3.6 */ public static LineAttributes clone(LineAttributes src) { float[] dashClone = null; if (src.dash != null) { dashClone = new float[src.dash.length]; System.arraycopy(src.dash, 0, dashClone, 0, dashClone.length); } return new LineAttributes(src.width, src.cap, src.join, src.style, dashClone, src.dashOffset, src.miterLimit); } /** * Countermeasure against LineAttributes class not having a copy by value * function. * * @since 3.6 */ public static void copyLineAttributes(LineAttributes dest, LineAttributes src) { if (dest != src) { dest.cap = src.cap; dest.join = src.join; dest.miterLimit = src.miterLimit; dest.style = src.style; dest.width = src.width; dest.dashOffset = src.dashOffset; if (src.dash == null) { dest.dash = null; } else { if ((dest.dash == null) || (dest.dash.length != src.dash.length)) { dest.dash = new float[src.dash.length]; } System.arraycopy(src.dash, 0, dest.dash, 0, src.dash.length); } } } /** * Utility method for use with countermeasure against passing line * attributes to SWT forcing advanced graphics. * * @return * @since 3.2 */ private static int[] convertFloatArrayToInt(float[] fArray) { int[] iArray = null; if (fArray != null) { int arrayLen = fArray.length; iArray = new int[arrayLen]; for (int i = 0; i < arrayLen; i++) { iArray[i] = (int) fArray[i]; } } return iArray; } static void loadPath(Region region, float[] points, byte[] types) { int start = 0, end = 0; for (int i = 0; i < types.length; i++) { switch (types[i]) { case SWT.PATH_MOVE_TO: { if (start != end) { int n = 0; int[] temp = new int[end - start]; for (int k = start; k < end; k++) { temp[n++] = Math.round(points[k]); } region.add(temp); } start = end; end += 2; break; } case SWT.PATH_LINE_TO: { end += 2; break; } case SWT.PATH_CLOSE: { if (start != end) { int n = 0; int[] temp = new int[end - start]; for (int k = start; k < end; k++) { temp[n++] = Math.round(points[k]); } region.add(temp); } start = end; break; } } } if (start != end) { int n = 0; int[] temp = new int[end - start]; for (int k = start; k < end; k++) { temp[n++] = Math.round(points[k]); } region.add(temp); } } }eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ScalableFigure.java000066400000000000000000000016331166301720600272060ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; /** * A figure that can be scaled. * * @author Eric Bordeau * @since 2.1.1 */ public interface ScalableFigure extends IFigure { /** * Returns the current scale. * * @return the current scale */ double getScale(); /** * Sets the new scale factor. * * @param scale * the scale */ void setScale(double scale); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ScalableFreeformLayeredPane.java000066400000000000000000000051141166301720600316420ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.draw2d.geometry.Translatable; /** * @author hudsonr * @since 2.1 */ public class ScalableFreeformLayeredPane extends FreeformLayeredPane implements ScalableFigure { private double scale = 1.0; /** * @see org.eclipse.draw2d.Figure#getClientArea() */ public Rectangle getClientArea(Rectangle rect) { super.getClientArea(rect); rect.width /= scale; rect.height /= scale; rect.x /= scale; rect.y /= scale; return rect; } /** * Returns the current zoom scale level. * * @return the scale */ public double getScale() { return scale; } /** * @see org.eclipse.draw2d.IFigure#isCoordinateSystem() */ public boolean isCoordinateSystem() { return true; } /** * @see org.eclipse.draw2d.Figure#paintClientArea(Graphics) */ protected void paintClientArea(Graphics graphics) { if (getChildren().isEmpty()) return; if (scale == 1.0) { super.paintClientArea(graphics); } else { ScaledGraphics g = new ScaledGraphics(graphics); boolean optimizeClip = getBorder() == null || getBorder().isOpaque(); if (!optimizeClip) g.clipRect(getBounds().getCropped(getInsets())); g.scale(scale); g.pushState(); paintChildren(g); g.dispose(); graphics.restoreState(); } } /** * Sets the zoom level * * @param newZoom * The new zoom level */ public void setScale(double newZoom) { if (scale == newZoom) return; scale = newZoom; superFireMoved(); // For AncestorListener compatibility getFreeformHelper().invalidate(); repaint(); } /** * @see org.eclipse.draw2d.Figure#translateToParent(Translatable) */ public void translateToParent(Translatable t) { t.performScale(scale); } /** * @see org.eclipse.draw2d.Figure#translateFromParent(Translatable) */ public void translateFromParent(Translatable t) { t.performScale(1 / scale); } /** * @see org.eclipse.draw2d.Figure#useLocalCoordinates() */ protected final boolean useLocalCoordinates() { return false; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ScalableLayeredPane.java000066400000000000000000000066231166301720600301620ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.SWT; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.draw2d.geometry.Translatable; /** * A non-freeform, scalable layered pane. * * @author Eric Bordeau * @since 2.1.1 */ public class ScalableLayeredPane extends LayeredPane implements ScalableFigure { private double scale = 1.0; /** * @see IFigure#getClientArea(Rectangle) */ public Rectangle getClientArea(Rectangle rect) { super.getClientArea(rect); rect.width /= scale; rect.height /= scale; rect.x /= scale; rect.y /= scale; return rect; } /** * @see Figure#getPreferredSize(int, int) */ public Dimension getMinimumSize(int wHint, int hHint) { Dimension d = super .getMinimumSize( wHint != SWT.DEFAULT ? (int) (wHint / getScale()) : SWT.DEFAULT, hHint != SWT.DEFAULT ? (int) (hHint / getScale()) : SWT.DEFAULT); int w = getInsets().getWidth(); int h = getInsets().getHeight(); return d.getExpanded(-w, -h).scale(scale).expand(w, h); } /** * @see Figure#getPreferredSize(int, int) */ public Dimension getPreferredSize(int wHint, int hHint) { Dimension d = super .getPreferredSize( wHint != SWT.DEFAULT ? (int) (wHint / getScale()) : SWT.DEFAULT, hHint != SWT.DEFAULT ? (int) (hHint / getScale()) : SWT.DEFAULT); int w = getInsets().getWidth(); int h = getInsets().getHeight(); return d.getExpanded(-w, -h).scale(scale).expand(w, h); } /** * Returns the scale level, default is 1.0. * * @return the scale level */ public double getScale() { return scale; } /** * @see org.eclipse.draw2d.IFigure#isCoordinateSystem() */ public boolean isCoordinateSystem() { return true; } /** * @see org.eclipse.draw2d.Figure#paintClientArea(Graphics) */ protected void paintClientArea(Graphics graphics) { if (getChildren().isEmpty()) return; if (scale == 1.0) { super.paintClientArea(graphics); } else { ScaledGraphics g = new ScaledGraphics(graphics); boolean optimizeClip = getBorder() == null || getBorder().isOpaque(); if (!optimizeClip) g.clipRect(getBounds().getCropped(getInsets())); g.scale(scale); g.pushState(); paintChildren(g); g.dispose(); graphics.restoreState(); } } /** * Sets the zoom level * * @param newZoom * The new zoom level */ public void setScale(double newZoom) { if (scale == newZoom) return; scale = newZoom; fireMoved(); // for AncestorListener compatibility revalidate(); repaint(); } /** * @see org.eclipse.draw2d.Figure#translateFromParent(Translatable) */ public void translateFromParent(Translatable t) { t.performScale(1 / scale); } /** * @see org.eclipse.draw2d.Figure#translateToParent(Translatable) */ public void translateToParent(Translatable t) { t.performScale(scale); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ScalablePolygonShape.java000066400000000000000000000075551166301720600304060ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2008, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Alexander Shatalin (Borland) - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Geometry; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.PointList; import org.eclipse.draw2d.geometry.Rectangle; /** * Renders a {@link org.eclipse.draw2d.geometry.PointList} as a polygonal shape * scaled in accordance with bounds to fill whole figure. This class is similar * to {@link PolygonShape}, except the polygon should be scaled * expanded/compressed to fit in current bounds. * * @since 3.5 */ public class ScalablePolygonShape extends AbstractPointListShape { private static final Rectangle TEMPLATEBOUNDS = Rectangle.SINGLETON; private PointList scaledPoints; protected boolean shapeContainsPoint(int x, int y) { Point location = getLocation(); return Geometry.polygonContainsPoint(getScaledPoints(), x - location.x, y - location.y); } protected void fillShape(Graphics graphics) { graphics.pushState(); graphics.translate(getLocation()); graphics.fillPolygon(getScaledPoints()); graphics.popState(); } protected void outlineShape(Graphics graphics) { graphics.pushState(); graphics.translate(getLocation()); graphics.drawPolygon(getScaledPoints()); graphics.popState(); } private Rectangle getTemplateBounds() { TEMPLATEBOUNDS.setLocation(0, 0); TEMPLATEBOUNDS.setSize(0, 0); int[] intArray = points.toIntArray(); for (int i = 0; i < intArray.length;) { int x = intArray[i++]; if (x > TEMPLATEBOUNDS.width) { TEMPLATEBOUNDS.width = x; } int y = intArray[i++]; if (y > TEMPLATEBOUNDS.height) { TEMPLATEBOUNDS.height = y; } } return TEMPLATEBOUNDS; } public PointList getScaledPoints() { if (scaledPoints != null) { return scaledPoints; } Rectangle pointsBounds = getTemplateBounds(); Rectangle actualBounds = getBounds(); double xScale = actualBounds.width > lineWidth ? ((double) actualBounds.width - lineWidth) / pointsBounds.width : 0; double yScale = actualBounds.height > lineWidth ? ((double) actualBounds.height - lineWidth) / pointsBounds.height : 0; double halfLineWidth = ((double) lineWidth) / 2; int[] pointsArray = points.getCopy().toIntArray(); for (int i = 0; i < pointsArray.length; i = i + 2) { pointsArray[i] = (int) (Math.floor(pointsArray[i] * xScale) + halfLineWidth); pointsArray[i + 1] = (int) (Math.floor(pointsArray[i + 1] * yScale) + halfLineWidth); } return scaledPoints = new PointList(pointsArray); } public void addPoint(Point pt) { scaledPoints = null; super.addPoint(pt); } public void insertPoint(Point pt, int index) { scaledPoints = null; super.insertPoint(pt, index); } public void removeAllPoints() { scaledPoints = null; super.removeAllPoints(); } public void removePoint(int index) { scaledPoints = null; super.removePoint(index); } public void setStart(Point start) { scaledPoints = null; super.setStart(start); } public void setEnd(Point end) { scaledPoints = null; super.setEnd(end); } public void setPoint(Point pt, int index) { scaledPoints = null; super.setPoint(pt, index); } public void setPoints(PointList points) { scaledPoints = null; super.setPoints(points); } public void setBounds(Rectangle rect) { scaledPoints = null; super.setBounds(rect); } public void setLineWidth(int w) { scaledPoints = null; super.setLineWidth(w); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ScaledGraphics.java000066400000000000000000000651651166301720600272240ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.graphics.FontMetrics; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.LineAttributes; import org.eclipse.swt.graphics.Path; import org.eclipse.swt.graphics.PathData; import org.eclipse.swt.graphics.Pattern; import org.eclipse.swt.graphics.TextLayout; import org.eclipse.swt.graphics.TextStyle; import org.eclipse.swt.widgets.Display; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.PointList; import org.eclipse.draw2d.geometry.Rectangle; /** * A Graphics object able to scale all operations based on the current scale * factor. */ public class ScaledGraphics extends Graphics { private static class FontHeightCache { Font font; int height; } static class FontKey { Font font; int height; protected FontKey() { } protected FontKey(Font font, int height) { this.font = font; this.height = height; } public boolean equals(Object obj) { return (((FontKey) obj).font.equals(font) && ((FontKey) obj).height == height); } public int hashCode() { return font.hashCode() ^ height; } protected void setValues(Font font, int height) { this.font = font; this.height = height; } } /** * The internal state of the scaled graphics. */ protected static class State { private double appliedX; private double appliedY; private Font font; private float lineWidth; private double zoom; /** * Constructs a new, uninitialized State object. */ protected State() { } /** * Constructs a new State object and initializes the properties based on * the given values. * * @param zoom * the zoom factor * @param x * the x offset * @param y * the y offset * @param font * the font * @param lineWidth * the line width */ protected State(double zoom, double x, double y, Font font, int lineWidth) { this(zoom, x, y, font, (float) lineWidth); } /** * Constructs a new State object and initializes the properties based on * the given values. * * @param zoom * the zoom factor * @param x * the x offset * @param y * the y offset * @param font * the font * @param lineWidth * the line width * * @since 3.5 */ protected State(double zoom, double x, double y, Font font, float lineWidth) { this.zoom = zoom; this.appliedX = x; this.appliedY = y; this.font = font; this.lineWidth = lineWidth; } /** * Sets all the properties of the state object. * * @param zoom * the zoom factor * @param x * the x offset * @param y * the y offset * @param font * the font * @param lineWidth * the line width */ protected void setValues(double zoom, double x, double y, Font font, int lineWidth) { setValues(zoom, x, y, font, (float) lineWidth); } /** * Sets all the properties of the state object. * * @param zoom * the zoom factor * @param x * the x offset * @param y * the y offset * @param font * the font * @param lineWidth * the line width * * @since 3.5 */ protected void setValues(double zoom, double x, double y, Font font, float lineWidth) { this.zoom = zoom; this.appliedX = x; this.appliedY = y; this.font = font; this.lineWidth = lineWidth; } } private static int[][] intArrayCache = new int[8][]; private final Rectangle tempRECT = new Rectangle(); static { for (int i = 0; i < intArrayCache.length; i++) { intArrayCache[i] = new int[i + 1]; } } private boolean allowText = true; // private static final Point PT = new Point(); private Map fontCache = new HashMap(); private Map fontDataCache = new HashMap(); private FontKey fontKey = new FontKey(); private double fractionalX; private double fractionalY; private Graphics graphics; private FontHeightCache localCache = new FontHeightCache(); private Font localFont; private float localLineWidth; private List stack = new ArrayList(); private int stackPointer = 0; private FontHeightCache targetCache = new FontHeightCache(); double zoom = 1.0; /** * Constructs a new ScaledGraphics based on the given Graphics object. * * @param g * the base graphics object */ public ScaledGraphics(Graphics g) { graphics = g; localFont = g.getFont(); localLineWidth = g.getLineWidthFloat(); } /** @see Graphics#clipRect(Rectangle) */ public void clipRect(Rectangle r) { graphics.clipRect(zoomClipRect(r)); } Font createFont(FontData data) { return new Font(Display.getCurrent(), data); } /** * Scales given path by zoom factor * * @param path * Path to be scaled * @return Scaled path */ private Path createScaledPath(Path path) { PathData p = path.getPathData(); for (int i = 0; i < p.points.length; i += 2) { p.points[i] = (float) (p.points[i] * zoom + fractionalX); p.points[i + 1] = (float) (p.points[i + 1] * zoom + fractionalY); } Path scaledPath = new Path(path.getDevice()); int index = 0; for (int i = 0; i < p.types.length; i++) { byte type = p.types[i]; switch (type) { case SWT.PATH_MOVE_TO: scaledPath.moveTo(p.points[index], p.points[index + 1]); index += 2; break; case SWT.PATH_LINE_TO: scaledPath.lineTo(p.points[index], p.points[index + 1]); index += 2; break; case SWT.PATH_CUBIC_TO: scaledPath.cubicTo(p.points[index], p.points[index + 1], p.points[index + 2], p.points[index + 3], p.points[index + 4], p.points[index + 5]); index += 6; break; case SWT.PATH_QUAD_TO: scaledPath.quadTo(p.points[index], p.points[index + 1], p.points[index + 2], p.points[index + 3]); index += 4; break; case SWT.PATH_CLOSE: scaledPath.close(); break; } } return scaledPath; } /** @see Graphics#dispose() */ public void dispose() { // Remove all states from the stack while (stackPointer > 0) { popState(); } // Dispose fonts Iterator iter = fontCache.values().iterator(); while (iter.hasNext()) { Font font = ((Font) iter.next()); font.dispose(); } } /** @see Graphics#drawArc(int, int, int, int, int, int) */ public void drawArc(int x, int y, int w, int h, int offset, int sweep) { Rectangle z = zoomRect(x, y, w, h); if (z.isEmpty() || sweep == 0) return; graphics.drawArc(z, offset, sweep); } /** @see Graphics#drawFocus(int, int, int, int) */ public void drawFocus(int x, int y, int w, int h) { graphics.drawFocus(zoomRect(x, y, w, h)); } /** @see Graphics#drawImage(Image, int, int) */ public void drawImage(Image srcImage, int x, int y) { org.eclipse.swt.graphics.Rectangle size = srcImage.getBounds(); graphics.drawImage(srcImage, 0, 0, size.width, size.height, (int) (Math.floor((x * zoom + fractionalX))), (int) (Math.floor((y * zoom + fractionalY))), (int) (Math.floor((size.width * zoom + fractionalX))), (int) (Math.floor((size.height * zoom + fractionalY)))); } /** @see Graphics#drawImage(Image, int, int, int, int, int, int, int, int) */ public void drawImage(Image srcImage, int sx, int sy, int sw, int sh, int tx, int ty, int tw, int th) { // "t" == target rectangle, "s" = source Rectangle t = zoomRect(tx, ty, tw, th); if (!t.isEmpty()) graphics.drawImage(srcImage, sx, sy, sw, sh, t.x, t.y, t.width, t.height); } /** @see Graphics#drawLine(int, int, int, int) */ public void drawLine(int x1, int y1, int x2, int y2) { graphics.drawLine((int) (Math.floor((x1 * zoom + fractionalX))), (int) (Math.floor((y1 * zoom + fractionalY))), (int) (Math.floor((x2 * zoom + fractionalX))), (int) (Math.floor((y2 * zoom + fractionalY)))); } /** @see Graphics#drawOval(int, int, int, int) */ public void drawOval(int x, int y, int w, int h) { graphics.drawOval(zoomRect(x, y, w, h)); } /** @see Graphics#drawPath(Path) */ public void drawPath(Path path) { Path scaledPath = createScaledPath(path); try { graphics.drawPath(scaledPath); } finally { scaledPath.dispose(); } } /** @see Graphics#drawPoint(int, int) */ public void drawPoint(int x, int y) { graphics.drawPoint((int) Math.floor(x * zoom + fractionalX), (int) Math.floor(y * zoom + fractionalY)); } /** * @see Graphics#drawPolygon(int[]) */ public void drawPolygon(int[] points) { graphics.drawPolygon(zoomPointList(points)); } /** @see Graphics#drawPolygon(PointList) */ public void drawPolygon(PointList points) { graphics.drawPolygon(zoomPointList(points.toIntArray())); } /** * @see Graphics#drawPolyline(int[]) */ public void drawPolyline(int[] points) { graphics.drawPolyline(zoomPointList(points)); } /** @see Graphics#drawPolyline(PointList) */ public void drawPolyline(PointList points) { graphics.drawPolyline(zoomPointList(points.toIntArray())); } /** @see Graphics#drawRectangle(int, int, int, int) */ public void drawRectangle(int x, int y, int w, int h) { graphics.drawRectangle(zoomRect(x, y, w, h)); } /** @see Graphics#drawRoundRectangle(Rectangle, int, int) */ public void drawRoundRectangle(Rectangle r, int arcWidth, int arcHeight) { graphics.drawRoundRectangle(zoomRect(r.x, r.y, r.width, r.height), (int) (arcWidth * zoom), (int) (arcHeight * zoom)); } /** @see Graphics#drawString(String, int, int) */ public void drawString(String s, int x, int y) { if (allowText) graphics.drawString(s, zoomTextPoint(x, y)); } /** @see Graphics#drawText(String, int, int) */ public void drawText(String s, int x, int y) { if (allowText) graphics.drawText(s, zoomTextPoint(x, y)); } /** * @see Graphics#drawText(String, int, int, int) */ public void drawText(String s, int x, int y, int style) { if (allowText) graphics.drawText(s, zoomTextPoint(x, y), style); } /** * @see Graphics#drawTextLayout(TextLayout, int, int, int, int, Color, * Color) */ public void drawTextLayout(TextLayout layout, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground) { TextLayout scaled = zoomTextLayout(layout); if (scaled == null) { return; } try { graphics.drawTextLayout(scaled, (int) Math.floor(x * zoom + fractionalX), (int) Math.floor(y * zoom + fractionalY), selectionStart, selectionEnd, selectionBackground, selectionForeground); } finally { scaled.dispose(); } } /** @see Graphics#fillArc(int, int, int, int, int, int) */ public void fillArc(int x, int y, int w, int h, int offset, int sweep) { Rectangle z = zoomFillRect(x, y, w, h); if (z.isEmpty() || sweep == 0) return; graphics.fillArc(z, offset, sweep); } /** @see Graphics#fillGradient(int, int, int, int, boolean) */ public void fillGradient(int x, int y, int w, int h, boolean vertical) { graphics.fillGradient(zoomFillRect(x, y, w, h), vertical); } /** @see Graphics#fillOval(int, int, int, int) */ public void fillOval(int x, int y, int w, int h) { graphics.fillOval(zoomFillRect(x, y, w, h)); } /** @see Graphics#fillPath(Path) */ public void fillPath(Path path) { Path scaledPath = createScaledPath(path); try { graphics.fillPath(scaledPath); } finally { scaledPath.dispose(); } } /** * @see Graphics#fillPolygon(int[]) */ public void fillPolygon(int[] points) { graphics.fillPolygon(zoomPointList(points)); } /** @see Graphics#fillPolygon(PointList) */ public void fillPolygon(PointList points) { graphics.fillPolygon(zoomPointList(points.toIntArray())); } /** @see Graphics#fillRectangle(int, int, int, int) */ public void fillRectangle(int x, int y, int w, int h) { graphics.fillRectangle(zoomFillRect(x, y, w, h)); } /** @see Graphics#fillRoundRectangle(Rectangle, int, int) */ public void fillRoundRectangle(Rectangle r, int arcWidth, int arcHeight) { graphics.fillRoundRectangle(zoomFillRect(r.x, r.y, r.width, r.height), (int) (arcWidth * zoom), (int) (arcHeight * zoom)); } /** @see Graphics#fillString(String, int, int) */ public void fillString(String s, int x, int y) { if (allowText) graphics.fillString(s, zoomTextPoint(x, y)); } /** @see Graphics#fillText(String, int, int) */ public void fillText(String s, int x, int y) { if (allowText) graphics.fillText(s, zoomTextPoint(x, y)); } /** * @see Graphics#getAbsoluteScale() */ public double getAbsoluteScale() { return zoom * graphics.getAbsoluteScale(); } /** * @see Graphics#getAlpha() */ public int getAlpha() { return graphics.getAlpha(); } /** * @see Graphics#getAntialias() */ public int getAntialias() { return graphics.getAntialias(); } /** @see Graphics#getBackgroundColor() */ public Color getBackgroundColor() { return graphics.getBackgroundColor(); } Font getCachedFont(FontKey key) { Font font = (Font) fontCache.get(key); if (font != null) { return font; } key = new FontKey(key.font, key.height); FontData data = key.font.getFontData()[0]; data.setHeight(key.height); Font zoomedFont = createFont(data); fontCache.put(key, zoomedFont); return zoomedFont; } FontData getCachedFontData(Font f) { FontData data = (FontData) fontDataCache.get(f); if (data == null) { data = getLocalFont().getFontData()[0]; fontDataCache.put(f, data); } return data; } /** @see Graphics#getClip(Rectangle) */ public Rectangle getClip(Rectangle rect) { graphics.getClip(rect); int x = (int) (rect.x / zoom); int y = (int) (rect.y / zoom); /* * If the clip rectangle is queried, perform an inverse zoom, and take * the ceiling of the resulting double. This is necessary because * forward scaling essentially performs a floor() function. Without * this, figures will think that they don't need to paint when actually * they do. */ rect.width = (int) Math.ceil(rect.right() / zoom) - x; rect.height = (int) Math.ceil(rect.bottom() / zoom) - y; rect.x = x; rect.y = y; return rect; } /** * @see Graphics#getAdvanced() */ public boolean getAdvanced() { return graphics.getAdvanced(); } /** * @see Graphics#getFillRule() */ public int getFillRule() { return graphics.getFillRule(); } /** @see Graphics#getFont() */ public Font getFont() { return getLocalFont(); } /** @see Graphics#getFontMetrics() */ public FontMetrics getFontMetrics() { return FigureUtilities.getFontMetrics(localFont); } /** @see Graphics#getForegroundColor() */ public Color getForegroundColor() { return graphics.getForegroundColor(); } /** * @see Graphics#getInterpolation() */ public int getInterpolation() { return graphics.getInterpolation(); } /** * @see Graphics#getLineCap() */ public int getLineCap() { return graphics.getLineCap(); } /** * @see Graphics#getLineJoin() */ public int getLineJoin() { return graphics.getLineJoin(); } /** @see Graphics#getLineStyle() */ public int getLineStyle() { return graphics.getLineStyle(); } /** @see Graphics#getLineMiterLimit() */ public float getLineMiterLimit() { return graphics.getLineMiterLimit(); } /** @see Graphics#getLineWidth() */ public int getLineWidth() { return (int) getLineWidthFloat(); } /** @see Graphics#getLineWidthFloat() */ public float getLineWidthFloat() { return getLocalLineWidth(); } /** @see Graphics#getLineAttributes() */ public LineAttributes getLineAttributes() { LineAttributes a = graphics.getLineAttributes(); a.width = getLocalLineWidth(); return a; } private Font getLocalFont() { return localFont; } private float getLocalLineWidth() { return localLineWidth; } /** * @see Graphics#getTextAntialias() */ public int getTextAntialias() { return graphics.getTextAntialias(); } /** @see Graphics#getXORMode() */ public boolean getXORMode() { return graphics.getXORMode(); } /** @see Graphics#popState() */ public void popState() { graphics.popState(); stackPointer--; restoreLocalState((State) stack.get(stackPointer)); } /** @see Graphics#pushState() */ public void pushState() { State s; if (stack.size() > stackPointer) { s = (State) stack.get(stackPointer); s.setValues(zoom, fractionalX, fractionalY, getLocalFont(), localLineWidth); } else { stack.add(new State(zoom, fractionalX, fractionalY, getLocalFont(), localLineWidth)); } stackPointer++; graphics.pushState(); } private void restoreLocalState(State state) { this.fractionalX = state.appliedX; this.fractionalY = state.appliedY; setScale(state.zoom); setLocalFont(state.font); setLocalLineWidth(state.lineWidth); } /** @see Graphics#restoreState() */ public void restoreState() { graphics.restoreState(); restoreLocalState((State) stack.get(stackPointer - 1)); } /** @see Graphics#rotate(float) */ public void rotate(float degrees) { graphics.rotate(degrees); } /** @see Graphics#scale(double) */ public void scale(double amount) { setScale(zoom * amount); } /** @see Graphics#setAdvanced(boolean) */ public void setAdvanced(boolean advanced) { graphics.setAdvanced(advanced); } /** * @see Graphics#setAlpha(int) */ public void setAlpha(int alpha) { graphics.setAlpha(alpha); } /** * @see Graphics#setAntialias(int) */ public void setAntialias(int value) { graphics.setAntialias(value); } /** @see Graphics#setBackgroundColor(Color) */ public void setBackgroundColor(Color rgb) { graphics.setBackgroundColor(rgb); } /** @see Graphics#setClip(Path) */ public void setClip(Path path) { Path scaledPath = createScaledPath(path); try { graphics.setClip(scaledPath); } finally { scaledPath.dispose(); } } /** @see Graphics#setBackgroundPattern(Pattern) */ public void setBackgroundPattern(Pattern pattern) { graphics.setBackgroundPattern(pattern); } /** @see Graphics#setClip(Rectangle) */ public void setClip(Rectangle r) { graphics.setClip(zoomClipRect(r)); } /** * @see org.eclipse.draw2d.Graphics#clipPath(org.eclipse.swt.graphics.Path) */ public void clipPath(Path path) { Path scaledPath = createScaledPath(path); try { graphics.clipPath(scaledPath); } finally { scaledPath.dispose(); } } /** * @see Graphics#setFillRule(int) */ public void setFillRule(int rule) { graphics.setFillRule(rule); } /** @see Graphics#setFont(Font) */ public void setFont(Font f) { setLocalFont(f); } /** @see Graphics#setForegroundColor(Color) */ public void setForegroundColor(Color rgb) { graphics.setForegroundColor(rgb); } /** @see Graphics#setForegroundPattern(Pattern) */ public void setForegroundPattern(Pattern pattern) { graphics.setForegroundPattern(pattern); } /** @see org.eclipse.draw2d.Graphics#setInterpolation(int) */ public void setInterpolation(int interpolation) { graphics.setInterpolation(interpolation); } /** * @see Graphics#setLineCap(int) */ public void setLineCap(int cap) { graphics.setLineCap(cap); } /** * @see Graphics#setLineDash(int[]) */ public void setLineDash(int[] dash) { graphics.setLineDash(dash); } /** * @see org.eclipse.draw2d.Graphics#setLineDash(float[]) */ public void setLineDash(float[] dash) { graphics.setLineDash(dash); } /** * @see Graphics#setLineJoin(int) */ public void setLineJoin(int join) { graphics.setLineJoin(join); } /** @see Graphics#setLineStyle(int) */ public void setLineStyle(int style) { graphics.setLineStyle(style); } /** @see Graphics#setLineMiterLimit(float) */ public void setLineMiterLimit(float value) { graphics.setLineMiterLimit(value); } /** @see Graphics#setLineWidth(int) */ public void setLineWidth(int width) { setLineWidthFloat(width); } /** @see Graphics#setLineWidthFloat(float) */ public void setLineWidthFloat(float width) { setLocalLineWidth(width); } /** @see Graphics#setLineAttributes(LineAttributes) */ public void setLineAttributes(LineAttributes attributes) { graphics.setLineAttributes(attributes); setLocalLineWidth(attributes.width); } private void setLocalFont(Font f) { localFont = f; graphics.setFont(zoomFont(f)); } private void setLocalLineWidth(float width) { localLineWidth = width; graphics.setLineWidthFloat(zoomLineWidth(width)); } void setScale(double value) { if (zoom != value) { this.zoom = value; graphics.setFont(zoomFont(getLocalFont())); graphics.setLineWidthFloat(zoomLineWidth(localLineWidth)); } } /** * @see Graphics#setTextAntialias(int) */ public void setTextAntialias(int value) { graphics.setTextAntialias(value); } /** @see Graphics#setXORMode(boolean) */ public void setXORMode(boolean b) { graphics.setXORMode(b); } /** @see Graphics#translate(int, int) */ public void translate(int dx, int dy) { // fractionalX/Y is the fractional part left over from previous // translates that gets lost in the integer approximation. double dxFloat = dx * zoom + fractionalX; double dyFloat = dy * zoom + fractionalY; fractionalX = dxFloat - Math.floor(dxFloat); fractionalY = dyFloat - Math.floor(dyFloat); graphics.translate((int) Math.floor(dxFloat), (int) Math.floor(dyFloat)); } /** @see Graphics#translate(float, float) */ public void translate(float dx, float dy) { double dxFloat = dx * zoom + fractionalX; double dyFloat = dy * zoom + fractionalY; fractionalX = dxFloat - Math.floor(dxFloat); fractionalY = dyFloat - Math.floor(dyFloat); graphics.translate((int) Math.floor(dxFloat), (int) Math.floor(dyFloat)); } private Rectangle zoomClipRect(Rectangle r) { tempRECT.x = (int) (Math.floor(r.x * zoom + fractionalX)); tempRECT.y = (int) (Math.floor(r.y * zoom + fractionalY)); tempRECT.width = (int) (Math .ceil(((r.x + r.width) * zoom + fractionalX))) - tempRECT.x; tempRECT.height = (int) (Math .ceil(((r.y + r.height) * zoom + fractionalY))) - tempRECT.y; return tempRECT; } private Rectangle zoomFillRect(int x, int y, int w, int h) { tempRECT.x = (int) (Math.floor((x * zoom + fractionalX))); tempRECT.y = (int) (Math.floor((y * zoom + fractionalY))); tempRECT.width = (int) (Math.floor(((x + w - 1) * zoom + fractionalX))) - tempRECT.x + 1; tempRECT.height = (int) (Math.floor(((y + h - 1) * zoom + fractionalY))) - tempRECT.y + 1; return tempRECT; } Font zoomFont(Font f) { if (f == null) { f = Display.getCurrent().getSystemFont(); } FontData data = getCachedFontData(f); int zoomedFontHeight = zoomFontHeight(data.getHeight()); allowText = zoomedFontHeight > 0; fontKey.setValues(f, zoomedFontHeight); return getCachedFont(fontKey); } int zoomFontHeight(int height) { return (int) (zoom * height); } float zoomLineWidth(float w) { return (float) (w * zoom); } private int[] zoomPointList(int[] points) { int[] scaled = null; // Look in cache for a integer array with the same length as 'points' for (int i = 0; i < intArrayCache.length; i++) { if (intArrayCache[i].length == points.length) { scaled = intArrayCache[i]; // Move this integer array up one notch in the array if (i != 0) { int[] temp = intArrayCache[i - 1]; intArrayCache[i - 1] = scaled; intArrayCache[i] = temp; } } } // If no match is found, take the one that is last and resize it. if (scaled == null) { intArrayCache[intArrayCache.length - 1] = new int[points.length]; scaled = intArrayCache[intArrayCache.length - 1]; } // Scale the points for (int i = 0; (i + 1) < points.length; i += 2) { scaled[i] = (int) (Math.floor((points[i] * zoom + fractionalX))); scaled[i + 1] = (int) (Math .floor((points[i + 1] * zoom + fractionalY))); } return scaled; } private Rectangle zoomRect(int x, int y, int w, int h) { tempRECT.x = (int) (Math.floor(x * zoom + fractionalX)); tempRECT.y = (int) (Math.floor(y * zoom + fractionalY)); tempRECT.width = (int) (Math.floor(((x + w) * zoom + fractionalX))) - tempRECT.x; tempRECT.height = (int) (Math.floor(((y + h) * zoom + fractionalY))) - tempRECT.y; return tempRECT; } private TextLayout zoomTextLayout(TextLayout layout) { TextLayout zoomed = new TextLayout(Display.getCurrent()); zoomed.setText(layout.getText()); int zoomWidth = -1; if (layout.getWidth() != -1) zoomWidth = ((int) (layout.getWidth() * zoom)); if (zoomWidth < -1 || zoomWidth == 0) return null; zoomed.setFont(zoomFont(layout.getFont())); zoomed.setAlignment(layout.getAlignment()); zoomed.setAscent(layout.getAscent()); zoomed.setDescent(layout.getDescent()); zoomed.setOrientation(layout.getOrientation()); zoomed.setSegments(layout.getSegments()); zoomed.setSpacing(layout.getSpacing()); zoomed.setTabs(layout.getTabs()); zoomed.setWidth(zoomWidth); int length = layout.getText().length(); if (length > 0) { int start = 0, offset = 1; TextStyle style = null, lastStyle = layout.getStyle(0); for (; offset <= length; offset++) { if (offset != length && (style = layout.getStyle(offset)) == lastStyle) continue; int end = offset - 1; if (lastStyle != null) { TextStyle zoomedStyle = new TextStyle( zoomFont(lastStyle.font), lastStyle.foreground, lastStyle.background); zoomedStyle.metrics = lastStyle.metrics; zoomedStyle.rise = lastStyle.rise; zoomedStyle.strikeout = lastStyle.strikeout; zoomedStyle.underline = lastStyle.underline; zoomed.setStyle(zoomedStyle, start, end); } lastStyle = style; start = offset; } } return zoomed; } private Point zoomTextPoint(int x, int y) { if (localCache.font != localFont) { // Font is different, re-calculate its height FontMetrics metric = FigureUtilities.getFontMetrics(localFont); localCache.height = metric.getHeight() - metric.getDescent(); localCache.font = localFont; } if (targetCache.font != graphics.getFont()) { FontMetrics metric = graphics.getFontMetrics(); targetCache.font = graphics.getFont(); targetCache.height = metric.getHeight() - metric.getDescent(); } return new Point(((int) (Math.floor((x * zoom) + fractionalX))), (int) (Math.floor((y + localCache.height - 1) * zoom - targetCache.height + 1 + fractionalY))); } }eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/SchemeBorder.java000066400000000000000000000207741166301720600267070ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.graphics.Color; import org.eclipse.draw2d.geometry.Insets; import org.eclipse.draw2d.geometry.Rectangle; /** * SchemeBorder allows the creation of borders based on * {@link SchemeBorder.Scheme Schemes}. A Scheme is a class whose only * purpose is to carry border specific information. SchemeBorder renders the * border based on the information given by the Scheme set to it. */ public class SchemeBorder extends AbstractBorder implements ColorConstants { /** The {@link SchemeBorder.Scheme} associated with this SchemeBorder **/ protected Scheme scheme = null; /** Arrays of Colors, used for shadow or highlight effects **/ protected static final Color DARKEST_DARKER[] = new Color[] { buttonDarkest, buttonDarker }, LIGHTER_DARKER[] = new Color[] { buttonLightest, buttonDarker }, DARKER_LIGHTER[] = new Color[] { buttonDarker, buttonLightest }; /** * Holds a set of information about a border, which can be changed to create * a wide range of schemes. Provides support for border opacity, size, * highlight side and shadow side colors. */ public static class Scheme { private Insets insets; private boolean isOpaque = false; /** Arrays of Colors, used for highlight and shadow effecsts */ protected Color highlight[], shadow[]; /** * Constructs a default border Scheme with no border sides. * * @since 2.0 */ protected Scheme() { } /** * Constructs a border Scheme with the specified highlight and shadow * colors. The size of the border depends on the number of colors passed * in for each parameter. Hightlight colors are used in the top and left * sides of the border, and Shadow colors are used in the bottom and * right sides of the border. * * @param highlight * the hightlight colors * @param shadow * the shadow colors * @since 2.0 */ public Scheme(Color[] highlight, Color[] shadow) { this.highlight = highlight; this.shadow = shadow; init(); } /** * Constructs a border scheme with the specified colors. The input * colors serve as both highlight and shadow colors. The size of the * border is the number of colors passed in as input. Hightlight colors * are used in the top and left sides of the border, and Shadow colors * are used in the bottom and right sides of the border. * * @param colors * the colors to be used for the border * @since 2.0 */ public Scheme(Color[] colors) { highlight = shadow = colors; init(); } /** * Calculates and returns the Insets for this border Scheme. The * calculations depend on the number of colors passed in as input. * * @return the Insets used by this border * @since 2.0 */ protected Insets calculateInsets() { int tl = getHighlight().length; int br = getShadow().length; return new Insets(tl, tl, br, br); } /** * Calculates and retuns the opaque state of this border scheme. Returns * false if any of the border colors are null. * This is done to prevent the appearance of underlying pixels since the * border color is null. * * @return true if this border is opaque * @since 2.0 */ protected boolean calculateOpaque() { Color colors[] = getHighlight(); for (int i = 0; i < colors.length; i++) if (colors[i] == null) return false; colors = getShadow(); for (int i = 0; i < colors.length; i++) if (colors[i] == null) return false; return true; } /** * Returns the highlight colors of this border scheme as an array of * Colors. * * @return the highlight colors * @since 2.0 */ protected Color[] getHighlight() { return highlight; } /** * Returns the Insets required by this Scheme. * * @return the Insets * @since 2.0 */ protected Insets getInsets() { return insets; } /** * Returns the shadow colors of this border scheme as an array of * Colors. * * @return the shadow colors * @since 2.0 */ protected Color[] getShadow() { return shadow; } /** * Calculates and initializes the properties of this border scheme. * * @since 2.0 */ protected void init() { insets = calculateInsets(); isOpaque = calculateOpaque(); } /** * Returns whether this border should be opaque or not. * * @return true if this border is opaque * @since 2.0 */ protected boolean isOpaque() { return isOpaque; } } /** * Interface which defines some commonly used schemes for the border. These * schemes can be given as input to the {@link SchemeBorder SchemeBorder} to * generate appropriate borders. */ public static interface SCHEMES { /** Schemes used for shadow and highlight effects **/ Scheme BUTTON_CONTRAST = new Scheme(new Color[] { button, buttonLightest }, DARKEST_DARKER), BUTTON_RAISED = new Scheme( new Color[] { buttonLightest }, DARKEST_DARKER), BUTTON_PRESSED = new Scheme(DARKEST_DARKER, new Color[] { buttonLightest }), RAISED = new Scheme( new Color[] { buttonLightest }, new Color[] { buttonDarkest }), LOWERED = new Scheme( new Color[] { buttonDarkest }, new Color[] { buttonLightest }), RIDGED = new Scheme( LIGHTER_DARKER, DARKER_LIGHTER), ETCHED = new Scheme( DARKER_LIGHTER, LIGHTER_DARKER); } /** * Constructs a default SchemeBorder with no scheme defined. * * @since 2.0 */ protected SchemeBorder() { } /** * Constructs a SchemeBorder with the Scheme given as input. * * @param scheme * the Scheme to be used by this border * @since 2.0 */ public SchemeBorder(Scheme scheme) { setScheme(scheme); } /** * @see Border#getInsets(IFigure) */ public Insets getInsets(IFigure figure) { return getScheme().getInsets(); } /** * Returns the scheme used by this border. * * @return the Scheme used by this border * @since 2.0 */ protected Scheme getScheme() { return scheme; } /** * Returns the opaque state of this border. Returns true * indicating that this will fill in the area enclosed by the border. * * @see Border#isOpaque() */ public boolean isOpaque() { return true; } /** * Sets the Scheme for this border to the Scheme given as input. * * @param scheme * the Scheme for this border * @since 2.0 */ protected void setScheme(Scheme scheme) { this.scheme = scheme; } /** * @see Border#paint(IFigure, Graphics, Insets) */ public void paint(IFigure figure, Graphics g, Insets insets) { Color[] tl = scheme.getHighlight(); Color[] br = scheme.getShadow(); paint(g, figure, insets, tl, br); } /** * Paints the border using the information in the set Scheme and the inputs * given. Side widths are determined by the number of colors in the Scheme * for each side. * * @param graphics * the graphics object * @param fig * the figure this border belongs to * @param insets * the insets * @param tl * the highlight (top/left) colors * @param br * the shadow (bottom/right) colors */ protected void paint(Graphics graphics, IFigure fig, Insets insets, Color[] tl, Color[] br) { graphics.setLineWidth(1); graphics.setLineStyle(Graphics.LINE_SOLID); graphics.setXORMode(false); Rectangle rect = getPaintRectangle(fig, insets); int top = rect.y; int left = rect.x; int bottom = rect.bottom() - 1; int right = rect.right() - 1; Color color; for (int i = 0; i < br.length; i++) { color = br[i]; graphics.setForegroundColor(color); graphics.drawLine(right - i, bottom - i, right - i, top + i); graphics.drawLine(right - i, bottom - i, left + i, bottom - i); } right--; bottom--; for (int i = 0; i < tl.length; i++) { color = tl[i]; graphics.setForegroundColor(color); graphics.drawLine(left + i, top + i, right - i, top + i); graphics.drawLine(left + i, top + i, left + i, bottom - i); } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ScrollBar.java000066400000000000000000000416751166301720600262330ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import org.eclipse.swt.graphics.Color; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.draw2d.geometry.Transposer; /** * Provides for the scrollbars used by the {@link ScrollPane}. A ScrollBar is * made up of five essential Figures: An 'Up' arrow button, a 'Down' arrow * button, a draggable 'Thumb', a 'Pageup' button, and a 'Pagedown' button. */ public class ScrollBar extends Figure implements Orientable, PropertyChangeListener { private static final int ORIENTATION_FLAG = Figure.MAX_FLAG << 1; /** @see Figure#MAX_FLAG */ protected static final int MAX_FLAG = ORIENTATION_FLAG; private static final Color COLOR_TRACK = FigureUtilities.mixColors( ColorConstants.white, ColorConstants.button); private RangeModel rangeModel = null; private IFigure thumb; private Clickable pageUp, pageDown; private Clickable buttonUp, buttonDown; /** * Listens to mouse events on the scrollbar to take care of scrolling. */ protected ThumbDragger thumbDragger = new ThumbDragger(); private boolean isHorizontal = false; private int pageIncrement = 50; private int stepIncrement = 10; /** * Transposes from vertical to horizontal if needed. */ protected final Transposer transposer = new Transposer(); { setRangeModel(new DefaultRangeModel()); } /** * Constructs a ScrollBar. ScrollBar orientation is vertical by default. * Call {@link #setHorizontal(boolean)} with true to set * horizontal orientation. * * @since 2.0 */ public ScrollBar() { initialize(); } /** * Creates the default 'Up' ArrowButton for the ScrollBar. * * @return the up button * @since 2.0 */ protected Clickable createDefaultUpButton() { Button buttonUp = new ArrowButton(); buttonUp.setBorder(new ButtonBorder( ButtonBorder.SCHEMES.BUTTON_SCROLLBAR)); return buttonUp; } /** * Creates the default 'Down' ArrowButton for the ScrollBar. * * @return the down button * @since 2.0 */ protected Clickable createDefaultDownButton() { Button buttonDown = new ArrowButton(); buttonDown.setBorder(new ButtonBorder( ButtonBorder.SCHEMES.BUTTON_SCROLLBAR)); return buttonDown; } /** * Creates the pagedown Figure for the Scrollbar. * * @return the page down figure * @since 2.0 */ protected Clickable createPageDown() { return createPageUp(); } /** * Creates the pageup Figure for the Scrollbar. * * @return the page up figure * @since 2.0 */ protected Clickable createPageUp() { final Clickable clickable = new Clickable(); clickable.setOpaque(true); clickable.setBackgroundColor(COLOR_TRACK); clickable.setRequestFocusEnabled(false); clickable.setFocusTraversable(false); clickable.addChangeListener(new ChangeListener() { public void handleStateChanged(ChangeEvent evt) { if (clickable.getModel().isArmed()) clickable.setBackgroundColor(ColorConstants.black); else clickable.setBackgroundColor(COLOR_TRACK); } }); return clickable; } /** * Creates the Scrollbar's "thumb", the draggable Figure that indicates the * Scrollbar's position. * * @return the thumb figure * @since 2.0 */ protected IFigure createDefaultThumb() { Panel thumb = new Panel(); thumb.setMinimumSize(new Dimension(6, 6)); thumb.setBackgroundColor(ColorConstants.button); thumb.setBorder(new SchemeBorder(SchemeBorder.SCHEMES.BUTTON_CONTRAST)); return thumb; } /** * Returns the figure used as the up button. * * @return the up button */ protected IFigure getButtonUp() { // TODO: The set method takes a Clickable while the get method returns // an IFigure. // Change the get method to return Clickable (since that's what it's // typed as). return buttonUp; } /** * Returns the figure used as the down button. * * @return the down button */ protected IFigure getButtonDown() { // TODO: The set method takes a Clickable while the get method returns // an IFigure. // Change the get method to return Clickable (since that's what it's // typed as). return buttonDown; } /** * Returns the extent. * * @return the extent * @see RangeModel#getExtent() */ public int getExtent() { return getRangeModel().getExtent(); } /** * Returns the minumum value. * * @return the minimum * @see RangeModel#getMinimum() */ public int getMinimum() { return getRangeModel().getMinimum(); } /** * Returns the maximum value. * * @return the maximum * @see RangeModel#getMaximum() */ public int getMaximum() { return getRangeModel().getMaximum(); } /** * Returns the figure used for page down. * * @return the page down figure */ protected IFigure getPageDown() { // TODO: The set method takes a Clickable while the get method returns // an IFigure. // Change the get method to return Clickable (since that's what it's // typed as). return pageDown; } /** * Returns the the amound the scrollbar will move when the page up or page * down areas are pressed. * * @return the page increment */ public int getPageIncrement() { return pageIncrement; } /** * Returns the figure used for page up. * * @return the page up figure */ protected IFigure getPageUp() { // TODO: The set method takes a Clickable while the get method returns // an IFigure. // Change the get method to return Clickable (since that's what it's // typed as). return pageUp; } /** * Returns the range model for this scrollbar. * * @return the range model */ public RangeModel getRangeModel() { return rangeModel; } /** * Returns the amount the scrollbar will move when the up or down arrow * buttons are pressed. * * @return the step increment */ public int getStepIncrement() { return stepIncrement; } /** * Returns the figure used as the scrollbar's thumb. * * @return the thumb figure */ protected IFigure getThumb() { return thumb; } /** * Returns the current scroll position of the scrollbar. * * @return the current value * @see RangeModel#getValue() */ public int getValue() { return getRangeModel().getValue(); } /** * Returns the size of the range of allowable values. * * @return the value range */ protected int getValueRange() { return getMaximum() - getExtent() - getMinimum(); } /** * Initilization of the ScrollBar. Sets the Scrollbar to have a * ScrollBarLayout with vertical orientation. Creates the Figures that make * up the components of the ScrollBar. * * @since 2.0 */ protected void initialize() { setLayoutManager(new ScrollBarLayout(transposer)); setUpClickable(createDefaultUpButton()); setDownClickable(createDefaultDownButton()); setPageUp(createPageUp()); setPageDown(createPageDown()); setThumb(createDefaultThumb()); } /** * Returns true if this scrollbar is orientated horizontally, * false otherwise. * * @return whether this scrollbar is horizontal */ public boolean isHorizontal() { return isHorizontal; } private void pageDown() { setValue(getValue() + getPageIncrement()); } private void pageUp() { setValue(getValue() - getPageIncrement()); } /** * @see PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent event) { if (event.getSource() instanceof RangeModel) { setEnabled(getRangeModel().isEnabled()); if (RangeModel.PROPERTY_VALUE.equals(event.getPropertyName())) { firePropertyChange("value", event.getOldValue(), //$NON-NLS-1$ event.getNewValue()); revalidate(); } if (RangeModel.PROPERTY_MINIMUM.equals(event.getPropertyName())) { firePropertyChange("value", event.getOldValue(), //$NON-NLS-1$ event.getNewValue()); revalidate(); } if (RangeModel.PROPERTY_MAXIMUM.equals(event.getPropertyName())) { firePropertyChange("value", event.getOldValue(), //$NON-NLS-1$ event.getNewValue()); revalidate(); } if (RangeModel.PROPERTY_EXTENT.equals(event.getPropertyName())) { firePropertyChange("value", event.getOldValue(), //$NON-NLS-1$ event.getNewValue()); revalidate(); } } } /** * @see IFigure#revalidate() */ public void revalidate() { // Override default revalidate to prevent going up the parent chain. // Reason for this // is that preferred size never changes unless orientation changes. invalidate(); getUpdateManager().addInvalidFigure(this); } /** * Does nothing because this doesn't make sense for a scrollbar. * * @see Orientable#setDirection(int) */ public void setDirection(int direction) { // Doesn't make sense for Scrollbar. } /** * Sets the Clickable that represents the down arrow of the Scrollbar to * down. * * @param down * the down button * @since 2.0 */ public void setDownClickable(Clickable down) { if (buttonDown != null) { remove(buttonDown); } buttonDown = down; if (buttonDown != null) { if (buttonDown instanceof Orientable) ((Orientable) buttonDown) .setDirection(isHorizontal() ? Orientable.EAST : Orientable.SOUTH); buttonDown.setFiringMethod(Clickable.REPEAT_FIRING); buttonDown.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { stepDown(); } }); add(buttonDown, ScrollBarLayout.DOWN_ARROW); } } /** * Sets the Clickable that represents the up arrow of the Scrollbar to * up. * * @param up * the up button * @since 2.0 */ public void setUpClickable(Clickable up) { if (buttonUp != null) { remove(buttonUp); } buttonUp = up; if (up != null) { if (up instanceof Orientable) ((Orientable) up).setDirection(isHorizontal() ? Orientable.WEST : Orientable.NORTH); buttonUp.setFiringMethod(Clickable.REPEAT_FIRING); buttonUp.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { stepUp(); } }); add(buttonUp, ScrollBarLayout.UP_ARROW); } } /** * @see IFigure#setEnabled(boolean) */ public void setEnabled(boolean value) { if (isEnabled() == value) return; super.setEnabled(value); setChildrenEnabled(value); if (getThumb() != null) { getThumb().setVisible(value); revalidate(); } } /** * Sets the extent of the Scrollbar to ext * * @param ext * the extent * @since 2.0 */ public void setExtent(int ext) { if (getExtent() == ext) return; getRangeModel().setExtent(ext); } /** * Sets the orientation of the ScrollBar. If true, the * Scrollbar will have a horizontal orientation. If false, the * scrollBar will have a vertical orientation. * * @param value * true if the scrollbar should be horizontal * @since 2.0 */ public final void setHorizontal(boolean value) { setOrientation(value ? HORIZONTAL : VERTICAL); } /** * Sets the maximum position to max. * * @param max * the maximum position * @since 2.0 */ public void setMaximum(int max) { if (getMaximum() == max) return; getRangeModel().setMaximum(max); } /** * Sets the minimum position to min. * * @param min * the minumum position * @since 2.0 */ public void setMinimum(int min) { if (getMinimum() == min) return; getRangeModel().setMinimum(min); } /** * @see Orientable#setOrientation(int) */ public void setOrientation(int value) { if ((value == HORIZONTAL) == isHorizontal()) return; isHorizontal = value == HORIZONTAL; transposer.setEnabled(isHorizontal); setChildrenOrientation(value); super.revalidate(); } /** * Sets the ScrollBar to scroll increment pixels when its pageup or * pagedown buttons are pressed. (Note that the pageup and pagedown buttons * are NOT the arrow buttons, they are the figures between the arrow * buttons and the ScrollBar's thumb figure). * * @param increment * the new page increment * @since 2.0 */ public void setPageIncrement(int increment) { pageIncrement = increment; } /** * Sets the pagedown button to the passed Clickable. The pagedown button is * the figure between the down arrow button and the ScrollBar's thumb * figure. * * @param down * the page down figure * @since 2.0 */ public void setPageDown(Clickable down) { if (pageDown != null) remove(pageDown); pageDown = down; if (pageDown != null) { pageDown.setFiringMethod(Clickable.REPEAT_FIRING); pageDown.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { pageDown(); } }); add(down, ScrollBarLayout.PAGE_DOWN); } } /** * Sets the pageup button to the passed Clickable. The pageup button is the * rectangular figure between the down arrow button and the ScrollBar's * thumb figure. * * @param up * the page up figure * @since 2.0 */ public void setPageUp(Clickable up) { if (pageUp != null) remove(pageUp); pageUp = up; if (pageUp != null) { pageUp.setFiringMethod(Clickable.REPEAT_FIRING); pageUp.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { pageUp(); } }); add(pageUp, ScrollBarLayout.PAGE_UP); } } /** * Sets the ScrollBar's RangeModel to the passed value. * * @param rangeModel * the new range model * @since 2.0 */ public void setRangeModel(RangeModel rangeModel) { if (this.rangeModel != null) this.rangeModel.removePropertyChangeListener(this); this.rangeModel = rangeModel; rangeModel.addPropertyChangeListener(this); } /** * Sets the ScrollBar's step increment to the passed value. The step * increment indicates how many pixels the ScrollBar will scroll when its up * or down arrow button is pressed. * * @param increment * the new step increment * @since 2.0 */ public void setStepIncrement(int increment) { stepIncrement = increment; } /** * Sets the ScrollBar's thumb to the passed Figure. The thumb is the * draggable component of the ScrollBar that indicates the ScrollBar's * position. * * @param figure * the thumb figure * @since 2.0 */ public void setThumb(IFigure figure) { if (thumb != null) { thumb.removeMouseListener(thumbDragger); thumb.removeMouseMotionListener(thumbDragger); remove(thumb); } thumb = figure; if (thumb != null) { thumb.addMouseListener(thumbDragger); thumb.addMouseMotionListener(thumbDragger); add(thumb, ScrollBarLayout.THUMB); } } /** * Sets the value of the Scrollbar to v * * @param v * the new value * @since 2.0 */ public void setValue(int v) { getRangeModel().setValue(v); } /** * Causes the ScrollBar to scroll down (or right) by the value of its step * increment. * * @since 2.0 */ protected void stepDown() { setValue(getValue() + getStepIncrement()); } /** * Causes the ScrollBar to scroll up (or left) by the value of its step * increment. * * @since 2.0 */ protected void stepUp() { setValue(getValue() - getStepIncrement()); } /** * @since 3.6 */ protected class ThumbDragger extends MouseMotionListener.Stub implements MouseListener { protected Point start; protected int dragRange; protected int revertValue; protected boolean armed; public ThumbDragger() { } public void mousePressed(MouseEvent me) { armed = true; start = me.getLocation(); Rectangle area = new Rectangle(transposer.t(getClientArea())); Dimension thumbSize = transposer.t(getThumb().getSize()); if (getButtonUp() != null) area.height -= transposer.t(getButtonUp().getSize()).height; if (getButtonDown() != null) area.height -= transposer.t(getButtonDown().getSize()).height; Dimension sizeDifference = new Dimension(area.width, area.height - thumbSize.height); dragRange = sizeDifference.height; revertValue = getValue(); me.consume(); } public void mouseDragged(MouseEvent me) { if (!armed) return; Dimension difference = transposer.t(me.getLocation().getDifference( start)); int change = getValueRange() * difference.height / dragRange; setValue(revertValue + change); me.consume(); } public void mouseReleased(MouseEvent me) { if (!armed) return; armed = false; me.consume(); } public void mouseDoubleClicked(MouseEvent me) { } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ScrollBarLayout.java000066400000000000000000000136021166301720600274160ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Insets; import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.draw2d.geometry.Transposer; /** * Lays out the Figures that make up a ScrollBar. */ public class ScrollBarLayout extends AbstractLayout { /** Used as a constraint for the up arrow figure. */ public static final String UP_ARROW = "up arrow"; //$NON-NLS-1$ /** Used as a constraint for the down arrow figure. */ public static final String DOWN_ARROW = "down arrow"; //$NON-NLS-1$ /** Used as a constraint for the thumb figure. */ public static final String THUMB = "thumb"; //$NON-NLS-1$ /** Used as a constraint for the page up figure. */ public static final String PAGE_UP = "page_up"; //$NON-NLS-1$ /** Used as a constraint for the page down figure. */ public static final String PAGE_DOWN = "page_down"; //$NON-NLS-1$ IFigure up, down, thumb, pageUp, pageDown; /** * Transposes values if the ScrollBar is horizontally oriented. When used * properly, the layout manager just needs to code for one case: vertical * orientation. */ protected final Transposer transposer; /** * Constructs a ScrollBarLayout. If the given Transposer is enabled, the * Scrollbar will be horizontally oriented. Otherwise, the ScrollBar will be * vertically oriented. * * @param t * the Transposer * @since 2.0 */ public ScrollBarLayout(Transposer t) { transposer = t; } /** * @see AbstractLayout#setConstraint(IFigure, Object) */ public void setConstraint(IFigure figure, Object constraint) { if (constraint.equals(UP_ARROW)) up = figure; else if (constraint.equals(DOWN_ARROW)) down = figure; else if (constraint.equals(THUMB)) thumb = figure; else if (constraint.equals(PAGE_UP)) pageUp = figure; else if (constraint.equals(PAGE_DOWN)) pageDown = figure; } /** * @see AbstractLayout#calculatePreferredSize(IFigure, int, int) */ protected Dimension calculatePreferredSize(IFigure parent, int w, int h) { Insets insets = transposer.t(parent.getInsets()); Dimension d = new Dimension(16, 16 * 4); d.expand(insets.getWidth(), insets.getHeight()); return transposer.t(d); } /** * @see LayoutManager#layout(IFigure) */ public void layout(IFigure parent) { ScrollBar scrollBar = (ScrollBar) parent; Rectangle trackBounds = layoutButtons(scrollBar); int extent = scrollBar.getExtent(); int max = scrollBar.getMaximum(); int min = scrollBar.getMinimum(); int totalRange = max - min; int valueRange = totalRange - extent; if ((valueRange < 1) || (!scrollBar.isEnabled())) { Rectangle boundsUpper = new Rectangle(trackBounds), boundsLower = new Rectangle( trackBounds); boundsUpper.height /= 2; boundsLower.y += boundsUpper.height; boundsLower.height = trackBounds.height - boundsUpper.height; if (pageUp != null) pageUp.setBounds(transposer.t(boundsUpper)); if (pageDown != null) pageDown.setBounds(transposer.t(boundsLower)); return; } if (totalRange == 0) return; int thumbHeight = Math.max(thumb == null ? 0 : thumb.getMinimumSize().height, trackBounds.height * extent / totalRange); if (thumb != null) thumb.setVisible(trackBounds.height > thumbHeight); int thumbY = trackBounds.y + (trackBounds.height - thumbHeight) * (scrollBar.getValue() - min) / valueRange; Rectangle thumbBounds = new Rectangle(trackBounds.x, thumbY, trackBounds.width, thumbHeight); if (thumb != null) thumb.setBounds(transposer.t(thumbBounds)); if (pageUp != null) pageUp.setBounds(transposer.t(new Rectangle(trackBounds.x, trackBounds.y, trackBounds.width, thumbBounds.y - trackBounds.y))); if (pageDown != null) pageDown.setBounds(transposer.t(new Rectangle(trackBounds.x, thumbBounds.y + thumbHeight, trackBounds.width, trackBounds .bottom() - thumbBounds.bottom()))); } /** * Places the buttons and returns the Rectangle into which the track should * be placed. The track consists of the pageup, pagedown, and thumb figures. * The Rectangle returned should be transposed correctly, that is, it should * be vertically oriented. Users of the rectangle will re-transpose it for * horizontal use. * * @param scrollBar * the scrollbar whose buttons are being layed out * @return the Rectangle into which the track should be placed * @since 2.0 */ protected Rectangle layoutButtons(ScrollBar scrollBar) { Rectangle bounds = transposer.t(scrollBar.getClientArea()); Dimension buttonSize = new Dimension(bounds.width, Math.min( bounds.width, bounds.height / 2)); if (up != null) up.setBounds(transposer.t(new Rectangle(bounds.getTopLeft(), buttonSize))); if (down != null) { Rectangle r = new Rectangle(bounds.x, bounds.bottom() - buttonSize.height, buttonSize.width, buttonSize.height); down.setBounds(transposer.t(r)); } Rectangle trackBounds = bounds.getCropped(new Insets((up == null) ? 0 : buttonSize.height, 0, (down == null) ? 0 : buttonSize.height, 0)); return trackBounds; } /** * @see LayoutManager#remove(IFigure) */ public void remove(IFigure child) { if (child == up) { up = null; } else if (child == down) { down = null; } else if (child == thumb) { thumb = null; } else if (child == pageUp) { pageUp = null; } else if (child == pageDown) { pageDown = null; } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ScrollPane.java000066400000000000000000000207271166301720600264050ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Point; /** * A class which implements automatic horizontal and/or vertical scrolling for a * single IFigure child. *

    * ScrollBar visibilites are represented by integer class constants: *

      *
    • NEVER: Never show the ScrollBar *
    • AUTOMATIC: Show as needed, when the ScrollPane can no longer contain its * view *
    • ALWAYS: Always show the ScrollBar *
    * To use, instantiate a ScrollPane object and call its setView(IFigure) method * passing the IFigure that is desired to have scrolling ability. */ public class ScrollPane extends Figure { /** Constant indicating to never show the ScrollBar */ public static final int NEVER = 0; /** * Constant indicating to show as needed, when the ScrollPane can't contain * its view */ public static final int AUTOMATIC = 1; /** Constant indicating to always show the ScrollBar */ public static final int ALWAYS = 2; /** The viewport being scrolled */ protected Viewport viewport; /** The horizontal scrollbar */ protected ScrollBar hBar; /** The vertical scrollbar */ protected ScrollBar vBar; private int hVisibility = AUTOMATIC, vVisibility = AUTOMATIC; /** * Constructs a new ScrollPane with a ScrollPaneLayout. * * @since 2.0 */ public ScrollPane() { setLayoutManager(new ScrollPaneLayout()); } /** * Creates a new horizontally oriented ScrollBar and adds it to this * ScrollPane. * * @since 2.0 */ protected void createHorizontalScrollBar() { ScrollBar bar = new ScrollBar(); bar.setHorizontal(true); setHorizontalScrollBar(bar); } /** * Creates a new Viewport and adds it to this ScrollPane. * * @since 2.0 */ protected void createViewport() { setViewport(new Viewport()); } /** * Creates a new vertically oriented ScrollBar and adds it to this * ScrollPane. * * @since 2.0 */ protected void createVerticalScrollBar() { ScrollBar bar = new ScrollBar(); setVerticalScrollBar(bar); } /** * Returns the ScrollPane's horizontal ScrollBar. * * @return the horizontal scrollbar * @since 2.0 */ public ScrollBar getHorizontalScrollBar() { if (hBar == null) createHorizontalScrollBar(); return hBar; } /** * Returns the visibility of the ScrollPane's horizontal ScrollBar. These * are represented by the integer class constants {@link #NEVER}, * {@link #AUTOMATIC}, and {@link #ALWAYS}. The default is * {@link #AUTOMATIC}. * * @return the visiblity of the horizontal scrollbar * @since 2.0 */ public int getHorizontalScrollBarVisibility() { return hVisibility; } /** * Returns the ScrollPane's vertical ScrollBar. * * @return teh vertical scrollbar * @since 2.0 */ public ScrollBar getVerticalScrollBar() { if (vBar == null) createVerticalScrollBar(); return vBar; } /** * Returns the visibility of the ScrollPane's vertical ScrollBar. These are * represented by the integer class constants {@link #NEVER}, * {@link #AUTOMATIC}, and {@link #ALWAYS}. The default is * {@link #AUTOMATIC}. * * @return the visibility of the vertical scrollbar * @since 2.0 */ public int getVerticalScrollBarVisibility() { return vVisibility; } /** * Returns the contents of the viewport. * * @return the contents of the viewport */ public IFigure getContents() { return getView(); } /** * Returns the ScrollPane's view. The view is the IFigure that is the * contents of the ScrollPane. * * @return the contents * @deprecated use getContents() * @since 2.0 */ public IFigure getView() { return getViewport().getContents(); } /** * Returns the ScrollPane's {@link Viewport}. * * @return the viewport * @since 2.0 */ public Viewport getViewport() { if (viewport == null) createViewport(); return viewport; } /** * Returns true because ScrollPanes are always opaque. * * @see IFigure#isOpaque() */ public boolean isOpaque() { return true; } /** * Scrolls the Scrollpane horizontally x pixels from its left-most position. * * @param x * the amount to scroll horizontally * @since 2.0 */ public void scrollHorizontalTo(int x) { getViewport().setHorizontalLocation(x); } /** * Scrolls the Scrollpane horizontally from its left-most position by * location.x pixels and vertically from its top-most position by location.y * pixels. * * @param location * the point to scroll to * @since 2.0 */ public void scrollTo(Point location) { scrollHorizontalTo(location.x); scrollVerticalTo(location.y); } /** * Scrolls the Scrollpane vertically y pixels from its top-most position. * * @param y * the amount to scroll vertically * @since 2.0 */ public void scrollVerticalTo(int y) { getViewport().setVerticalLocation(y); } /** * Sets the contents of the current viewport. * * @param figure * the contents of the viewport */ public void setContents(IFigure figure) { setView(figure); } /** * Sets the ScrollPane's horizontal ScrollBar to the passed ScrollBar. * * @param bar * the new horizontal scrollbar * @since 2.0 */ public void setHorizontalScrollBar(ScrollBar bar) { if (hBar != null) { remove(hBar); hBar.getRangeModel().removePropertyChangeListener(hBar); } hBar = bar; if (hBar != null) { add(hBar); hBar.setRangeModel(getViewport().getHorizontalRangeModel()); } } /** * Sets the horizontal ScrollBar visibility of the ScrollPane to the passed * value. These are represented by the integer class constants * {@link #NEVER}, {@link #AUTOMATIC}, and {@link #ALWAYS}. The default is * {@link #AUTOMATIC}. * * @param v * the new horizontal visibility * @since 2.0 */ public void setHorizontalScrollBarVisibility(int v) { if (hVisibility == v) return; hVisibility = v; revalidate(); } /** * Sets both the horizontal and vertical ScrollBar visibilities of the * ScrollPane to the passed value. These are represented by the integer * class constants {@link #NEVER}, {@link #AUTOMATIC}, and {@link #ALWAYS}. * The default is {@link #AUTOMATIC}. * * @param v * the new vertical and horizontal visibility * @since 2.0 */ public void setScrollBarVisibility(int v) { setHorizontalScrollBarVisibility(v); setVerticalScrollBarVisibility(v); } /** * Sets the ScrollPane's vertical ScrollBar to the passed Scrollbar. * * @param bar * the new vertical scrollbar * @since 2.0 */ public void setVerticalScrollBar(ScrollBar bar) { if (vBar != null) { remove(vBar); vBar.getRangeModel().removePropertyChangeListener(vBar); } vBar = bar; if (vBar != null) { add(vBar); vBar.setRangeModel(getViewport().getVerticalRangeModel()); } } /** * Sets the vertical ScrollBar visibility of the ScrollPane to the passed * value. These are represented by the integer class constants * {@link #NEVER}, {@link #AUTOMATIC}, and {@link #ALWAYS}. The default is * {@link #AUTOMATIC}. * * @param v * the new vertical scrollbar visibility * @since 2.0 */ public void setVerticalScrollBarVisibility(int v) { if (vVisibility == v) return; vVisibility = v; revalidate(); } /** * Sets the ScrollPane's view to the passed IFigure. The view is the * top-level IFigure which represents the contents of the ScrollPane. * * @param figure * the new contents * @deprecated call setContents(IFigure) instead * @since 2.0 */ public void setView(IFigure figure) { getViewport().setContents(figure); } /** * Sets the ScrollPane's Viewport to the passed value. * * @param vp * the new viewport * @since 2.0 */ public void setViewport(Viewport vp) { if (viewport != null) remove(viewport); viewport = vp; if (vp != null) add(vp, 0); } /** * @see IFigure#validate() */ public void validate() { super.validate(); getHorizontalScrollBar().validate(); getVerticalScrollBar().validate(); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ScrollPaneLayout.java000066400000000000000000000104601166301720600275740ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Insets; import org.eclipse.draw2d.geometry.Rectangle; /** * The ScrollPaneLayout is responsible for laying out the {@link Viewport} and * {@link ScrollBar ScrollBars} of a {@link ScrollPane}. */ public class ScrollPaneLayout extends AbstractHintLayout { /** @see ScrollPane#NEVER */ protected static final int NEVER = ScrollPane.NEVER; /** @see ScrollPane#AUTOMATIC */ protected static final int AUTO = ScrollPane.AUTOMATIC; /** @see ScrollPane#ALWAYS */ protected static final int ALWAYS = ScrollPane.ALWAYS; /** * @see AbstractHintLayout#calculateMinimumSize(IFigure, int, int) */ public Dimension calculateMinimumSize(IFigure figure, int w, int h) { ScrollPane scrollpane = (ScrollPane) figure; Insets insets = scrollpane.getInsets(); Dimension d = scrollpane.getViewport().getMinimumSize(w, h); return d.getExpanded(insets.getWidth(), insets.getHeight()); } /** * Calculates and returns the preferred size of the container based on the * given hints. If the given ScrollPane's (container) horizontal and * vertical scroll bar visibility is not {@link ScrollPane#NEVER}, then * space for those bars is always deducted from the hints (whether or not we * actually need the scroll bars). * * @param container * the ScrollPane whose preferred size needs to be calculated * @param wHint * the width hint * @param hHint * the height hint * @return the preferred size of the given container * @since 2.0 */ protected Dimension calculatePreferredSize(IFigure container, int wHint, int hHint) { ScrollPane scrollpane = (ScrollPane) container; ScrollBar hBar = scrollpane.getHorizontalScrollBar(); ScrollBar vBar = scrollpane.getVerticalScrollBar(); Insets insets = scrollpane.getInsets(); int reservedWidth = insets.getWidth(); int reservedHeight = insets.getHeight(); if (scrollpane.getVerticalScrollBarVisibility() != ScrollPane.NEVER) reservedWidth += vBar.getPreferredSize().width; if (scrollpane.getHorizontalScrollBarVisibility() != ScrollPane.NEVER) reservedHeight += hBar.getPreferredSize().height; if (wHint > -1) wHint = Math.max(0, wHint - reservedWidth); if (hHint > -1) hHint = Math.max(0, hHint - reservedHeight); return scrollpane.getViewport().getPreferredSize(wHint, hHint) .getExpanded(reservedWidth, reservedHeight); } /** * @see org.eclipse.draw2d.LayoutManager#layout(IFigure) */ public void layout(IFigure parent) { ScrollPane scrollpane = (ScrollPane) parent; Viewport viewport = scrollpane.getViewport(); ScrollBar hBar = scrollpane.getHorizontalScrollBar(), vBar = scrollpane .getVerticalScrollBar(); ScrollPaneSolver.Result result = ScrollPaneSolver.solve( parent.getClientArea(), viewport, scrollpane.getHorizontalScrollBarVisibility(), scrollpane.getVerticalScrollBarVisibility(), vBar.getPreferredSize().width, hBar.getPreferredSize().height); if (result.showV) { vBar.setBounds(new Rectangle(result.viewportArea.right(), result.viewportArea.y, result.insets.right, result.viewportArea.height)); } if (result.showH) { hBar.setBounds(new Rectangle(result.viewportArea.x, result.viewportArea.bottom(), result.viewportArea.width, result.insets.bottom)); } vBar.setVisible(result.showV); hBar.setVisible(result.showH); int vStepInc = vBar.getStepIncrement(); int vPageInc = vBar.getRangeModel().getExtent() - vStepInc; if (vPageInc < vStepInc) vPageInc = vStepInc; vBar.setPageIncrement(vPageInc); int hStepInc = hBar.getStepIncrement(); int hPageInc = hBar.getRangeModel().getExtent() - hStepInc; if (hPageInc < hStepInc) hPageInc = hStepInc; hBar.setPageIncrement(hPageInc); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ScrollPaneSolver.java000066400000000000000000000106161166301720600275740ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Insets; import org.eclipse.draw2d.geometry.Rectangle; /** * This class handles the calculation of solving for the area of a * {@link org.eclipse.draw2d.ScrollPane}'s viewport and insets. Also determines * if the horizontal and vertical scrollbars should be visible. */ public class ScrollPaneSolver { /** Scrollbar visibility constants -- never show scrollbars **/ public static final int NEVER = 0; /** Scrollbar visibility constants -- show scrollbars automatically **/ public static final int AUTOMATIC = 1; /** Scrollbar visibility constants -- always show scrollbars **/ public static final int ALWAYS = 2; /** * Container class for the results of ScrollPaneSolver's solve method */ public static class Result { /** Show horizontal scrollbar boolean **/ public boolean showH; /** Show vertical scrollbar boolean **/ public boolean showV; /** Area of ScrollPane's viewport **/ public Rectangle viewportArea; /** Insets of ScrollPane **/ public Insets insets; } /** * Solves for the viewport area, insets, and visibility of horizontal and * vertical scrollbars of a ScrollPane * * @param clientArea * The ScrollPane's client area * @param viewport * The ScrollPane's Viewport * @param hVis * Horizontal scrollbar visibility * @param vVis * Vertical scrollbar visibility * @param vBarWidth * Width of vertical scrollbar * @param hBarHeight * Height of horizontal scrollbar * @return the Result */ public static Result solve(Rectangle clientArea, Viewport viewport, int hVis, int vVis, int vBarWidth, int hBarHeight) { Result result = new Result(); result.insets = new Insets(); result.insets.bottom = hBarHeight; result.insets.right = vBarWidth; Dimension available = clientArea.getSize(); Dimension guaranteed = new Dimension(available).shrink( (vVis == NEVER ? 0 : result.insets.right), (hVis == NEVER ? 0 : result.insets.bottom)); guaranteed.width = Math.max(guaranteed.width, 0); guaranteed.height = Math.max(guaranteed.height, 0); int wHint = guaranteed.width; int hHint = guaranteed.height; Dimension preferred = viewport.getPreferredSize(wHint, hHint).getCopy(); Insets viewportInsets = viewport.getInsets(); /* * This was calling viewport.getMinimumSize(), but viewport's minimum * size was really small, and wasn't a function of its contents. */ Dimension viewportMinSize = new Dimension(viewportInsets.getWidth(), viewportInsets.getHeight()); if (viewport.getContents() != null) { if (viewport.getContentsTracksHeight() && hHint > -1) hHint = Math.max(0, hHint - viewportInsets.getHeight()); if (viewport.getContentsTracksWidth() && wHint > -1) wHint = Math.max(0, wHint - viewportInsets.getWidth()); viewportMinSize.expand(viewport.getContents().getMinimumSize(wHint, hHint)); } /* * Adjust preferred size if tracking flags set. Basically, tracking == * "compress view until its minimum size is reached". */ if (viewport.getContentsTracksHeight()) preferred.height = viewportMinSize.height; if (viewport.getContentsTracksWidth()) preferred.width = viewportMinSize.width; boolean none = available.contains(preferred), both = !none && preferred.containsProper(guaranteed), showV = both || preferred.height > available.height, showH = both || preferred.width > available.width; // Adjust for visibility override flags result.showV = vVis != NEVER && (showV || vVis == ALWAYS); result.showH = hVis != NEVER && (showH || hVis == ALWAYS); if (!result.showV) result.insets.right = 0; if (!result.showH) result.insets.bottom = 0; result.viewportArea = clientArea.getCropped(result.insets); viewport.setBounds(result.viewportArea); return result; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/Shape.java000066400000000000000000000325431166301720600254020ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.graphics.LineAttributes; /** * Provides abstract support for a variety of shapes. *

    * When customizing shapes, you shouldn't override paintFigure(). Override * fillShape() and outlineShape() methods instead. */ public abstract class Shape extends Figure { /** * The width of this shape's outline. * * @deprecated Use {@link #setLineWidth(int)} or * {@link #setLineWidthFloat(float)} instead. */ protected int lineWidth; /** * Private copy of lineWidth field to track changes. We cannot compare to * the float line width because rounding may make them seem equal when they * have actually changed. * * e.g. someone sets int line width to 5, when float line width was already * 5.4, float line width should change to 5.0, but comparing them as ints * would suggest there's no change to synchronize. */ private int lastLineWidth; /** * The line style to be used for this shape's outline. * * @deprecated Use {@link #setLineStyle(int)} instead. */ protected int lineStyle; /** * Private copy of lineStyle field to track changes. */ private int lastLineStyle; private LineAttributes lineAttributes; private boolean fill; private boolean outline; private boolean xorFill; private boolean xorOutline; private Integer antialias; private Integer alpha; /** * Default constructor. * * @since 2.0 */ public Shape() { lineAttributes = new LineAttributes(1.0f); fill = true; outline = true; xorFill = false; xorOutline = false; antialias = null; alpha = null; // synchronize parameters lineWidth = (int) lineAttributes.width; lineStyle = lineAttributes.style; lastLineWidth = lineWidth; lastLineStyle = lineStyle; } /** * Fills the interior of the shape with the background color. * * @param graphics * the graphics object */ protected abstract void fillShape(Graphics graphics); /** * Outlines this shape using the foreground color. * * @param graphics * the graphics object */ protected abstract void outlineShape(Graphics graphics); /** * Paints the shape. Each shape has an outline to draw, and a region to fill * within that outline. Disabled shapes must visually depict the disabled * state. * * @see Figure#paintFigure(Graphics) */ public void paintFigure(Graphics graphics) { if (antialias != null) { graphics.setAntialias(antialias.intValue()); } if (alpha != null) { graphics.setAlpha(alpha.intValue()); } // graphics.rotate(rotation); /* * see bug #267397: paintFigure was historically not called, disabling * setOpaque() behavior, and it was decided to defend the API's * consistency. */ // paint background and border // super.paintFigure(graphics); if (!isEnabled()) { graphics.translate(1, 1); graphics.setBackgroundColor(ColorConstants.buttonLightest); graphics.setForegroundColor(ColorConstants.buttonLightest); if (fill) { paintFill(graphics); } if (outline) { paintOutline(graphics); } graphics.setBackgroundColor(ColorConstants.buttonDarker); graphics.setForegroundColor(ColorConstants.buttonDarker); graphics.translate(-1, -1); } if (fill) { paintFill(graphics); } if (outline) { paintOutline(graphics); } } private void paintOutline(Graphics graphics) { // synchronize the line width and style attributes to the // public fields which may have been assigned // to without our knowledge lineAttributes.width = getLineWidthFloat(); lineAttributes.style = getLineStyle(); graphics.setLineAttributes(lineAttributes); if (xorOutline) { /* * XORMode is a non-advanced only feature (GDI, not in GDI+ on * windows) * * Also, XORMode is deprecated in SWT, so this should really be * removed completely at some point. XORMode isn't supported on Mac * OSX at all. */ boolean oldAdv = graphics.getAdvanced(); graphics.setAdvanced(false); graphics.setXORMode(true); outlineShape(graphics); graphics.setAdvanced(oldAdv); } else { outlineShape(graphics); } } private void paintFill(Graphics graphics) { if (xorFill) { /* * XORMode is a non-advanced only feature (GDI, not in GDI+ on * windows) * * Also, XORMode is deprecated in SWT, so this should really be * removed completely at some point. XORMode isn't supported on Mac * OSX at all. */ boolean oldAdv = graphics.getAdvanced(); graphics.setAdvanced(false); graphics.setXORMode(true); fillShape(graphics); graphics.setAdvanced(oldAdv); } else { fillShape(graphics); } } /** * Sets whether this shape should fill its region or not. It repaints this * figure. * * @param b * fill state * @since 2.0 */ public void setFill(boolean b) { if (fill != b) { fill = b; repaint(); } } /** * Sets whether XOR based fill should be used by the shape. It repaints this * figure. * * @param b * XOR fill state * @since 2.0 */ public void setFillXOR(boolean b) { if (xorFill != b) { xorFill = b; repaint(); } } /** * Sets whether the outline should be drawn for this shape. * * @param b * true if the shape should be outlined * @since 2.0 */ public void setOutline(boolean b) { if (outline != b) { outline = b; repaint(); } } /** * Sets whether XOR based outline should be used for this shape. * * @param b * true if the outline should be XOR'ed * @since 2.0 */ public void setOutlineXOR(boolean b) { if (xorOutline != b) { xorOutline = b; repaint(); } } /** * Sets whether XOR based fill and XOR based outline should be used for this * shape. * * @param b * true if the outline and fill should be XOR'ed * @since 2.0 */ public void setXOR(boolean b) { xorOutline = xorFill = b; repaint(); } /** * @since 3.5 */ public Integer getAlpha() { return alpha; } /** * @since 3.5 */ public Integer getAntialias() { return antialias; } /** * Returns line attributes used when drawing this shape. * * @see org.eclipse.swt.graphics.LineAttributes * * Performance note: creates and returns a clone. * * @return current line attributes * @since 3.5 */ public LineAttributes getLineAttributes() { return SWTGraphics.clone(lineAttributes); } /** * Returns the line width of this shape's outline. * * @return the line width */ public int getLineWidth() { // synchronize lineWidth field for // backwards compatibility if (lineWidth != lastLineWidth) { lineAttributes.width = lineWidth; lastLineWidth = lineWidth; } return (int) lineAttributes.width; } /** * Returns the line width of this shape's outline. * * @see org.eclipse.swt.graphics.LineAttributes#width * * @since 3.5 */ public float getLineWidthFloat() { // synchronize lineWidth field for // backwards compatibility if (lineWidth != lastLineWidth) { lineAttributes.width = lineWidth; lastLineWidth = lineWidth; } return lineAttributes.width; } /** * Returns the line join style of this shape's outline. * * @see org.eclipse.swt.graphics.LineAttributes#join * * @since 3.5 */ public int getLineJoin() { return lineAttributes.join; } /** * Returns the line cap style of this shape's outline. * * @see org.eclipse.swt.graphics.LineAttributes#cap * * @since 3.5 */ public int getLineCap() { return lineAttributes.cap; } /** * Returns the line style of this shape's outline. * * @see org.eclipse.swt.graphics.LineAttributes#style * * @return the line style */ public int getLineStyle() { // synchronize line style which may have been assigned // to lineStyle field for backwards compatibility if (lineStyle != lastLineStyle) { lineAttributes.style = lineStyle; lastLineStyle = lineStyle; } return lineAttributes.style; } /** * Returns the line dash style of this shape's outline. * * @see org.eclipse.swt.graphics.LineAttributes#dash * * @since 3.5 */ public float[] getLineDash() { if (lineAttributes.dash != null) { return (float[]) lineAttributes.dash.clone(); } else { return null; } } /** * Returns the line dash offset of this shape's outline. * * @see org.eclipse.swt.graphics.LineAttributes#dashOffset * * @since 3.5 */ public float getLineDashOffset() { return lineAttributes.dashOffset; } /** * Returns the line dash miter limit of this shape's outline. * * @see org.eclipse.swt.graphics.LineAttributes#miterLimit * * @since 3.5 */ public float getLineMiterLimit() { return lineAttributes.miterLimit; } /** * @since 3.5 */ public void setAlpha(Integer value) { if (alpha != null) { if (!alpha.equals(value)) { alpha = value; repaint(); } } else if (value != null) { alpha = value; repaint(); } } /** * @since 3.5 */ public void setAlpha(int value) { if (alpha != null) { if (alpha.intValue() != value) { alpha = new Integer(value); repaint(); } } else { alpha = new Integer(value); repaint(); } } /** * @see org.eclipse.swt.graphics.GC#setAntialias(int) * @param value * @since 3.5 */ public void setAntialias(Integer value) { if (antialias != null) { if (!antialias.equals(value)) { antialias = value; repaint(); } } else if (value != null) { antialias = value; repaint(); } } /** * @since 3.5 */ public void setAntialias(int value) { if (antialias != null) { if (antialias.intValue() != value) { antialias = new Integer(value); repaint(); } } else { antialias = new Integer(value); repaint(); } } /** * Sets all line attributes at once. * * @see org.eclipse.swt.graphics.LineAttributes * * @param la * @since 3.5 */ public void setLineAttributes(LineAttributes la) { if (!lineAttributes.equals(la)) { SWTGraphics.copyLineAttributes(lineAttributes, la); repaint(); } } /** * Sets the line width to be used to outline the shape. * * @param w * the new width * @since 2.0 */ public void setLineWidth(int w) { float _w = w; if (lineAttributes.width != _w) { lineAttributes.width = _w; // synchronize lineWidth fields for // backwards compatibility lineWidth = w; lastLineWidth = w; repaint(); } } /** * Sets the line width of this shape's outline. * * @see org.eclipse.swt.graphics.LineAttributes#width * * @param value * @since 3.5 */ public void setLineWidthFloat(float value) { if (lineAttributes.width != value) { lineAttributes.width = value; // synchronize lineWidth fields for // backwards compatibility lineWidth = (int) value; lastLineWidth = (int) value; repaint(); } } /** * Sets the line join style of this shape's outline. * * @see org.eclipse.swt.graphics.LineAttributes#join * * @param join * @since 3.5 */ public void setLineJoin(int join) { if (lineAttributes.join != join) { lineAttributes.join = join; repaint(); } } /** * Sets the line cap style of this shape's outline. * * @see org.eclipse.swt.graphics.LineAttributes#cap * * @param cap * @since 3.5 */ public void setLineCap(int cap) { if (lineAttributes.cap != cap) { lineAttributes.cap = cap; repaint(); } } /** * Sets the line style of this shape's outline. * * @see org.eclipse.swt.graphics.LineAttributes#style * * @param style * the new line style * @since 2.0 */ public void setLineStyle(int style) { if (lineAttributes.style != style) { lineAttributes.style = style; // synchronize the lineStyle field // to the lineStyle we actually use lineStyle = style; lastLineStyle = style; repaint(); } } /** * Sets the line dash style of this shape's outline. * * @see org.eclipse.swt.graphics.LineAttributes#dash * * @param dash * @since 3.5 */ public void setLineDash(float[] dash) { if ((dash != null) && !dash.equals(lineAttributes.dash)) { lineAttributes.dash = (float[]) dash.clone(); repaint(); } else if ((dash == null) && (lineAttributes.dash != null)) { lineAttributes.dash = null; repaint(); } } /** * Sets the line dash offset of this shape's outline. * * @see org.eclipse.swt.graphics.LineAttributes#dashOffset * * @param dashOffset * @since 3.5 */ public void setLineDashOffset(float dashOffset) { if (lineAttributes.dashOffset != dashOffset) { lineAttributes.dashOffset = dashOffset; repaint(); } } /** * Sets the line dash miter limit of this shape's outline. * * @see org.eclipse.swt.graphics.LineAttributes#miterLimit * * @param miterLimit * @since 3.5 */ public void setLineMiterLimit(float miterLimit) { if (lineAttributes.miterLimit != miterLimit) { lineAttributes.miterLimit = miterLimit; repaint(); } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ShortestPathConnectionRouter.java000066400000000000000000000250551166301720600322130ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.PointList; import org.eclipse.draw2d.geometry.PrecisionPoint; import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.draw2d.graph.Path; import org.eclipse.draw2d.graph.ShortestPathRouter; /** * Routes multiple connections around the children of a given container figure. * * @author Whitney Sorenson * @author Randy Hudson * @since 3.1 */ public final class ShortestPathConnectionRouter extends AbstractRouter { private class LayoutTracker extends LayoutListener.Stub { public void postLayout(IFigure container) { processLayout(); } public void remove(IFigure child) { removeChild(child); } public void setConstraint(IFigure child, Object constraint) { addChild(child); } } private Map constraintMap = new HashMap(); private Map figuresToBounds; private Map connectionToPaths; private boolean isDirty; private ShortestPathRouter algorithm = new ShortestPathRouter(); private IFigure container; private Set staleConnections = new HashSet(); private LayoutListener listener = new LayoutTracker(); private FigureListener figureListener = new FigureListener() { public void figureMoved(IFigure source) { Rectangle newBounds = source.getBounds().getCopy(); if (algorithm.updateObstacle( (Rectangle) figuresToBounds.get(source), newBounds)) { queueSomeRouting(); isDirty = true; } figuresToBounds.put(source, newBounds); } }; private boolean ignoreInvalidate; /** * Creates a new shortest path router with the given container. The * container contains all the figure's which will be treated as obstacles * for the connections to avoid. Any time a child of the container moves, * one or more connections will be revalidated to process the new obstacle * locations. The connections being routed must not be contained within the * container. * * @param container * the container */ public ShortestPathConnectionRouter(IFigure container) { isDirty = false; algorithm = new ShortestPathRouter(); this.container = container; } void addChild(IFigure child) { if (connectionToPaths == null) return; if (figuresToBounds.containsKey(child)) return; Rectangle bounds = child.getBounds().getCopy(); algorithm.addObstacle(bounds); figuresToBounds.put(child, bounds); child.addFigureListener(figureListener); isDirty = true; } private void hookAll() { figuresToBounds = new HashMap(); for (int i = 0; i < container.getChildren().size(); i++) addChild((IFigure) container.getChildren().get(i)); container.addLayoutListener(listener); } private void unhookAll() { container.removeLayoutListener(listener); if (figuresToBounds != null) { Iterator figureItr = figuresToBounds.keySet().iterator(); while (figureItr.hasNext()) { // Must use iterator's remove to avoid concurrent modification IFigure child = (IFigure) figureItr.next(); figureItr.remove(); removeChild(child); } figuresToBounds = null; } } /** * Gets the constraint for the given {@link Connection}. The constraint is * the paths list of bend points for this connection. * * @param connection * The connection whose constraint we are retrieving * @return The constraint */ public Object getConstraint(Connection connection) { return constraintMap.get(connection); } /** * Returns the default spacing maintained on either side of a connection. * The default value is 4. * * @return the connection spacing * @since 3.2 */ public int getSpacing() { return algorithm.getSpacing(); } /** * @see ConnectionRouter#invalidate(Connection) */ public void invalidate(Connection connection) { if (ignoreInvalidate) return; staleConnections.add(connection); isDirty = true; } private void processLayout() { if (staleConnections.isEmpty()) return; ((Connection) staleConnections.iterator().next()).revalidate(); } private void processStaleConnections() { Iterator iter = staleConnections.iterator(); if (iter.hasNext() && connectionToPaths == null) { connectionToPaths = new HashMap(); hookAll(); } while (iter.hasNext()) { Connection conn = (Connection) iter.next(); Path path = (Path) connectionToPaths.get(conn); if (path == null) { path = new Path(conn); connectionToPaths.put(conn, path); algorithm.addPath(path); } List constraint = (List) getConstraint(conn); if (constraint == null) constraint = Collections.EMPTY_LIST; Point start = conn.getSourceAnchor().getReferencePoint().getCopy(); Point end = conn.getTargetAnchor().getReferencePoint().getCopy(); container.translateToRelative(start); container.translateToRelative(end); path.setStartPoint(start); path.setEndPoint(end); if (!constraint.isEmpty()) { PointList bends = new PointList(constraint.size()); for (int i = 0; i < constraint.size(); i++) { Bendpoint bp = (Bendpoint) constraint.get(i); bends.addPoint(bp.getLocation()); } path.setBendPoints(bends); } else path.setBendPoints(null); isDirty |= path.isDirty; } staleConnections.clear(); } void queueSomeRouting() { if (connectionToPaths == null || connectionToPaths.isEmpty()) return; try { ignoreInvalidate = true; ((Connection) connectionToPaths.keySet().iterator().next()) .revalidate(); } finally { ignoreInvalidate = false; } } /** * @see ConnectionRouter#remove(Connection) */ public void remove(Connection connection) { staleConnections.remove(connection); constraintMap.remove(connection); if (connectionToPaths == null) return; Path path = (Path) connectionToPaths.remove(connection); algorithm.removePath(path); isDirty = true; if (connectionToPaths.isEmpty()) { unhookAll(); connectionToPaths = null; } else { // Make sure one of the remaining is revalidated so that we can // re-route again. queueSomeRouting(); } } void removeChild(IFigure child) { if (connectionToPaths == null) return; Rectangle bounds = child.getBounds().getCopy(); boolean change = algorithm.removeObstacle(bounds); figuresToBounds.remove(child); child.removeFigureListener(figureListener); if (change) { isDirty = true; queueSomeRouting(); } } /** * @see ConnectionRouter#route(Connection) */ public void route(Connection conn) { if (isDirty) { ignoreInvalidate = true; processStaleConnections(); isDirty = false; List updated = algorithm.solve(); Connection current; for (int i = 0; i < updated.size(); i++) { Path path = (Path) updated.get(i); current = (Connection) path.data; current.revalidate(); PointList points = path.getPoints().getCopy(); Point ref1, ref2, start, end; ref1 = new PrecisionPoint(points.getPoint(1)); ref2 = new PrecisionPoint(points.getPoint(points.size() - 2)); current.translateToAbsolute(ref1); current.translateToAbsolute(ref2); start = current.getSourceAnchor().getLocation(ref1).getCopy(); end = current.getTargetAnchor().getLocation(ref2).getCopy(); current.translateToRelative(start); current.translateToRelative(end); points.setPoint(start, 0); points.setPoint(end, points.size() - 1); current.setPoints(points); } ignoreInvalidate = false; } } /** * @return All connection paths after routing dirty paths. Some of the paths * that were not dirty may change as well, as a consequence of new * routings. * @since 3.5 */ public List getPathsAfterRouting() { if (isDirty) { processStaleConnections(); isDirty = false; List all = algorithm.solve(); return all; } return null; } /** * @see ConnectionRouter#setConstraint(Connection, Object) */ public void setConstraint(Connection connection, Object constraint) { // Connection.setConstraint() already calls revalidate, so we know that // a // route() call will follow. staleConnections.add(connection); constraintMap.put(connection, constraint); isDirty = true; } /** * Sets the default space that should be maintained on either side of a * connection. This causes the connections to be separated from each other * and from the obstacles. The default value is 4. * * @param spacing * the connection spacing * @since 3.2 */ public void setSpacing(int spacing) { algorithm.setSpacing(spacing); } /** * @return true if there are connections routed by this router, false * otherwise * @since 3.5 */ public boolean hasMoreConnections() { return connectionToPaths != null && !connectionToPaths.isEmpty(); } /** * @return the container which contains connections routed by this router * @since 3.5 */ public IFigure getContainer() { return container; } /** * Sets the value indicating if connection invalidation should be ignored. * * @param b * true if invalidation should be skipped, false otherwise * @since 3.5 */ public void setIgnoreInvalidate(boolean b) { ignoreInvalidate = b; } /** * Returns the value indicating if connection invalidation should be * ignored. * * @return true if invalidation should be skipped, false otherwise * @since 3.5 */ public boolean shouldIgnoreInvalidate() { return ignoreInvalidate; } /** * Returns the value indicating if the router is dirty, i.e. if there are * any outstanding connections that need to be routed * * @return true if there are connections to be routed, false otherwise * @since 3.5 */ public boolean isDirty() { return isDirty; } /** * Returns true if the given connection is routed by this router, false * otherwise * * @param conn * Connection whose router is questioned * @return true if this is the router used for conn * @since 3.5 */ public boolean containsConnection(Connection conn) { return connectionToPaths != null && connectionToPaths.containsKey(conn); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/SimpleEtchedBorder.java000066400000000000000000000034131166301720600300400ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Insets; import org.eclipse.draw2d.geometry.Rectangle; /** * Provides a two pixel wide constant sized border, having an etched look. */ public final class SimpleEtchedBorder extends SchemeBorder { /** The singleton instance of this class */ public static final Border singleton = new SimpleEtchedBorder(); /** The insets */ protected static final Insets INSETS = new Insets(2); /** * Constructs a default border having a two pixel wide border. * * @since 2.0 */ protected SimpleEtchedBorder() { } /** * Returns the Insets used by this border. This is a constant value of two * pixels in each direction. * * @see Border#getInsets(IFigure) */ public Insets getInsets(IFigure figure) { return new Insets(INSETS); } /** * Returns the opaque state of this border. This border is opaque and takes * responsibility to fill the region it encloses. * * @see Border#isOpaque() */ public boolean isOpaque() { return true; } /** * @see Border#paint(IFigure, Graphics, Insets) */ public void paint(IFigure figure, Graphics g, Insets insets) { Rectangle rect = getPaintRectangle(figure, insets); FigureUtilities.paintEtchedBorder(g, rect); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/SimpleLoweredBorder.java000066400000000000000000000030421166301720600302430ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.graphics.Color; /** * Provides a lowered border. */ public final class SimpleLoweredBorder extends SchemeBorder { private static final Scheme DOUBLE = new Scheme( new Color[] { ColorConstants.buttonDarkest, ColorConstants.buttonDarker }, new Color[] { ColorConstants.buttonLightest, ColorConstants.button }); /** * Constructs a SimpleLoweredBorder with the predefined button-pressed * Scheme set as default. * * @since 2.0 */ public SimpleLoweredBorder() { super(SCHEMES.BUTTON_PRESSED); } /** * Constructs a SimpleLoweredBorder with the width of all sides provided as * input. If width == 2, this SimpleLoweredBorder will use the local DOUBLE * Scheme, otherwise it will use the * {@link SchemeBorder.SCHEMES#BUTTON_PRESSED} Scheme. * * @param width * the width of all the sides of the border * @since 2.0 */ public SimpleLoweredBorder(int width) { super(width == 2 ? DOUBLE : SCHEMES.BUTTON_PRESSED); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/SimpleRaisedBorder.java000066400000000000000000000030551166301720600300550ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.graphics.Color; /** * Provides a raised border. */ public class SimpleRaisedBorder extends SchemeBorder { private static final Scheme DOUBLE = new Scheme(new Color[] { ColorConstants.buttonLightest, ColorConstants.button }, new Color[] { ColorConstants.buttonDarkest, ColorConstants.buttonDarker }); /** * Constructs a SimpleRaisedBorder with the predefined * {@link SchemeBorder.SCHEMES#BUTTON_RAISED} Scheme set as default. * * @since 2.0 */ public SimpleRaisedBorder() { super(SCHEMES.BUTTON_RAISED); } /** * Constructs a SimpleRaisedBorder with the width of all sides provided as * input. If width == 2, this SimpleRaisedBorder will use the local DOUBLE * Scheme, otherwise it will use the * {@link SchemeBorder.SCHEMES#BUTTON_RAISED} Scheme. * * @param width * the width of all the sides of the border * @since 2.0 */ public SimpleRaisedBorder(int width) { super(width == 2 ? DOUBLE : SCHEMES.BUTTON_RAISED); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/StackLayout.java000066400000000000000000000060771166301720600266100ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.List; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Rectangle; /** * Figures using the StackLayout as their layout manager have their children * placed on top of one another. Order of placement is determined by the order * in which the children were added, first child added placed on the bottom. */ public class StackLayout extends AbstractHintLayout { /** * Returns the minimum size required by the input container. This is the * size of the largest child of the container, as all other children fit * into this size. * * @see AbstractHintLayout#calculateMinimumSize(IFigure, int, int) */ protected Dimension calculateMinimumSize(IFigure figure, int wHint, int hHint) { if (wHint > -1) wHint = Math.max(0, wHint - figure.getInsets().getWidth()); if (hHint > -1) hHint = Math.max(0, hHint - figure.getInsets().getHeight()); Dimension d = new Dimension(); List children = figure.getChildren(); IFigure child; for (int i = 0; i < children.size(); i++) { child = (IFigure) children.get(i); if (!isObservingVisibility() || child.isVisible()) d.union(child.getMinimumSize(wHint, hHint)); } d.expand(figure.getInsets().getWidth(), figure.getInsets().getHeight()); d.union(getBorderPreferredSize(figure)); return d; } /** * Calculates and returns the preferred size of the given figure. This is * the union of the preferred sizes of the widest and the tallest of all its * children. * * @see AbstractLayout#calculatePreferredSize(IFigure, int, int) */ protected Dimension calculatePreferredSize(IFigure figure, int wHint, int hHint) { if (wHint > -1) wHint = Math.max(0, wHint - figure.getInsets().getWidth()); if (hHint > -1) hHint = Math.max(0, hHint - figure.getInsets().getHeight()); Dimension d = new Dimension(); List children = figure.getChildren(); IFigure child; for (int i = 0; i < children.size(); i++) { child = (IFigure) children.get(i); if (!isObservingVisibility() || child.isVisible()) d.union(child.getPreferredSize(wHint, hHint)); } d.expand(figure.getInsets().getWidth(), figure.getInsets().getHeight()); d.union(getBorderPreferredSize(figure)); return d; } /** * @see org.eclipse.draw2d.LayoutManager#layout(IFigure) */ public void layout(IFigure figure) { Rectangle r = figure.getClientArea(); List children = figure.getChildren(); IFigure child; for (int i = 0; i < children.size(); i++) { child = (IFigure) children.get(i); child.setBounds(r); } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/SubordinateUpdateManager.java000066400000000000000000000043211166301720600312500ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Rectangle; /** * @deprecated this class is not used */ public abstract class SubordinateUpdateManager extends UpdateManager { /** * A root figure. */ protected IFigure root; /** * A graphics source */ protected GraphicsSource graphicsSource; /** * @see UpdateManager#addDirtyRegion(IFigure, int, int, int, int) */ public void addDirtyRegion(IFigure f, int x, int y, int w, int h) { if (getSuperior() == null) return; getSuperior().addDirtyRegion(f, x, y, w, h); } /** * @see UpdateManager#addInvalidFigure(IFigure) */ public void addInvalidFigure(IFigure f) { UpdateManager um = getSuperior(); if (um == null) return; um.addInvalidFigure(f); } /** * Returns the host figure. * * @return the host figure */ protected abstract IFigure getHost(); /** * Returns the superior update manager. * * @return the superior */ protected UpdateManager getSuperior() { if (getHost().getParent() == null) return null; return getHost().getParent().getUpdateManager(); } /** * @see UpdateManager#performUpdate() */ public void performUpdate() { UpdateManager um = getSuperior(); if (um == null) return; um.performUpdate(); } /** * @see UpdateManager#performUpdate(Rectangle) */ public void performUpdate(Rectangle rect) { UpdateManager um = getSuperior(); if (um == null) return; um.performUpdate(rect); } /** * @see UpdateManager#setRoot(IFigure) */ public void setRoot(IFigure f) { root = f; } /** * @see UpdateManager#setGraphicsSource(GraphicsSource) */ public void setGraphicsSource(GraphicsSource gs) { graphicsSource = gs; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/TextUtilities.java000066400000000000000000000063451166301720600271630ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2007, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontMetrics; import org.eclipse.draw2d.geometry.Dimension; /** * Provides miscellaneous text operations. Clients may subclass this class if * necessary. * * @author crevells * @since 3.4 */ public class TextUtilities { /** * a singleton default instance */ public static TextUtilities INSTANCE = new TextUtilities(); /** * Returns the Dimensions of s in Font f. * * @param s * the string * @param f * the font * @return the dimensions of the given string */ public Dimension getStringExtents(String s, Font f) { return FigureUtilities.getStringExtents(s, f); } /** * Returns the Dimensions of the given text, converting newlines and tabs * appropriately. * * @param s * the text * @param f * the font * @return the dimensions of the given text */ public Dimension getTextExtents(String s, Font f) { return FigureUtilities.getTextExtents(s, f); } /** * Gets the font's ascent. * * @param font * @return the font's ascent */ public int getAscent(Font font) { FontMetrics fm = FigureUtilities.getFontMetrics(font); return fm.getHeight() - fm.getDescent(); } /** * Gets the font's descent. * * @param font * @return the font's descent */ public int getDescent(Font font) { return FigureUtilities.getFontMetrics(font).getDescent(); } /** * Returns the largest substring of s in Font f that can be * confined to the number of pixels in availableWidth. * * @param s * the original string * @param f * the font * @param availableWidth * the available width * @return the largest substring that fits in the given width */ public int getLargestSubstringConfinedTo(String s, Font f, int availableWidth) { FontMetrics metrics = FigureUtilities.getFontMetrics(f); int min, max; float avg = metrics.getAverageCharWidth(); min = 0; max = s.length() + 1; // The size of the current guess int guess = 0, guessSize = 0; while ((max - min) > 1) { // Pick a new guess size // New guess is the last guess plus the missing width in pixels // divided by the average character size in pixels guess = guess + (int) ((availableWidth - guessSize) / avg); if (guess >= max) guess = max - 1; if (guess <= min) guess = min + 1; // Measure the current guess guessSize = getTextExtents(s.substring(0, guess), f).width; if (guessSize < availableWidth) // We did not use the available width min = guess; else // We exceeded the available width max = guess; } return min; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/TitleBarBorder.java000066400000000000000000000123041166301720600271770ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation * Michael Houston (schmeeky@gmail.com) - Bugzilla 259088 *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.graphics.Color; import org.eclipse.draw2d.geometry.Insets; import org.eclipse.draw2d.geometry.Rectangle; /** * Border provides a title bar on the Figure for which this is the border of. * Generally used in conjunction with other borders to create window-like * effects. Also provides for alignment of the text in the bar. * * @see FrameBorder */ public class TitleBarBorder extends AbstractLabeledBorder { private static Color defaultBackgroundColor = ColorConstants.menuBackgroundSelected; private static Color defaultForegroundColor = ColorConstants.menuForegroundSelected; private int textAlignment = PositionConstants.LEFT; private Insets padding = new Insets(1, 3, 2, 2); private Color fillColor = defaultBackgroundColor; /** * Constructs a TitleBarBorder with its label set to the name of this class. * * @since 2.0 */ public TitleBarBorder() { setTextColor(defaultForegroundColor); } /** * Constructs a TitleBarBorder with its label set to the passed String. * * @param s * text of the label * @since 2.0 */ public TitleBarBorder(String s) { this(); setLabel(s); } /** * Calculates and returns the Insets for this border. * * @param figure * the figure on which Insets calculations are based * @return the calculated Insets * @since 2.0 */ protected Insets calculateInsets(IFigure figure) { return new Insets(getTextExtents(figure).height + padding.getHeight(), 0, 0, 0); } /** * Returns the background Color of this TitleBarBorder. * * @return the background color * @since 2.0 */ protected Color getBackgroundColor() { return fillColor; } /** * Returns this TitleBarBorder's padding. Padding provides spacing along the * sides of the TitleBarBorder. The default value is no padding along all * sides. * * @return the Insets representing the space along the sides of the * TitleBarBorder * @since 2.0 */ protected Insets getPadding() { return padding; } /** * Returns the alignment of the text in the title bar. Possible values are * {@link PositionConstants#LEFT}, {@link PositionConstants#CENTER} and * {@link PositionConstants#RIGHT}. * * @return the text alignment * @since 2.0 */ public int getTextAlignment() { return textAlignment; } /** * Returns true thereby filling up all the contents within its * boundaries, eleminating the need by the figure to clip the boundaries and * do the same. * * @see Border#isOpaque() */ public boolean isOpaque() { return true; } /** * @see Border#paint(IFigure, Graphics, Insets) */ public void paint(IFigure figure, Graphics g, Insets insets) { tempRect.setBounds(getPaintRectangle(figure, insets)); Rectangle rec = tempRect; rec.height = Math.min(rec.height, getTextExtents(figure).height + padding.getHeight()); g.clipRect(rec); g.setBackgroundColor(fillColor); g.fillRectangle(rec); int x = rec.x + padding.left; int y = rec.y + padding.top; int textWidth = getTextExtents(figure).width; int freeSpace = rec.width - padding.getWidth() - textWidth; if (getTextAlignment() == PositionConstants.CENTER) freeSpace /= 2; if (getTextAlignment() != PositionConstants.LEFT) x += freeSpace; g.setFont(getFont(figure)); g.setForegroundColor(getTextColor()); g.drawString(getLabel(), x, y); } /** * Sets the background color of the area within the boundaries of this * border. This is required as this border takes responsibility for filling * up the region, as TitleBarBorders are always opaque. * * @param color * the background color * @since 2.0 */ public void setBackgroundColor(Color color) { fillColor = color; } /** * Sets the padding space to be applied on all sides of the border. The * default value is no padding on all sides. * * @param all * the value of the padding on all sides * @since 2.0 */ public void setPadding(int all) { padding = new Insets(all); invalidate(); } /** * Sets the padding space of this TitleBarBorder to the passed value. The * default value is no padding on all sides. * * @param pad * the padding * @since 2.0 */ public void setPadding(Insets pad) { padding = pad; invalidate(); } /** * Sets the alignment of the text in the title bar. Possible values are * {@link PositionConstants#LEFT}, {@link PositionConstants#CENTER} and * {@link PositionConstants#RIGHT}. * * @param align * the new text alignment * @since 2.0 */ public void setTextAlignment(int align) { textAlignment = align; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/Toggle.java000066400000000000000000000032731166301720600255610ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.graphics.Image; /** * Basic Rule for Toggle: Whoever creates the toggle is reponsible for response * changes for it (selection, rollover, etc). Only * {@link org.eclipse.draw2d.CheckBox} does its own listening. */ public class Toggle extends Clickable { /** * Constructs a Toggle with no text or icon. * * @since 2.0 */ public Toggle() { super(); setStyle(STYLE_TOGGLE); } /** * Constructs a Toggle with passed text and icon * * @param text * the text * @param icon * the icon * @since 2.0 */ public Toggle(String text, Image icon) { super(new Label(text, icon), STYLE_TOGGLE); } /** * Constructs a Toggle with passed IFigure as its contents. * * @param contents * the contents * @since 2.0 */ public Toggle(IFigure contents) { super(contents, STYLE_TOGGLE); } /** * Constructs a Toggle with the passed figure as its contents and the given * style. * * @param contents * the contents * @param style * the style */ public Toggle(IFigure contents, int style) { super(contents, style); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ToggleButton.java000066400000000000000000000053371166301720600267600ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.swt.graphics.Image; import org.eclipse.draw2d.geometry.Insets; import org.eclipse.draw2d.geometry.Rectangle; /** * A Toggle that appears like a 3-dimensional button. */ public class ToggleButton extends Toggle { /** This ToggleButton's Label **/ protected Label label = null; /** * Constructs a new ToggleButton with no initial contents. */ public ToggleButton() { setStyle(STYLE_BUTTON | STYLE_TOGGLE); } /** * Constructs a ToggleButton with the passed IFigure as its contents. * * @param contents * the contents of the toggle button * @since 2.0 */ public ToggleButton(IFigure contents) { super(contents, STYLE_BUTTON | STYLE_TOGGLE); } /** * Constructs a ToggleButton with the passed string as its text. * * @param text * the text to be displayed on the button * @since 2.0 */ public ToggleButton(String text) { this(text, null); } /** * Constructs a ToggleButton with a Label containing the passed text and * icon. * * @param text * the text * @param normalIcon * the icon * @since 2.0 */ public ToggleButton(String text, Image normalIcon) { super(new Label(text, normalIcon), STYLE_BUTTON | STYLE_TOGGLE); } /** * @see org.eclipse.draw2d.Figure#paintFigure(Graphics) */ protected void paintFigure(Graphics graphics) { if (isSelected() && isOpaque()) { fillCheckeredRectangle(graphics); } else { super.paintFigure(graphics); } } /** * Draws a checkered pattern to emulate a toggle button that is in the * selected state. * * @param graphics * The Graphics object used to paint */ protected void fillCheckeredRectangle(Graphics graphics) { graphics.setBackgroundColor(ColorConstants.button); graphics.setForegroundColor(ColorConstants.buttonLightest); Rectangle rect = getClientArea(Rectangle.SINGLETON).crop( new Insets(1, 1, 0, 0)); graphics.fillRectangle(rect.x, rect.y, rect.width, rect.height); graphics.clipRect(rect); graphics.translate(rect.x, rect.y); int n = rect.width + rect.height; for (int i = 1; i < n; i += 2) { graphics.drawLine(0, i, i, 0); } graphics.restoreState(); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ToggleModel.java000066400000000000000000000017121166301720600265360ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; /** * ButtonModel that supports toggle buttons. */ public class ToggleModel extends ButtonModel { /** * Notifies any ActionListeners on this ButtonModel that an action has been * performed. Sets this ButtonModel's selection to be the opposite of what * it was. * * @since 2.0 */ public void fireActionPerformed() { setSelected(!isSelected()); super.fireActionPerformed(); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ToolTipHelper.java000066400000000000000000000133151166301720600270700ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.Timer; import java.util.TimerTask; import org.eclipse.swt.SWT; import org.eclipse.swt.events.MouseTrackAdapter; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Display; import org.eclipse.draw2d.geometry.Dimension; /** * This class is used by SWTEventDispatcher as support to display Figure * tooltips on a mouse hover event. Tooltips are drawn directly below the cursor * unless the display does not allow, in which case the tooltip will be drawn * directly above the cursor. Tooltips will be displayed with a LineBorder. The * background of the tooltips will be the standard SWT tooltipBackground color * unless the Figure's tooltip has set its own background. */ public class ToolTipHelper extends PopUpHelper { private Timer timer; private IFigure currentTipSource; /** * Constructs a ToolTipHelper to be associated with Control c. * * @param c * the control * @since 2.0 */ public ToolTipHelper(org.eclipse.swt.widgets.Control c) { super(c, SWT.TOOL | SWT.ON_TOP); getShell().setBackground(ColorConstants.tooltipBackground); getShell().setForeground(ColorConstants.tooltipForeground); } /* * Calculates the location where the tooltip will be painted. Returns this * as a Point. Tooltip will be painted directly below the cursor if * possible, otherwise it will be painted directly above cursor. */ private Point computeWindowLocation(IFigure tip, int eventX, int eventY) { org.eclipse.swt.graphics.Rectangle clientArea = control.getDisplay() .getClientArea(); Point preferredLocation = new Point(eventX, eventY + 26); Dimension tipSize = getLightweightSystem().getRootFigure() .getPreferredSize().getExpanded(getShellTrimSize()); // Adjust location if tip is going to fall outside display if (preferredLocation.y + tipSize.height > clientArea.height) preferredLocation.y = eventY - tipSize.height; if (preferredLocation.x + tipSize.width > clientArea.width) preferredLocation.x -= (preferredLocation.x + tipSize.width) - clientArea.width; return preferredLocation; } /** * Sets the LightWeightSystem's contents to the passed tooltip, and displays * the tip. The tip will be displayed only if the tip source is different * than the previously viewed tip source. (i.e. The cursor has moved off of * the previous tooltip source figure.) *

    * The tooltip will be painted directly below the cursor if possible, * otherwise it will be painted directly above cursor. * * @param hoverSource * the figure over which the hover event was fired * @param tip * the tooltip to be displayed * @param eventX * the x coordinate of the hover event * @param eventY * the y coordinate of the hover event * @since 2.0 */ public void displayToolTipNear(IFigure hoverSource, IFigure tip, int eventX, int eventY) { if (tip != null && hoverSource != currentTipSource) { getLightweightSystem().setContents(tip); Point displayPoint = computeWindowLocation(tip, eventX, eventY); Dimension shellSize = getLightweightSystem().getRootFigure() .getPreferredSize().getExpanded(getShellTrimSize()); setShellBounds(displayPoint.x, displayPoint.y, shellSize.width, shellSize.height); show(); currentTipSource = hoverSource; timer = new Timer(true); timer.schedule(new TimerTask() { public void run() { Display.getDefault().asyncExec(new Runnable() { public void run() { hide(); timer.cancel(); } }); } }, 5000); } } /** * Disposes of the tooltip's shell and kills the timer. * * @see PopUpHelper#dispose() */ public void dispose() { if (isShowing()) { timer.cancel(); hide(); } getShell().dispose(); } /** * @see PopUpHelper#hookShellListeners() */ protected void hookShellListeners() { // Close the tooltip window if the mouse enters the tooltip getShell().addMouseTrackListener(new MouseTrackAdapter() { public void mouseEnter(org.eclipse.swt.events.MouseEvent e) { hide(); currentTipSource = null; if (timer != null) { timer.cancel(); } } }); } /** * Displays the hover source's tooltip if a tooltip of another source is * currently being displayed. * * @param figureUnderMouse * the figure over which the cursor was when called * @param tip * the tooltip to be displayed * @param eventX * the x coordinate of the cursor * @param eventY * the y coordinate of the cursor * @since 2.0 */ public void updateToolTip(IFigure figureUnderMouse, IFigure tip, int eventX, int eventY) { /* * If the cursor is not on any Figures, it has been moved off of the * control. Hide the tool tip. */ if (figureUnderMouse == null) { if (isShowing()) { hide(); timer.cancel(); } } // Makes tooltip appear without a hover event if a tip is currently // being displayed if (isShowing() && figureUnderMouse != currentTipSource) { hide(); timer.cancel(); displayToolTipNear(figureUnderMouse, tip, eventX, eventY); } else if (!isShowing() && figureUnderMouse != currentTipSource) currentTipSource = null; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ToolbarLayout.java000066400000000000000000000326221166301720600271400ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.List; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Insets; import org.eclipse.draw2d.geometry.Rectangle; /** * Arranges figures in a single row or column. Orientation can be set to produce * either a row or column layout. This layout tries to fit all children within * the parent's client area. To do this, it compresses the children by some * amount, but will not compress them smaller than their minimum size. If a * child's preferred size is smaller than the row's or column's minor dimension, * the layout can be configured to stretch the child. */ public class ToolbarLayout extends OrderedLayout { /** * Constant for horizontal alignment * * @deprecated Unused. */ public static final boolean HORIZONTAL = true; /** * Constant for vertical alignment * * @deprecated Unused. * */ public static final boolean VERTICAL = false; /** * Sets whether children should "stretch" with their container * * @deprecated Use {@link OrderedLayout#setStretchMinorAxis(boolean)} and * {@link OrderedLayout#isStretchMinorAxis()} instead. * */ protected boolean matchWidth; /** * Space in pixels between Figures * * @deprecated Use {@link #getSpacing()} and {@link #setSpacing(int)} * instead. */ protected int spacing; /** * Constructs a vertically oriented ToolbarLayout with child spacing of 0 * pixels, {@link #setStretchMinorAxis(boolean)} true, and * {@link #ALIGN_TOPLEFT} minor alignment. * * @since 2.0 */ public ToolbarLayout() { setStretchMinorAxis(true); setSpacing(0); } /** * Constructs a ToolbarLayout with a specified orientation. Default values * are: child spacing 0 pixels, {@link #setStretchMinorAxis(boolean)} * false, and {@link #ALIGN_TOPLEFT} alignment. * * @param isHorizontal * whether the children are oriented horizontally * @since 2.0 */ public ToolbarLayout(boolean isHorizontal) { setHorizontal(isHorizontal); setStretchMinorAxis(false); setSpacing(0); } private Dimension calculateChildrenSize(List children, int wHint, int hHint, boolean preferred) { Dimension childSize; IFigure child; int height = 0, width = 0; for (int i = 0; i < children.size(); i++) { child = (IFigure) children.get(i); childSize = transposer.t(preferred ? getChildPreferredSize(child, wHint, hHint) : getChildMinimumSize(child, wHint, hHint)); height += childSize.height; width = Math.max(width, childSize.width); } return new Dimension(width, height); } /** * Calculates the minimum size of the container based on the given hints. If * this is a vertically-oriented Toolbar Layout, then only the widthHint is * respected (which means that the children can be as tall as they desire). * In this case, the minimum width is that of the widest child, and the * minimum height is the sum of the minimum heights of all children, plus * the spacing between them. The border and insets of the container figure * are also accounted for. * * @param container * the figure whose minimum size has to be calculated * @param wHint * the width hint (the desired width of the container) * @param hHint * the height hint (the desired height of the container) * @return the minimum size of the container * @see #getMinimumSize(IFigure, int, int) * @since 2.1 */ protected Dimension calculateMinimumSize(IFigure container, int wHint, int hHint) { Insets insets = container.getInsets(); if (isHorizontal()) { wHint = -1; if (hHint >= 0) hHint = Math.max(0, hHint - insets.getHeight()); } else { hHint = -1; if (wHint >= 0) wHint = Math.max(0, wHint - insets.getWidth()); } List children = container.getChildren(); Dimension minSize = calculateChildrenSize(children, wHint, hHint, false); // Do a second pass, if necessary if (wHint >= 0 && minSize.width > wHint) { minSize = calculateChildrenSize(children, minSize.width, hHint, false); } else if (hHint >= 0 && minSize.width > hHint) { minSize = calculateChildrenSize(children, wHint, minSize.width, false); } minSize.height += Math.max(0, children.size() - 1) * spacing; return transposer.t(minSize) .expand(insets.getWidth(), insets.getHeight()) .union(getBorderPreferredSize(container)); } /** * Calculates the preferred size of the container based on the given hints. * If this is a vertically-oriented Toolbar Layout, then only the widthHint * is respected (which means that the children can be as tall as they * desire). In this case, the preferred width is that of the widest child, * and the preferred height is the sum of the preferred heights of all * children, plus the spacing between them. The border and insets of the * container figure are also accounted for. * * @param container * the figure whose preferred size has to be calculated * @param wHint * the width hint (the desired width of the container) * @param hHint * the height hint (the desired height of the container) * @return the preferred size of the container * @see #getPreferredSize(IFigure, int, int) * @since 2.0 */ protected Dimension calculatePreferredSize(IFigure container, int wHint, int hHint) { Insets insets = container.getInsets(); if (isHorizontal()) { wHint = -1; if (hHint >= 0) hHint = Math.max(0, hHint - insets.getHeight()); } else { hHint = -1; if (wHint >= 0) wHint = Math.max(0, wHint - insets.getWidth()); } List children = container.getChildren(); Dimension prefSize = calculateChildrenSize(children, wHint, hHint, true); // Do a second pass, if necessary if (wHint >= 0 && prefSize.width > wHint) { prefSize = calculateChildrenSize(children, prefSize.width, hHint, true); } else if (hHint >= 0 && prefSize.width > hHint) { prefSize = calculateChildrenSize(children, wHint, prefSize.width, true); } prefSize.height += Math.max(0, children.size() - 1) * spacing; return transposer.t(prefSize) .expand(insets.getWidth(), insets.getHeight()) .union(getBorderPreferredSize(container)); } /** * @param child * the figure whose minimum size is to be determined * @param wHint * the width hint * @param hHint * the height hint * @return the given figure's minimum size * @since 3.3 */ protected Dimension getChildMinimumSize(IFigure child, int wHint, int hHint) { return child.getMinimumSize(wHint, hHint); } /** * @param child * the figure whose preferred size is to be determined * @param wHint * the width hint * @param hHint * the height hint * @return given figure's preferred size * @since 3.3 */ protected Dimension getChildPreferredSize(IFigure child, int wHint, int hHint) { return child.getPreferredSize(wHint, hHint); } /** * Returns {@link PositionConstants#VERTICAL} by default. * * @see org.eclipse.draw2d.OrderedLayout#getDefaultOrientation() */ protected int getDefaultOrientation() { return PositionConstants.VERTICAL; } /** * @return the spacing between children */ public int getSpacing() { return spacing; } /** * @see org.eclipse.draw2d.AbstractHintLayout#isSensitiveHorizontally(IFigure) */ protected boolean isSensitiveHorizontally(IFigure parent) { return !isHorizontal(); } /** * @see org.eclipse.draw2d.AbstractHintLayout#isSensitiveVertically(IFigure) */ protected boolean isSensitiveVertically(IFigure parent) { return isHorizontal(); } /** * Returns true if stretch minor axis has been enabled. The * default value is false. * * @return true if stretch minor axis is enabled * @deprecated Use {@link #isStretchMinorAxis()} instead. */ public boolean getStretchMinorAxis() { return isStretchMinorAxis(); } /** * Overwritten to guarantee backwards compatibility with {@link #matchWidth} * field. * * @see org.eclipse.draw2d.OrderedLayout#isStretchMinorAxis() */ public boolean isStretchMinorAxis() { return matchWidth; } /** * @see org.eclipse.draw2d.LayoutManager#layout(IFigure) */ public void layout(IFigure parent) { List children = parent.getChildren(); int numChildren = children.size(); Rectangle clientArea = transposer.t(parent.getClientArea()); int x = clientArea.x; int y = clientArea.y; int availableHeight = clientArea.height; Dimension prefSizes[] = new Dimension[numChildren]; Dimension minSizes[] = new Dimension[numChildren]; // Calculate the width and height hints. If it's a vertical // ToolBarLayout, // then ignore the height hint (set it to -1); otherwise, ignore the // width hint. These hints will be passed to the children of the parent // figure when getting their preferred size. int wHint = -1; int hHint = -1; if (isHorizontal()) { hHint = parent.getClientArea(Rectangle.SINGLETON).height; } else { wHint = parent.getClientArea(Rectangle.SINGLETON).width; } /* * Calculate sum of preferred heights of all children(totalHeight). * Calculate sum of minimum heights of all children(minHeight). Cache * Preferred Sizes and Minimum Sizes of all children. * * totalHeight is the sum of the preferred heights of all children * totalMinHeight is the sum of the minimum heights of all children * prefMinSumHeight is the sum of the difference between all children's * preferred heights and minimum heights. (This is used as a ratio to * calculate how much each child will shrink). */ IFigure child; int totalHeight = 0; int totalMinHeight = 0; int prefMinSumHeight = 0; for (int i = 0; i < numChildren; i++) { child = (IFigure) children.get(i); prefSizes[i] = transposer.t(getChildPreferredSize(child, wHint, hHint)); minSizes[i] = transposer .t(getChildMinimumSize(child, wHint, hHint)); totalHeight += prefSizes[i].height; totalMinHeight += minSizes[i].height; } totalHeight += (numChildren - 1) * spacing; totalMinHeight += (numChildren - 1) * spacing; prefMinSumHeight = totalHeight - totalMinHeight; /* * The total amount that the children must be shrunk is the sum of the * preferred Heights of the children minus Max(the available area and * the sum of the minimum heights of the children). * * amntShrinkHeight is the combined amount that the children must shrink * amntShrinkCurrentHeight is the amount each child will shrink * respectively */ int amntShrinkHeight = totalHeight - Math.max(availableHeight, totalMinHeight); if (amntShrinkHeight < 0) { amntShrinkHeight = 0; } for (int i = 0; i < numChildren; i++) { int amntShrinkCurrentHeight = 0; int prefHeight = prefSizes[i].height; int minHeight = minSizes[i].height; int prefWidth = prefSizes[i].width; int minWidth = minSizes[i].width; Rectangle newBounds = new Rectangle(x, y, prefWidth, prefHeight); child = (IFigure) children.get(i); if (prefMinSumHeight != 0) amntShrinkCurrentHeight = (prefHeight - minHeight) * amntShrinkHeight / (prefMinSumHeight); int width = Math.min(prefWidth, transposer.t(child.getMaximumSize()).width); if (isStretchMinorAxis()) width = transposer.t(child.getMaximumSize()).width; width = Math.max(minWidth, Math.min(clientArea.width, width)); newBounds.width = width; int adjust = clientArea.width - width; switch (getMinorAlignment()) { case ALIGN_TOPLEFT: adjust = 0; break; case ALIGN_CENTER: adjust /= 2; break; case ALIGN_BOTTOMRIGHT: break; } newBounds.x += adjust; newBounds.height -= amntShrinkCurrentHeight; child.setBounds(transposer.t(newBounds)); amntShrinkHeight -= amntShrinkCurrentHeight; prefMinSumHeight -= (prefHeight - minHeight); y += newBounds.height + spacing; } } /** * Sets children's width (if vertically oriented) or height (if horizontally * oriented) to stretch with their container. * * @deprecated use {@link #setStretchMinorAxis(boolean)} * @param match * whether to stretch children * @since 2.0 */ public void setMatchWidth(boolean match) { matchWidth = match; } /** * Sets the amount of space between children. * * @param space * the amount of space between children * @since 2.0 */ public void setSpacing(int space) { spacing = space; } /** * Overwritten to guarantee backwards compatibility with {@link #matchWidth} * field. * * @see org.eclipse.draw2d.OrderedLayout#setStretchMinorAxis(boolean) */ public void setStretchMinorAxis(boolean value) { matchWidth = value; } /** * Sets the orientation of the layout * * @param flag * whether the orientation should be vertical * @since 2.0 * @deprecated Use {@link #setHorizontal(boolean)} with argument * false instead. */ public void setVertical(boolean flag) { setHorizontal(!flag); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/TreeSearch.java000066400000000000000000000023511166301720600263610ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; /** * A helper used in depth-first searches of a figure subgraph. * * @author hudsonr * @since 2.1 */ public interface TreeSearch { /** * Returns true if the given figure is accepted by the search. * * @param figure * the current figure in the traversal * @return true if the figure is accepted */ boolean accept(IFigure figure); /** * Returns true if the figure and all of its contained figures * should be pruned from the search. * * @param figure * the current figure in the traversal * @return true if the subgraph should be pruned */ boolean prune(IFigure figure); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/Triangle.java000066400000000000000000000071751166301720600261120ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.PointList; import org.eclipse.draw2d.geometry.Rectangle; /** * A triangular graphical figure. */ public final class Triangle extends Shape implements Orientable { /** * The direction this triangle will face. Possible values are * {@link PositionConstants#NORTH}, {@link PositionConstants#SOUTH}, * {@link PositionConstants#EAST} and {@link PositionConstants#WEST}. */ protected int direction = NORTH; /** * The orientation of this triangle. Possible values are * {@link Orientable#VERTICAL} and {@link Orientable#HORIZONTAL}. */ protected int orientation = VERTICAL; /** The points of the triangle. */ protected PointList triangle = new PointList(3); /** * @see Shape#fillShape(Graphics) */ protected void fillShape(Graphics g) { g.fillPolygon(triangle); } /** * @see Shape#outlineShape(Graphics) */ protected void outlineShape(Graphics g) { g.drawPolygon(triangle); } /** * @see Figure#primTranslate(int, int) */ public void primTranslate(int dx, int dy) { super.primTranslate(dx, dy); triangle.translate(dx, dy); } /** * @see Orientable#setDirection(int) */ public void setDirection(int value) { if ((value & (NORTH | SOUTH)) != 0) orientation = VERTICAL; else orientation = HORIZONTAL; direction = value; revalidate(); repaint(); } /** * @see Orientable#setOrientation(int) */ public void setOrientation(int value) { if (orientation == VERTICAL && value == HORIZONTAL) { if (direction == NORTH) setDirection(WEST); else setDirection(EAST); } if (orientation == HORIZONTAL && value == VERTICAL) { if (direction == WEST) setDirection(NORTH); else setDirection(SOUTH); } } /** * @see IFigure#validate() */ public void validate() { super.validate(); Rectangle r = new Rectangle(); r.setBounds(getBounds()); r.crop(getInsets()); r.resize(-1, -1); int size; switch (direction & (NORTH | SOUTH)) { case 0: // East or west. size = Math.min(r.height / 2, r.width); r.x += (r.width - size) / 2; break; default: // North or south size = Math.min(r.height, r.width / 2); r.y += (r.height - size) / 2; break; } size = Math.max(size, 1); // Size cannot be negative Point head, p2, p3; switch (direction) { case NORTH: head = new Point(r.x + r.width / 2, r.y); p2 = new Point(head.x - size, head.y + size); p3 = new Point(head.x + size, head.y + size); break; case SOUTH: head = new Point(r.x + r.width / 2, r.y + size); p2 = new Point(head.x - size, head.y - size); p3 = new Point(head.x + size, head.y - size); break; case WEST: head = new Point(r.x, r.y + r.height / 2); p2 = new Point(head.x + size, head.y - size); p3 = new Point(head.x + size, head.y + size); break; default: head = new Point(r.x + size, r.y + r.height / 2); p2 = new Point(head.x - size, head.y - size); p3 = new Point(head.x - size, head.y + size); } triangle.removeAllPoints(); triangle.addPoint(head); triangle.addPoint(p2); triangle.addPoint(p3); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/UpdateListener.java000066400000000000000000000027741166301720600272750ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.Map; import org.eclipse.draw2d.geometry.Rectangle; /** * An interface used to notify listeners that the listened to object is * updating. */ public interface UpdateListener { /** * Notifies the listener that the listened to object is painting. The damage * rectangle may be null or empty. This indicates the dirty regions were * clipped or not visible. But for objects such as the * {@link org.eclipse.draw2d.parts.Thumbnail}, notification still needs to * occur. The map of dirty regions is passed to allow the listener to * determine if it needs to update, for instance when a particular figure is * painting. * * @param damage * The area being painted * @param dirtyRegions * a Map of figures to their dirty regions */ void notifyPainting(Rectangle damage, Map dirtyRegions); /** * Notifies the listener that the listened to object is validating. */ void notifyValidating(); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/UpdateManager.java000066400000000000000000000150611166301720600270530ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.Map; import org.eclipse.swt.graphics.GC; import org.eclipse.draw2d.geometry.Rectangle; /** * Update managers handle the job of laying out and repainting figures. A * desirable implementation is to batches work to be done and collapses any * redundant work. For example, clients may be making multiple changes to * figures, which require laying out the same container or repainting the same * region. *

    * The update manager receives requests to validate certain figures, and repaint * certain areas of figures. An update manager could process every request * synchronously, or it could batch these requests and process them * asynchronously. *

    * The update process occurs in two phases. The first phase is laying out * invalid figures. This phase comes first because it usually introduces * additional damage regions. In some cases, while validating figures, new * invalid figures may be appended to the update manager. Of course, damage * regions will be reported too as figures are layed out. *

    * The second phase is to repaint all damaged areas. The update manager will * typically batch, clip, and union, all rectangles and perform a single paint * of the overall damaged area. * */ public abstract class UpdateManager { private UpdateListener listeners[] = new UpdateListener[0]; private boolean disposed; /** * Adds the dirty region defined by the coordinates on the IFigure * figure. The update manager should repaint the dirty region in a * timely fashion. * * @param figure * the dirty figure * @param x * the x coordinate of the dirty region * @param y * the y coordinate of the dirty region * @param w * the width of the dirty region * @param h * the height of the dirty region */ public abstract void addDirtyRegion(IFigure figure, int x, int y, int w, int h); /** * @see #addDirtyRegion(IFigure, int, int, int, int) */ public void addDirtyRegion(IFigure figure, Rectangle rect) { addDirtyRegion(figure, rect.x, rect.y, rect.width, rect.height); } /** * Causes an update to occur at some time, and the given runnable to be * executed following the update. * * @since 3.1 * @param run * the runnable */ public void runWithUpdate(Runnable run) { } /** * The receiver should call validate() on the IFigure figure in a * timely fashion. * * @param figure * the invalid figure */ public abstract void addInvalidFigure(IFigure figure); /** * Adds the given listener to the list of listeners to be notified of * painting and validation. * * @param listener * the listener to add */ public void addUpdateListener(UpdateListener listener) { if (listener == null) throw new IllegalArgumentException(); if (listeners == null) { listeners = new UpdateListener[1]; listeners[0] = listener; } else { int oldSize = listeners.length; UpdateListener newListeners[] = new UpdateListener[oldSize + 1]; System.arraycopy(listeners, 0, newListeners, 0, oldSize); newListeners[oldSize] = listener; listeners = newListeners; } } /** * Called when the EditPartViewer is being disposed. */ public void dispose() { disposed = true; } /** * Notifies listeners that painting is about to occur, passing them the * damaged rectangle and the map of dirty regions. * * @param damage * the damaged rectangle * @param dirtyRegions * map of dirty regions to figures */ protected void firePainting(Rectangle damage, Map dirtyRegions) { UpdateListener localListeners[] = listeners; for (int i = 0; i < localListeners.length; i++) localListeners[i].notifyPainting(damage, dirtyRegions); } /** * Notifies listeners that validation is about to occur. */ protected void fireValidating() { UpdateListener localListeners[] = listeners; for (int i = 0; i < localListeners.length; i++) localListeners[i].notifyValidating(); } /** * @return whether this update manager has been disposed. */ protected boolean isDisposed() { return disposed; } /** * Forces an update to occur. Update managers will perform updates * automatically, but may do so asynchronously. Calling this method forces a * synchronous update. */ public abstract void performUpdate(); void paint(GC gc) { performUpdate(new Rectangle(gc.getClipping())); } /** * Performs an update on the given exposed rectangle. * * @param exposed * the exposed rectangle */ public abstract void performUpdate(Rectangle exposed); /** * Removes one occurrence of the given UpdateListener by identity. * * @param listener * the listener to remove */ public void removeUpdateListener(UpdateListener listener) { if (listener == null) throw new IllegalArgumentException(); for (int index = 0; index < listeners.length; index++) if (listeners[index] == listener) { int newSize = listeners.length - 1; UpdateListener newListeners[] = null; if (newSize != 0) { newListeners = new UpdateListener[newSize]; System.arraycopy(listeners, 0, newListeners, 0, index); System.arraycopy(listeners, index + 1, newListeners, index, newSize - index); } else { newListeners = new UpdateListener[0]; } listeners = newListeners; return; } } /** * Sets the GraphicsSource for this update manager. * * @param gs * the new GraphicsSource */ public abstract void setGraphicsSource(GraphicsSource gs); /** * Sets the root figure. * * @param figure * the new root figure */ public abstract void setRoot(IFigure figure); /** * Performs a partial update if supported (validation only). Fires * notification to listeners that validation has been performed. By default * this method calls {@link #performUpdate()}. Subclasses should override * this method to support validation without repainting. * * @since 3.2 */ public void performValidation() { performUpdate(); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/Viewport.java000066400000000000000000000235321166301720600261570ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.draw2d.geometry.Translatable; /** * A Viewport is a flexible window onto a {@link ScrollPane} and represents the * visible portion of the ScrollPane. */ public class Viewport extends Figure implements PropertyChangeListener { /** ID for the view location property */ public static final String PROPERTY_VIEW_LOCATION = "viewLocation"; //$NON-NLS-1$ private IFigure view; private boolean useTranslate = false; private boolean trackWidth = false; private boolean trackHeight = false; private boolean ignoreScroll = false; private RangeModel horiztonalRangeModel = null, verticalRangeModel = null; { setLayoutManager(new ViewportLayout()); setHorizontalRangeModel(new DefaultRangeModel()); setVerticalRangeModel(new DefaultRangeModel()); } /** * Constructs a new Viewport with the default values. */ public Viewport() { } /** * Constructs a new Viewport. If setting is true, the * viewport will use graphics translation to paint. * * @param setting * whether to use graphics translation */ public Viewport(boolean setting) { useTranslate = setting; } /** * @see IFigure#getClientArea(Rectangle) */ public Rectangle getClientArea(Rectangle rect) { super.getClientArea(rect); if (useGraphicsTranslate()) rect.translate(getViewLocation()); return rect; } /** * Returns the view, which is the contents of the {@link ScrollPane} * associated with this Viewport. * * @return the contents * @since 2.0 */ public IFigure getContents() { return view; } /** * Returns the RangeModel associated with the horizontal motion of this * Viewport * * @return the RangeModel * * @since 2.0 */ public RangeModel getHorizontalRangeModel() { return horiztonalRangeModel; } /** * Returns true if the Viewport resizes itself in the vertical * direction when the available height of its view is decreased, false * otherwise. This option is turned off by default, and can be activated by * calling {@link #setContentsTracksHeight(boolean)} and passing in * true. * * @return whether the contents tracks height * @since 2.0 */ public boolean getContentsTracksHeight() { return trackHeight; } /** * Returns true if the Viewport resizes itself in the * horizontal direction when the available width of its view is decreased, * false otherwise. This option is turned off by default, and can be * activated by calling {@link #setContentsTracksWidth(boolean)} and passing * in true. * * @return whether the contents tracks width * @since 2.0 */ public boolean getContentsTracksWidth() { return trackWidth; } /** * Returns the range model associated with the vertical motion of the * Viewport. * * @return the RangeModel * * @since 2.0 */ public RangeModel getVerticalRangeModel() { return verticalRangeModel; } /** * Returns the current location of this Viewport. * * @return the current location of this Viewport * * @since 2.0 */ public Point getViewLocation() { return new Point(getHorizontalRangeModel().getValue(), getVerticalRangeModel().getValue()); } private void localRevalidate() { invalidate(); if (getLayoutManager() != null) getLayoutManager().invalidate(); getUpdateManager().addInvalidFigure(this); } /** * @see Figure#paintClientArea(Graphics) */ protected void paintClientArea(Graphics g) { if (useGraphicsTranslate()) { Point p = getViewLocation(); try { g.translate(-p.x, -p.y); g.pushState(); super.paintClientArea(g); g.popState(); } finally { g.translate(p.x, p.y); } } else super.paintClientArea(g); } /** * @see org.eclipse.draw2d.Figure#isCoordinateSystem() */ public boolean isCoordinateSystem() { return useGraphicsTranslate() || super.isCoordinateSystem(); } /** * Listens for either of the {@link RangeModel RangeModels} to fire a * property change event and updates the view accordingly. * * @param event * the event */ public void propertyChange(PropertyChangeEvent event) { if (event.getSource() instanceof RangeModel) { if (RangeModel.PROPERTY_VALUE.equals(event.getPropertyName())) { if (!ignoreScroll) { localRevalidate(); if (useGraphicsTranslate()) { repaint(); fireMoved(); } } firePropertyChange(PROPERTY_VIEW_LOCATION, event.getOldValue(), event.getNewValue()); } } } /** * Sets extents of {@link RangeModel RangeModels} to the client area of this * Viewport. Sets RangeModel minimums to zero. Sets RangeModel maximums to * this Viewport's height/width. * * @since 2.0 */ protected void readjustScrollBars() { if (getContents() == null) return; getVerticalRangeModel().setAll(0, getClientArea().height, getContents().getBounds().height); getHorizontalRangeModel().setAll(0, getClientArea().width, getContents().getBounds().width); } /** * Sets this Viewport to be associated with the passed Figure. * * @param figure * the new contents * @since 2.0 */ public void setContents(IFigure figure) { if (view == figure) return; if (view != null) remove(view); view = figure; if (view != null) add(figure); } /** * Toggles the Viewport's ability to resize itself automatically when its * view is decreased in size in the vertical direction. This is disabled by * default. * * @param track * whether this viewport should track its height * @since 2.0 */ public void setContentsTracksHeight(boolean track) { trackHeight = track; } /** * Toggles the Viewport's ability to resize itself automatically when its * view is decreased in size in the horizontal direction. This is disabled * by default. * * @param track * whether this viewport should track its width * @since 2.0 */ public void setContentsTracksWidth(boolean track) { trackWidth = track; } /** * Sets the horizontal location of the Viewport's view to the passed value. * * @param value * the new horizontal location * @since 2.0 */ public void setHorizontalLocation(int value) { setViewLocation(value, getVerticalRangeModel().getValue()); } /** * Sets the horizontal range model to the passed RangeModel. * * @param rangeModel * the new horizontal range model * @since 2.0 */ public void setHorizontalRangeModel(RangeModel rangeModel) { if (horiztonalRangeModel != null) horiztonalRangeModel.removePropertyChangeListener(this); horiztonalRangeModel = rangeModel; horiztonalRangeModel.addPropertyChangeListener(this); } /** * If value is true, this viewport will ignore any * scrolling that occurs until this method is called again with * false. * * @param value * whether this viewport should ignore future scrolls */ public void setIgnoreScroll(boolean value) { ignoreScroll = value; } /** * Sets the vertical location of the Viewport's view to the passed value. * * @param value * the new vertical location * @since 2.0 */ public void setVerticalLocation(int value) { setViewLocation(getHorizontalRangeModel().getValue(), value); } /** * Sets the vertical range model to the passed RangeModel. * * @param rangeModel * the new vertical RangeModel * @since 2.0 */ public void setVerticalRangeModel(RangeModel rangeModel) { if (verticalRangeModel != null) verticalRangeModel.removePropertyChangeListener(this); verticalRangeModel = rangeModel; verticalRangeModel.addPropertyChangeListener(this); } /** * Sets the location of the Viewport's view to the passed values. * * @param x * The new x coordinate of the Viewport's view. * @param y * The new y coordinate of the Viewport's view. * @since 2.0 */ public void setViewLocation(int x, int y) { if (getHorizontalRangeModel().getValue() != x) getHorizontalRangeModel().setValue(x); if (getVerticalRangeModel().getValue() != y) getVerticalRangeModel().setValue(y); } /** * Sets the location of the Viewport's view to the passed Point. * * @param p * The new location of the Viewport's view. * @since 2.0 */ public void setViewLocation(Point p) { setViewLocation(p.x, p.y); } /** * @see IFigure#translateFromParent(Translatable) */ public void translateFromParent(Translatable t) { if (useTranslate) t.performTranslate(getHorizontalRangeModel().getValue(), getVerticalRangeModel().getValue()); super.translateFromParent(t); } /** * @see IFigure#translateToParent(Translatable) */ public void translateToParent(Translatable t) { if (useTranslate) t.performTranslate(-getHorizontalRangeModel().getValue(), -getVerticalRangeModel().getValue()); super.translateToParent(t); } /** * Returns true if this viewport uses graphics translation. * * @return whether this viewport uses graphics translation */ public boolean useGraphicsTranslate() { return useTranslate; } /** * @see IFigure#validate() */ public void validate() { super.validate(); readjustScrollBars(); } } ViewportAwareConnectionLayerClippingStrategy.java000066400000000000000000000205401166301720600353020ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/******************************************************************************* * Copyright (c) 2005, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.Iterator; import java.util.List; import org.eclipse.draw2d.geometry.Insets; import org.eclipse.draw2d.geometry.PointList; import org.eclipse.draw2d.geometry.Rectangle; /** * Clipping strategy for connection layer, which takes into account nested view * ports and truncates those parts of connections which reach outside and are * thus not visible. * * @author Alexander Nyssen * @author Philip Ritzkopf * * @since 3.6 */ public class ViewportAwareConnectionLayerClippingStrategy implements IClippingStrategy { private static final Insets PRIVATE_INSETS = new Insets(0, 0, 1, 1); private ConnectionLayer connectionLayer = null; public ViewportAwareConnectionLayerClippingStrategy( ConnectionLayer connectionLayer) { this.connectionLayer = connectionLayer; } /** * @see org.eclipse.draw2d.IClippingStrategy#getClip(org.eclipse.draw2d.IFigure) */ public Rectangle[] getClip(IFigure figure) { Rectangle[] clipRect = null; if (figure instanceof Connection) { clipRect = getEdgeClippingRectangle((Connection) figure); } else { clipRect = new Rectangle[] { getNodeClippingRectangle(figure) }; } // translate clipping rectangles (which are in absolute coordinates) // to be relative to the parent figure's (i.e. the connection // layer's) client area for (int i = 0; i < clipRect.length; i++) { figure.translateToRelative(clipRect[i]); } return clipRect; } /** * Computes clipping rectangle(s) for a given connection. Will consider all * enclosing viewports, excluding the root viewport. */ protected Rectangle[] getEdgeClippingRectangle(Connection connection) { // start with clipping the connection at its original bounds Rectangle clipRect = getAbsoluteBoundsAsCopy(connection); // in case we cannot infer source and target of the connection (e.g. // if XYAnchors are used), returning the bounds is all we can do ConnectionAnchor sourceAnchor = connection.getSourceAnchor(); ConnectionAnchor targetAnchor = connection.getTargetAnchor(); if (sourceAnchor == null || sourceAnchor.getOwner() == null || targetAnchor == null || targetAnchor.getOwner() == null) { return new Rectangle[] { clipRect }; } // source and target figure are known, see if there is common // viewport // the connection has to be clipped at. IFigure sourceFigure = sourceAnchor.getOwner(); IFigure targetFigure = targetAnchor.getOwner(); Viewport nearestEnclosingCommonViewport = ViewportUtilities .getNearestCommonViewport(sourceFigure, targetFigure); if (nearestEnclosingCommonViewport == null) { return new Rectangle[] { clipRect }; } // if the nearest common viewport is not the root viewport, we may // start with clipping the connection at this viewport. if (nearestEnclosingCommonViewport != getRootViewport()) { clipRect.intersect(getNodeClippingRectangle(nearestEnclosingCommonViewport)); } // if the nearest common viewport of source and target is not // simultaneously // the nearest enclosing viewport of source and target respectively, the // connection has to be further clipped (the connection may even not be // visible at all) Viewport nearestEnclosingSourceViewport = ViewportUtilities .getNearestEnclosingViewport(sourceFigure); Viewport nearestEnclosingTargetViewport = ViewportUtilities .getNearestEnclosingViewport(targetFigure); if (nearestEnclosingSourceViewport != nearestEnclosingTargetViewport) { // compute if source and target anchor are visible // within the nearest common enclosing viewport (which may // itself be nested in other viewports). Rectangle sourceClipRect = getAbsoluteBoundsAsCopy(sourceFigure); if (nearestEnclosingSourceViewport != nearestEnclosingCommonViewport) { clipAtViewports(sourceClipRect, ViewportUtilities.getViewportsPath( nearestEnclosingSourceViewport, nearestEnclosingCommonViewport, false)); } Rectangle targetClipRect = getAbsoluteBoundsAsCopy(targetFigure); if (nearestEnclosingTargetViewport != nearestEnclosingCommonViewport) { clipAtViewports(targetClipRect, ViewportUtilities.getViewportsPath( nearestEnclosingTargetViewport, nearestEnclosingCommonViewport, false)); } PointList absolutePointsAsCopy = getAbsolutePointsAsCopy(connection); boolean sourceAnchorVisible = sourceClipRect.getExpanded( PRIVATE_INSETS).contains( absolutePointsAsCopy.getFirstPoint()); boolean targetAnchorVisible = targetClipRect.getExpanded( PRIVATE_INSETS).contains( absolutePointsAsCopy.getLastPoint()); if (!sourceAnchorVisible || !targetAnchorVisible) { // one (or both) of source or target anchor is invisible // within the nearest common viewport, so up to now // we regard the edge as invisible. return new Rectangle[] {}; // TODO: We could come up with a more decent strategy here, // which also computes clipping fragments in those cases // where source/target are not visible but the edge // intersects with the enclosing source/target viewport's // parents bounds. } else { // both ends are visible, so just return what we have // computed before // (clipping at nearest enclosing viewport) return new Rectangle[] { clipRect }; } } else { // source and target share the same enclosing viewport, so just // return what we have computed before (clipping at nearest // enclosing viewport) return new Rectangle[] { clipRect }; } } /** * Computes clipping rectangle for a given (node) figure. Will consider all * enclosing viewports, excluding the root viewport. */ protected Rectangle getNodeClippingRectangle(IFigure figure) { // start with the bounds of the edit part's figure Rectangle clipRect = getAbsoluteBoundsAsCopy(figure); // now traverse the viewport path of the figure (and reduce clipRect // to what is actually visible); process all viewports up to the // root viewport List enclosingViewportsPath = ViewportUtilities.getViewportsPath( ViewportUtilities.getNearestEnclosingViewport(figure), getRootViewport(), false); clipAtViewports(clipRect, enclosingViewportsPath); return clipRect; } /** * Clips the given clipRect at all given viewports. */ protected void clipAtViewports(Rectangle clipRect, List enclosingViewportsPath) { for (Iterator iterator = enclosingViewportsPath.iterator(); iterator .hasNext();) { Viewport viewport = (Viewport) iterator.next(); clipRect.intersect(getAbsoluteViewportAreaAsCopy(viewport)); } } /** * Returns the root viewport, i.e. the nearest enclosing viewport of the * connection layer, which corresponds to the nearest enclosing common * viewport of primary and connection layer. */ protected Viewport getRootViewport() { return ViewportUtilities.getNearestEnclosingViewport(connectionLayer); } /** * Returns the connection's points in absolute coordinates. */ protected PointList getAbsolutePointsAsCopy(Connection connection) { PointList points = connection.getPoints().getCopy(); connection.translateToAbsolute(points); return points; } /** * Returns the area covered by the viewport in absolute coordinates. */ protected Rectangle getAbsoluteViewportAreaAsCopy(Viewport viewport) { return getAbsoluteClientAreaAsCopy(viewport); } /** * Returns the viewport's client area in absolute coordinates. */ protected Rectangle getAbsoluteClientAreaAsCopy(IFigure figure) { Rectangle absoluteClientArea = figure.getClientArea(); figure.translateToParent(absoluteClientArea); figure.translateToAbsolute(absoluteClientArea); return absoluteClientArea; } /** * Returns the figure's bounds in absolute coordinates. */ protected Rectangle getAbsoluteBoundsAsCopy(IFigure figure) { Rectangle absoluteFigureBounds = figure.getBounds().getCopy(); figure.translateToAbsolute(absoluteFigureBounds); return absoluteFigureBounds; } }eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ViewportLayout.java000066400000000000000000000104001166301720600273430ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Insets; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; /** * Layout for a viewport. A viewport is a flexible window onto a figure. */ public class ViewportLayout extends AbstractHintLayout { /** * Returns the minimum size required by the input viewport figure. Since * viewport is flexible, the minimum size required would be the just the * size of the borders. * * @see AbstractHintLayout#calculateMinimumSize(IFigure, int, int) */ protected Dimension calculateMinimumSize(IFigure figure, int wHint, int hHint) { Viewport viewport = (Viewport) figure; Dimension min = new Dimension(); Insets insets = viewport.getInsets(); return min.getExpanded(insets.getWidth(), insets.getHeight()); } /** * Calculates and returns the preferred size of the figure based on the * given hints. The given wHint is ignored unless the viewport (parent) is * tracking width. The same is true for the height hint. * * @param parent * the Viewport whose preferred size is to be calculated * @param wHint * the width hint * @param hHint * the height hint * @return the Preferred size of the given viewport * @since 2.0 */ protected Dimension calculatePreferredSize(IFigure parent, int wHint, int hHint) { Viewport viewport = (Viewport) parent; Insets insets = viewport.getInsets(); IFigure contents = viewport.getContents(); if (viewport.getContentsTracksWidth() && wHint > -1) wHint = Math.max(0, wHint - insets.getWidth()); else wHint = -1; if (viewport.getContentsTracksHeight() && hHint > -1) hHint = Math.max(0, hHint - insets.getHeight()); else hHint = -1; if (contents == null) { return new Dimension(insets.getWidth(), insets.getHeight()); } else { Dimension minSize = contents.getMinimumSize(wHint, hHint); if (wHint > -1) wHint = Math.max(wHint, minSize.width); if (hHint > -1) hHint = Math.max(hHint, minSize.height); return contents.getPreferredSize(wHint, hHint).getExpanded( insets.getWidth(), insets.getHeight()); } // Layout currently does not union border's preferred size. } /** * @see org.eclipse.draw2d.AbstractHintLayout#isSensitiveHorizontally(IFigure) */ protected boolean isSensitiveHorizontally(IFigure parent) { return ((Viewport) parent).getContentsTracksWidth(); } /** * @see org.eclipse.draw2d.AbstractHintLayout#isSensitiveHorizontally(IFigure) */ protected boolean isSensitiveVertically(IFigure parent) { return ((Viewport) parent).getContentsTracksHeight(); } /** * @see org.eclipse.draw2d.LayoutManager#layout(IFigure) */ public void layout(IFigure figure) { Viewport viewport = (Viewport) figure; IFigure contents = viewport.getContents(); if (contents == null) return; Point p = viewport.getClientArea().getLocation(); p.translate(viewport.getViewLocation().getNegated()); // Calculate the hints Rectangle hints = viewport.getClientArea(); int wHint = viewport.getContentsTracksWidth() ? hints.width : -1; int hHint = viewport.getContentsTracksHeight() ? hints.height : -1; Dimension newSize = viewport.getClientArea().getSize(); Dimension min = contents.getMinimumSize(wHint, hHint); Dimension pref = contents.getPreferredSize(wHint, hHint); if (viewport.getContentsTracksHeight()) newSize.height = Math.max(newSize.height, min.height); else newSize.height = Math.max(newSize.height, pref.height); if (viewport.getContentsTracksWidth()) newSize.width = Math.max(newSize.width, min.width); else newSize.width = Math.max(newSize.width, pref.width); contents.setBounds(new Rectangle(p, newSize)); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/ViewportUtilities.java000066400000000000000000000164601166301720600300550ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Research Group Software Construction, * RWTH Aachen University, Germany - initial API and implementation */ package org.eclipse.draw2d; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * Utility class to support working with {@link Viewport}s. * * @author Philip Ritzkopf * @author Alexander Nyssen * * @since 3.6 * */ public final class ViewportUtilities { private ViewportUtilities() { // provides only static utility functions and should not be accessed in // any other way than static. } /** * Returns all enclosing {@link Viewport}s for a given {@link IFigure}, * beginning with its direct enclosing {@link Viewport} up the root * {@link Viewport} in the figure's parent hierarchy. * * @param figure * @return A list of {@link Viewport}s representing the figure's enclosing * {@link Viewport} path, where the nearest enclosing * {@link Viewport} as the first element and the root * {@link Viewport} as the last element. In case there is no * enclosing {@link Viewport}, an empty list is returned. */ public static List getEnclosingViewportsPath(IFigure figure) { Viewport nearestEnclosingViewport = getNearestEnclosingViewport(figure); if (nearestEnclosingViewport == null) { return new ArrayList(); } Viewport rootViewport = getRootViewport(figure); return getViewportsPath(nearestEnclosingViewport, rootViewport, true); } /** * Returns a list containing the provided leaf {@link Viewport} as the first * element, and all its enclosing {@link Viewport}s up to the root * {@link Viewport}, where the root {@link Viewport} forms the last element * of the list. * * @param leafViewport * The {@link Viewport}, whose parent hierarchy is processed. * @param rootViewport * an ancestor of the given leafViewport, which marks the end * point of the hierarchy to be processed. * @return A list of {@link Viewport}s containing the leaf {@link Viewport} * as the first element, the root {@link Viewport} as the last and * in between all enclosing {@link Viewport}s of the leaf * {@link Viewport} up to the root. Returns an empty list in case * leaf or root {@link Viewport} are null or in case the root * viewport is not an ancestor of the leaf {@link Viewport}. */ public static List getViewportsPath(final Viewport leafViewport, final Viewport rootViewport) { return getViewportsPath(leafViewport, rootViewport, true); } /** * Returns a list containing the provided leaf {@link Viewport} as the first * element, and all its enclosing {@link Viewport}s up to the root * {@link Viewport}. The root {@link Viewport} forms the last element of the * list, in case includeRootViewport is set to true, otherwise the viewport * directly nested below the root viewport will be the last in the list. * * @param leafViewport * The {@link Viewport}, whose parent hierarchy is processed. * @param rootViewport * an ancestor of the given leafViewport, which marks the end * point of the hierarchy to be processed. * @param includeRootViewport * whether the provided rootViewport should be included in the * list of returned viewports (as the last one) or not. * @return A list of {@link Viewport}s containing the leaf {@link Viewport} * as the first element, the root {@link Viewport} as the last and * in between all enclosing {@link Viewport}s of the leaf * {@link Viewport} up to the root. Returns an empty list in case * leaf or root {@link Viewport} are null or in case the root * viewport is not an ancestor of the leaf {@link Viewport}. */ public static List getViewportsPath(final Viewport leafViewport, final Viewport rootViewport, boolean includeRootViewport) { if (leafViewport == null || rootViewport == null) { return Collections.EMPTY_LIST; } // search all enclosing viewports of leaf viewport up to root viewport // (or until no enclosing viewport can be found) List nestedViewports = new ArrayList(); Viewport currentViewport = leafViewport; do { nestedViewports.add(currentViewport); currentViewport = ViewportUtilities .getNearestEnclosingViewport(currentViewport); } while (currentViewport != null && currentViewport != rootViewport); // check if root viewport is an ancestor of the given leaf viewport if (currentViewport != null) { if (includeRootViewport) { nestedViewports.add(currentViewport); } return nestedViewports; } return Collections.EMPTY_LIST; } /** * Returns the nearest common enclosing {@link Viewport} for two given * {@link Figure}s. * * @param firstFigure * @param secondFigure * @return The nearest common {@link Viewport} of the two given figures, or * null if no common enclosing {@link Viewport} could be found. */ public static Viewport getNearestCommonViewport(IFigure firstFigure, IFigure secondFigure) { return getNearestViewport(FigureUtilities.findCommonAncestor( firstFigure, secondFigure)); } /** * Returns the upper most enclosing {@link Viewport} for the given * {@link IFigure}. * * @param figure * @return The upper most enclosing {@link Viewport} or null if there is no * enclosing {@link Viewport} for the given {@link IFigure}, */ public static Viewport getRootViewport(final IFigure figure) { Viewport currentViewport = getNearestViewport(figure); while (getNearestEnclosingViewport(currentViewport) != null) { currentViewport = getNearestEnclosingViewport(currentViewport); } return currentViewport; } /** * Returns the given figure in case it is a {@link Viewport} itself, * otherwise its nearest enclosing {@link Viewport}. * * @param figure * @return The given figure in case it is a {@link Viewport} itself, * otherwise the nearest enclosing {@link Viewport} or null if there * is no nearest enclosing {@link Viewport}. */ public static Viewport getNearestViewport(final IFigure figure) { if (figure == null) { return null; } if (figure instanceof Viewport) { return (Viewport) figure; } else { return getNearestEnclosingViewport(figure); } } /** * Returns the nearest enclosing {@link Viewport} of a given {@link IFigure} * by walking up the figure's hierarchy. * * @param figure * @return The nearest enclosing {@link Viewport} of the given figure, or * null if none could be found. */ public static Viewport getNearestEnclosingViewport(final IFigure figure) { if (figure == null) { return null; } Viewport viewport = null; IFigure currentFigure = figure; while (currentFigure.getParent() != null) { if (currentFigure.getParent() instanceof Viewport) { viewport = (Viewport) currentFigure.getParent(); break; } currentFigure = currentFigure.getParent(); } return viewport; } }eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/XYAnchor.java000066400000000000000000000041051166301720600260260ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import org.eclipse.draw2d.geometry.Point; /** * Supports an anchor in the XY layout. This anchor exists independently without * an owner. */ public class XYAnchor extends ConnectionAnchorBase { private Point location; /** * Constructs an XYAnchor at the Point p. * * @param p * the point where this anchor will be located * @since 2.0 */ public XYAnchor(Point p) { location = new Point(p); } /** * Returns the location of this anchor relative to the reference point given * in as input. Since this is XY layout, the location of the point is * independent of the reference point. * * @see ConnectionAnchor#getLocation(Point) */ public Point getLocation(Point reference) { return location; } /** * Returns null as these anchors inherently do not depend on * other figures for their location. * * @see ConnectionAnchor#getOwner() * @since 2.0 */ public IFigure getOwner() { return null; } /** * Returns the point which is used as the reference by this connection * anchor. In the case of the XYAnchor, this point is the same as its * location. * * @see ConnectionAnchor#getReferencePoint() */ public Point getReferencePoint() { return location; } /** * Sets the location of this anchor and notifies all the listeners of the * update. * * @param p * the new location of this anchor * @see #getLocation(Point) * @since 2.0 */ public void setLocation(Point p) { location.setLocation(p); fireAnchorMoved(); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/XYLayout.java000066400000000000000000000103651166301720600260760ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d; import java.util.HashMap; import java.util.Iterator; import java.util.ListIterator; import java.util.Map; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Insets; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; /** * This class implements the {@link org.eclipse.draw2d.LayoutManager} interface * using the XY Layout algorithm. This lays out the components using the layout * constraints as defined by each component. */ public class XYLayout extends AbstractLayout { /** The layout contraints */ protected Map constraints = new HashMap(); /** * Calculates and returns the preferred size of the input figure. Since in * XYLayout the location of the child should be preserved, the preferred * size would be a region which would hold all the children of the input * figure. If no constraint is set, that child is ignored for calculation. * If width and height are not positive, the preferred dimensions of the * child are taken. * * @see AbstractLayout#calculatePreferredSize(IFigure, int, int) * @since 2.0 */ protected Dimension calculatePreferredSize(IFigure f, int wHint, int hHint) { Rectangle rect = new Rectangle(); ListIterator children = f.getChildren().listIterator(); while (children.hasNext()) { IFigure child = (IFigure) children.next(); Rectangle r = (Rectangle) constraints.get(child); if (r == null) continue; if (r.width == -1 || r.height == -1) { Dimension preferredSize = child.getPreferredSize(r.width, r.height); r = r.getCopy(); if (r.width == -1) r.width = preferredSize.width; if (r.height == -1) r.height = preferredSize.height; } rect.union(r); } Dimension d = rect.getSize(); Insets insets = f.getInsets(); return new Dimension(d.width + insets.getWidth(), d.height + insets.getHeight()).union(getBorderPreferredSize(f)); } /** * @see LayoutManager#getConstraint(IFigure) */ public Object getConstraint(IFigure figure) { return constraints.get(figure); } /** * Returns the origin for the given figure. * * @param parent * the figure whose origin is requested * @return the origin */ public Point getOrigin(IFigure parent) { return parent.getClientArea().getLocation(); } /** * Implements the algorithm to layout the components of the given container * figure. Each component is laid out using its own layout constraint * specifying its size and position. * * @see LayoutManager#layout(IFigure) */ public void layout(IFigure parent) { Iterator children = parent.getChildren().iterator(); Point offset = getOrigin(parent); IFigure f; while (children.hasNext()) { f = (IFigure) children.next(); Rectangle bounds = (Rectangle) getConstraint(f); if (bounds == null) continue; if (bounds.width == -1 || bounds.height == -1) { Dimension preferredSize = f.getPreferredSize(bounds.width, bounds.height); bounds = bounds.getCopy(); if (bounds.width == -1) bounds.width = preferredSize.width; if (bounds.height == -1) bounds.height = preferredSize.height; } bounds = bounds.getTranslated(offset); f.setBounds(bounds); } } /** * @see LayoutManager#remove(IFigure) */ public void remove(IFigure figure) { super.remove(figure); constraints.remove(figure); } /** * Sets the layout constraint of the given figure. The constraints can only * be of type {@link Rectangle}. * * @see LayoutManager#setConstraint(IFigure, Object) * @since 2.0 */ public void setConstraint(IFigure figure, Object newConstraint) { super.setConstraint(figure, newConstraint); if (newConstraint != null) constraints.put(figure, newConstraint); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/doc-files/000077500000000000000000000000001166301720600253355ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/doc-files/demo2.gif000066400000000000000000000060561166301720600270410ustar00rootroot00000000000000GIF87ak1   $$$$$$,,4,444,<4<4DDDD٫R!;xHVZDE1\&RfN"Pے*| Kw1TUuUp@uQY[Ij;vpemI^*pAS1tmib.a#g$K@pQ-_vnuhR6lA&Y>P P4z.*`^Z]/Fb/./[!ss @sw+4J Әt-?PylwQynki:Xh+%n!tOK4얦mxy֬L 7lqcZ,Jշ-s׊5 UB;Դ]w+YʕM+HKQwN0WR*IkhN ̰7\IZG=-~YܢXٺc$ܛ8"/c8PL*[yi"ۇ\Lf1g%G^3 p3ulZ,>tfIϦt>f7VP7nfc=멖Ne!x6gN[{=iyv,Ela6NZDNx;^&[^ӕ櫽;S,G?=Mw^

    Example 2 - Layout Managers

    In this example, a panel is created with a FlowLayout for its layout manager.  A flow layout positions children left-to-right in rows going from top-to-bottom.  The children are sized according to their preferred size.

    01
    02
    03
    04
    05
    06
    07
    08
    09
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    
    import org.eclipse.swt.widgets.Shell;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.draw2d.*;
    import org.eclipse.swt.SWT;
    import org.eclipse.draw2d.geometry.*;
    
    public class Demo2 {
    	public static void main(String args[]){
    		Shell shell = new Shell();
    		shell.open();
    		shell.setText("Draw2d");
    		LightweightSystem lws = new LightweightSystem(shell);
    		IFigure panel = new Figure();
    		panel.setLayoutManager(new FlowLayout());
    		lws.setContents(panel);
    
    		Clickable button = new Button("Click me");
    		Clickable checkbox = new CheckBox("Check box");
    
    		Shape ellipse = new Ellipse();
    		ellipse.setBackgroundColor(ColorConstants.yellow);
    		ellipset.setSize(64, 36);
    
    		Shape rectangle = new RectangleFigure();
    		rectangle.setBackgroundColor(ColorConstants.lightBlue);
    		rectangle.setSize(64, 36);
    
    		panel.add(button);
    		panel.add(checkbox);
    		panel.add(ellipse);
    		panel.add(rectangle);
    
    		Display display = Display.getDefault();
    		while (!shell.isDisposed ()) {
    			if (!display.readAndDispatch ())
    				display.sleep ();
    		}
    	}
    }
    eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/doc-files/demo3.gif000066400000000000000000000161311166301720600270350ustar00rootroot00000000000000GIF87aJ1 $ ,,4 T \ $\ $d $l ,l,l,t4t4t4|<|$<|$<$D,DDDD,L,L4L4TL$L,T4TH'7m-k˖GZኌ)%{)) jkϜ@=PްsvT@b+ELQo[y|Y{`]#vH`-v̥ڶ>*"J﫩;L!VH6Ҵe#fCZ6r1oUH,dz'Þ' й,J L*|; Z>/~V0@%]҆<'0=ni^6bGzސ2ȹyn{,BҍP|ٽN!}.}+l 8?p6ġ 9$xA ld['cE%aу"0|ep}[x_%rlJ@#ܣ,8@byäC+׫AwEUd L. >$o] aҪc69ĒD8A>o$9Fӑ4F7IU)uoS3ϷIHs}Ԭ_1&P1[!W>QFl. Ͼlz=ņOpOT%%ԁi)tBXMSN QZ((!2F Ֆ8RRg0WGs?izI2*0]AI*v-!) )R˱8k IKMHZUiغU22mgvQ0 TkBM6@Қ 01ĩiJXM*GO/rХY|c91Sg}A;>FSh@RwȮv+A%P)lר6rWn9ӷ.$+ӱ(tB܂>c LR/8^5r z?fHւEY#W \2(NSlxų{O mJ /6µ{pK guS\KE5_SlqoZ XXβe-`2Mycxq| ٖ5n[%szrdYӀRٌ =2K3ư%:RqMV Nl2:bzР5rwRԨN5B VհcMZ:ֳwmŦaȮffΎQ i[ھmTϖ-r;!>ŝu{~y;}{i?M;( y[&+{1푛'?ʕ򕻜~a\v1q^<7fEGt%Wu\ tG/5kLzs~ꬋvz+:~}ao!޴4w=jkJϽW7;;\= :ڟ;񐏼'O[w<Γ䚌zz“؄Wdhiٕ]v i_IYēV7)S)i~)!ِQ{Ag)9͉t I(IuOnmXy}ijy`陛{ߙbɍx|ǐhg؉yi|u#Ʉϩ9 йѡ^"dy(*9Љ /2< 뱠,xѰ/E 2Il ѩ{4o,3j&\<}!kL7hln(M?kvK:Ғ<(m *_-̥ᨷt7 ڶ8MKaHɈ:Z^ZY=o@ ͻkͤҲ<DZ-p{ա}[&[TL۶Mܤ{n ڪ}̻']~=ۋmmйj-\ Lk͝ ]فl\,؝| q]ܩ } }:]ɝ.f+ݯ  LA{\F{׭-a0=xGFȶ *^߼ЋLިc{q8 clC+QE; lFۯ;0'7KHR,>/AԒS='#PQ;I N4K:BtCr%T9WKԤ,II/UDuVO1=HKY'zuXCW[MSR RvZ\%ڵ^W."אk.,|VcaMV\v*1s[]+]lm^ޅ(b{u&}6"ow`tm5_KOb3xc;cCydKFq߿m(awrfkf͍WZzf{nܖ_enok';V.'m㧷>׾7Wwߗ4l`;&$T@>WA 98?~}!HXS Bnσϣa m‰n1v0!`~!a~ĂщID'E={Ey`yHFř1h4$] H Ƈ|%rRe&f'rǘB]L ! G)KوSI,A2z#t1Ҋ7Ac6I61DBe45Cpe[2GT)O!Fz \zǼz,ZXelcXFV,czYfVlg=YV5 ;eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/doc-files/demo3.html000066400000000000000000000100671166301720600272360ustar00rootroot00000000000000
    Example 3 - Clicking and Scrolling

     

    In this example, a Button is used to create CheckBoxes inside a ScrollPane.

    The button and scrollpane are placed absolutely inside the contents figure by simply setting their bounds; no layout manager is used there.  However, the view must have a Layout, or its preferred size will not get calculated, and scrolling will not work correctly.

    The button's action listener will get called each time the user clicks on the button.  The listener will create a new CheckBox and add it to the view. A vertical scrollbar will appear when the checkboxes cannot all be displayed at once in the pane.

    01
    02
    03
    04
    05
    06
    07
    08
    09
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    
    import org.eclipse.swt.widgets.Shell;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.draw2d.*;
    import org.eclipse.swt.SWT;
    import org.eclipse.draw2d.geometry.*;
    
    public class Demo3 {
    
    static int count = 1;
    
    public static void main(String args[]){
    	Shell shell = new Shell();
    	shell.setSize(350,350);
    	shell.open();
    	shell.setText("Demo 3");
    	LightweightSystem lws = new LightweightSystem(shell);
    	IFigure panel = new Figure();
    	lws.setContents(panel);
    	ScrollPane scrollpane = new ScrollPane();
    	scrollpane.setBounds(new Rectangle(30,30,210,200));
    	scrollpane.getViewport().setBorder(new GroupBoxBorder("Viewport"));
    	scrollpane.setBorder(new GroupBoxBorder("ScrollPane"));
    	
    final Figure view = new Figure(); view.setBorder(new GroupBoxBorder("The View")); view.setLayoutManager(new FlowLayout(FlowLayout.VERTICAL)); scrollpane.setView(view);
    Clickable button = new Button("Create checkbox"); button.setBounds(new Rectangle(30,250,140,35));
    button.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ view.add(new CheckBox("Checkbox "+count++)); } });
    panel.add(button); panel.add(scrollpane); Display display = Display.getDefault(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep (); } } }
    eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/doc-files/demo4.gif000066400000000000000000000107001166301720600270320ustar00rootroot00000000000000GIF89aDbऋ6xYD㱣+ǪOnᩓ,p.Kf~7TJ9{HH-s5Rj1u~B`R@^1Mv6S*F(Dj"M&Btd4w7ky1t !a5*7)nɴ>Xn{pڨ39եm>߶\,@@@ $jtHmn|̀Ћ9WܡYx %jdrVuqÖZyp8UecIg畸ikPo;X蔷[{މׇWvSqtyhl]}ߣwnjXwQpJhTrHfsčLj}UtӃ\|aKig`MkbfoGeؓ_~zʘ䐲xȗ㛾{ˈ~uƆ*o$?[?\,I;| <}3P/s!=~%A#> 'l &k &ɝtߜHteHt)lďHH@~ߜHtH,JHH3PtttH\tHH`3tt,̷M`P+Ǖft \&zKHSe¿HHzǜ߿Ț}Ԝt@j#)SH#?>f@пt!, H*\ȰÇ#JH!iȱǏ CIɓ(S\ɲeH"YI͛8s,3Ο@ J_O(]ʴӥUjтԂ`]"$rkV)Y$Bv8zUƒ]1* 2\I? EB8ayӇʖ5`H+^&93̝%L(qreQ{8PsI(7Xz‡PMl\R#FK'Mf]>ԪWnU@رeϦ]mܹuݕ^}`vXb5XdUvYfuYhvZjZlv[n[pw\r5\tUw]vۙg8ވ^L#SQeVZqXbeZj[pE]xŗ_ Fa)ƘcIFeiƙgFiƚkFmƛo Gq)ǜsIGuiKC zJCpOI!3 BBi /p J i_1ߓI`by z`Ia #ib)/ *c5"L>ӡm[ģH) p +>@ *I-P7V% v 9!"Y"(.#4r6ZDy n0 2CF:|Fw5_R9j ~Y!"$y*"0:'rCޮ͐F )3 +Ҋ4 K V+Z5 fS+砇Amhܐ*5FG޺-:3nwtQ +ثϭ;]Rxӻ& W=lY[qf=miܹ@O(^^Roݹ)AÏz\ůX `F\iZԂkb[Kž֬-Z;[湄}[}2vmwF6 &Fr!PBFa \5_1j‚֌E1) c`s&-m !L-"E~Ά6GqCALE8=htlx k#ܠU*>\` ,AE/|̸Amo 9(CgM)}2CY%;"D,1Qø$OiC;ȏT2mLXAUA}$#BN#azD]Le4 3HZ#%@Mnz&7NA'JP;9ϋdƈa\(Bm|h&blJQdPYxxHY{&Goc!%I7YZI#hE .Nzb wFV{l -"t}C5WXo)GJaS UЇ&Վv9͉NeZ| E 6zd̠䲗F^{n;#1SgpNCT0UTWqr_$'= Jj]e99Q?9@>z= ;w5JIuMzPVzXZ\ڥZhydZfJ`gڦnjiq7oZvzq:_z|Zyz٧z:9ꥅ*Rʨj ZzbʩGJzZsʪ ꪎ'zx~*|C* joJ' κڦ̚׊zJʫ Z㊦ڬ窨骭ڥZxX7j*xگwPZXv! so't[rLr91${&{*{t,۲{0[);'6<[s5(SDG;v8(L;wRuQ[.{XZ4K^ya[`;)SfiksF;moqsu[w+y{˴}=Ak;[{۸Kk;[{˹;eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/doc-files/demo4.html000066400000000000000000000143671166301720600272460ustar00rootroot00000000000000
    Example 4 - Connections and Anchors

    This example shows how to use Connections and ConnectionAnchors.  A connection is a figure that visually connects two anchors.  The anchors are usually places on figures which the connection is linking.

    The red and blue "nodes" can be dragged around with the mouse.  The connection will re-route itself automatically.  The connections children, the "Midpoint" label and the arrowhead, will also update.

    The connection implementation used here is a PolylineConnection.  This implementation supports decorations, such as arrowheads.  PolygonDecorations added to the connection will be rotated correctly by a Locator.  Other decorations can be added with their own locators, such as the "Midpoint" label in the demo.
     

    import org.eclipse.swt.SWT;
    import org.eclipse.swt.widgets.Shell;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.draw2d.*;
    import org.eclipse.draw2d.geometry.*;
    
    public class Demo4 {
    
    public static void main(String args[]){
          Shell shell = new Shell();
          shell.setSize(350,350);
          shell.open();
          shell.setText("Demo 4");
          LightweightSystem lws = new LightweightSystem(shell);
          IFigure panel = new Figure();
          lws.setContents(panel);
          RectangleFigure
                node1 = new RectangleFigure(),
                node2 = new RectangleFigure();
          node1.setBackgroundColor(ColorConstants.red);
          node1.setSize(64, 36);
          node2.setBackgroundColor(ColorConstants.blue);
          node2.setLocation(new Rectangle(100, 100, 64, 36));
    
          PolylineConnection conn = new PolylineConnection();
          conn.setSourceAnchor(new ChopboxAnchor(node1));
          conn.setTargetAnchor(new ChopboxAnchor(node2));
          conn.setTargetDecoration(new PolygonDecoration());
    
          Label label = new Label("Midpoint");
          label.setOpaque(true);
          label.setBackgroundColor(ColorConstants.buttonLightest);
          label.setBorder(new LineBorder());
          conn.add(label, new MidpointLocator(conn, 0));
    
          panel.add(node1);
          panel.add(node2);
          panel.add(conn);
          new Dragger(node1);
          new Dragger(node2);
          Display display = Display.getDefault();
          while (!shell.isDisposed()) {
                if (!display.readAndDispatch())
                      display.sleep ();
    }
    
    }
    static class Dragger extends MouseMotionListener.Stub implements MouseListener {
          public Dragger(IFigure figure){
                figure.addMouseMotionListener(this);
                figure.addMouseListener(this);
          }
          Point last;
          public void mouseReleased(MouseEvent e){}
          public void mouseClicked(MouseEvent e){}
          public void mouseDoubleClicked(MouseEvent e){}
          public void mousePressed(MouseEvent e){
                last = e.getLocation();
          }
          public void mouseDragged(MouseEvent e){
                Point p = e.getLocation();
                Dimension delta = p.getDifference(last);
                last = p;
                Figure f = ((Figure)e.getSource());
                f.setBounds(f.getBounds().getTranslated(delta.width, delta.height));
          }
    };
    
    }
     eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/doc-files/draw2d.gif000066400000000000000000000277041166301720600272210ustar00rootroot00000000000000GIF87a1  $ 4 44 D DD TD 4,,D<_vfh~}$Zvbe e/(Xu"݆9$Y@&]Sf/zbMR:$pL& `)dih)k&_frix%TZn #  A(j8W%^ & Fj*W-~*)r: 9ڞՙ筸Y'oIg+이6է&'Ш(C Tx2&H;c΢~eZm $; ߆_.۰k '7LJ+M(PKpj3`1|v_ت0K :s`pMn4C/tP+!W}%cM\g^ 67/W,.Gmɘ1ڱ 1_!:Xj\6'7GU~x[w%]u R X,rb[ae*g>8 i_>o oЇn[lhBl^/{͌ ÷ОV ~O' ?⏀|@ W=i,ot*,j㫌+ӽEW8.fX\8pDЪHbR.zQ` EZtx5fB1t:qwcRߩQ6וp@_rΞF:򑐌$'IJZ#Nz#PR:*WVt(BS Z'c^dpIbHL2%e&s>1IMyə|f69jz4q3q/L:v3, 1'9G)A̧>~tg\"VMB8q T=JъZ;7ю HGJ|iIWҖԡ(E)fX˒ m];+žĴ\jJy$=jgz6nj$+n[>"rj\W$%r֦v1j$(vnAIKӼZQoGKσw}zl~k׳ 퀯Bߍ4 }pOL$[WApz#`{ K4p>E OR\̹%#tqlTpZqH|f?FD2; 0F1aUO;87i OK{Z:ڑ6,;jkvF`2& N[)+2hVcyc,4+:!riGk])PNW7Ђr\V͌fO-GCխ>59dkgD.'œ^euNN/%w9˅Xё~#zڽv))rs_E\{omnzxg9Ky`~xzI1/̤߼-z"6&׵O1uYﲝOt/J?{p+KÜ~C:k|&3i }}-Cg?t7ywzGhw~Wk(5|[c'G}gXKd U~Hv%y25cׂ,$~wW&U)u2U9'9:xVWu^Հw's6~;$OjeׄY/Oc0dFm]\2p_eÄ+pgtHE33$XA .d( %B|8E5n䨱bG!E I(?^4eJ1IK8 lisI?*Κ>c4ɕ,INZUY>z3֢]M4Q;zs؞eL;RY/˻~UXOqg.)WӴfm;Siͮ2NYqcϡALsiԧRHEMֱ_-l۵q[ok8jĺ3ѷWvi9oWuw+97C|{D?)yizS˯0L@b2mo2AIA3̢Ы,<;G8;Cc/R< 3㰰1?ʼn`H$dDN\J*D.I.jrQ"Y,1 4-$K8)2C >$ J1bS6@H9,բ B(Kq2 5:SFيR"u4+ݔU}U^tVEC;KRT 43a XaBVdcj:RRw daH8L ,=d,KIE>~Ox^.'J8 8@b(1Gm<3fyJGsXtqLLWZ9O@y/)kA"=(B!jzS (VP0<Ĕ(Z4qXI9T ΰg/ S.SRNiͥ㯇$g%؀Ͳ-OMS/ΣPBZ5)QZϦt?jXAвbdIu!lgt@ټ+^3>"_KfUz\zav[Ym#&H eٚĆPq*Flfݺ( vܮyyխV6gDv(*7D2 i+]ͪB{]@jLޘM$7Ni5q勬N]i8{Hުb(ל{w!m0Z| ".y+R%\/U( /,_+vO߱F5d<5Cɍ "&B s<C +[t9//kYfX*SylIYĻ;rq׻䄚ʙ7ժ6e0#\F-RR/t,roKuyffWyS_kX˓ޭV! }Hzv {^i<3pd=Ҋ9s:'I=)Ddzs2|m{YIi]:|{?ꡛ e}KÿqP Ӭ@*1|<\qP[>64yC+@&3A;YāC?1?ËI5+r"D d DBF-Y;4B$,0?D+=ԹKjC?\ŒH</Vżp95Y]w/[QWݻw Nb_C `r0Wfʸ1Ν7{&x,)'ʠCÎ}ubW&{K}-pέ|%pɸ޴ԭZ VrgR{xßm;=[^[7~u X]mǟifw zV]m.!w%[Qv]mH&!"˜b衋gs)ŢݝV8$"8YOJRy`1^nKrɣKi_IYfVYztR)f9Мߘ'rFX}.6{'a )Bwy#)dinYoEiy᪪ZfJ++uVzٯ>Ȭ[lil*)N**v 鷜Wκkn+jM歷ΙzYLS\cs卑 Æܘ ڼ:k/Wɟًi'ǜLuܳ?.gїZ83GCFEN?][ H5;7]6ؙ}Yb#HvoÙt]pF$cӝr4aރ{*޸dh;>]Ewv_O cn8'^.dB^:S^ѮӾ"SZ^{̙y;#!iN|ñ˞1nI( }N{&l_r߽>P̺߶ïLS^(&yrWOoT"ZP#׻ x`I LV4 Je iJiFf%8m.De37q4'DIo6rgI8y&X5}FdzC- ](N4dD0!*5:<(&ڷgeFAɑϣ1)-Q:=VKWR = )O}Vϛt jԣ"5J]*SԧB5K)P:ϡF5Z*WUU]V&aճ5je*XYձB_*+]j׻5z+_׿m[% ],c~b5l>ob6kdUXX]lbGY*,h -mkkv-o{;6•j66]np:ҥmqZveC.umߍmx;r7u{7E/y݊yꞪՌsF;)K0Dl<3JV n-4pÙ͞8"1K߼ *^1[ø1S<x9cj #95ֱylc'8Rd#T5DgG] Lf)Y]2\Sȼi\s\e:9Jr@eJnYςrmh$9)8GC:Ғ4+mKcѨ4;OO:[4hP:ժ^5[7V?]m[:מuL1޴0  4xaB 6tB3(VxcF9vdH'4y%ǒWtfL[δy'Κ9yqO@Y5zgPKTjԊOIjVXv=kX`Ŧ\Ilژhն5Lq;{w-{p` 6|aEeqnj%O[rZ̓#gshȢ=oL өfu؟]φZ۶PwwFPowkx䗗E9qOwuٵ{M'鳲W/}ϗOR.`;/v?ϢV˥<*iJ?AUӋ%PDlO¯",) /(iq1 Ǫ-zfvO7IĒtZh¡{8܉iŝ:qV$u8r/+i@qɺL3{3]1 7f22WoyrMu}<;0iFQ` bpvBAoQ da41i QsSQt_& TS ;uO\dgLfHnUPH( pwk-2oX<^RP*Љ; "Ps#9>bD whFI%zbmu`bFB-pAܣpب3v0j|&ѳBD1jXD\A!GStW`(٬K4 Hĥrs'=J-}$DYNt#(wI΋ɞǛJ<$ٸ%Y5ddt7a0Ip5T&2Cх|*B5 ɪMeIǐ/4Oy2sh 壳F *s󗂩VHۘсҤՔ?b*o| +IƬҙ[e2m m)[|҇Dk&eT$AsNVmWY^71"]x*RA j{_olƁ*Uu~9ye7ᵁ`tߋvX(^l* &KW.^e`{X7Q%ck1!۪v,19M!W`ЁJ9 +Ӝɕ[¸fMQ3 z8Vh`G` Ot_l:P^vK*gzhnvA n`^6~]Ȅ-/uSv<\=w~uϒq5$]U=z;xm|cf)yoAx&ye[j0ix﷉A0VasI4˙V}?__ s8N~F̌ooO#I25МP!Pp/BV (d4^CZF/os' 5rt<uPr$g fH&Ç#4.@8@ CI'I~$rG'c,ɱ͛8sɳgO>vJtТH!b5UJիXG&ʵׯA(vIJf~@EQʝK*ڴx.߂~ ,'m=[ K<٤˘3ky3ΠCάpӚ)C@T1ǰckLv~#%k$^Wqؿm+_N49ܸKG Bbiwe]ËrWMP6]{US[?ygh9!a}ᇒL-LRe%K߈$esۉ`R4xуQK4$L_DAPJ d{OvTQCa n}X9"R1&V )wVee'g]$Yפb"9嘀*h*y\RjF#qgmij}&'64ƪꠍ 묭IkARoz(:裲Jke"RZ:_}L" HZhmJ.);-f꿬p+} Tõ v+魊hy':q, +n( ͱGe{ 3̋n+ؾLmrs:(''L6kbXW}a=H+4MY`_,iummFfՀ7q5dr}k;}4xZ@ksۉK39ս>Wo[Z'>t;=]"Fݲz,v^䡦i^.-O:e dWE֬cXU@m!@jի._77WmtXq% +V2" =0kmjO1X66#Y5VֳHMR F9&5YVMr*bMvyDSleKGVY3umJ.%iS:.ȝyc6"w"8 v+)u76  !zlV׀ pim6pBN-* `Gf3Ω̳7E=` `=KIf-.Q 0 V">>"J&qDdw)ke/2GT"#%ey9Z+YlEπ.KMBc5NټF;a/~'DJ[iƴ7N{z;eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/doc-files/helloworld.gif000066400000000000000000000044171166301720600302050ustar00rootroot00000000000000GIF87a61   $$$$$$,,4,444,<4<4D"q&) -"Ѥ0hb)&fDXn+̼;zG%Bvk'+&U ,1UD9,l'{DHZ =)&M:&sgR.7tna)Skjo!DjifPĭ.sp™m#UZc;3('""IvB2 vC*s, +@ 3m9 S &R#au'`BHxl>Yk#;e7aR;A7pat51!G|qUJc<-MޙҦ %{C6ֹy4H(O? SuL,v hg;%wH0 օ#hhB7UKsg&b0/i`ZZ&QlaH& ekH芴6A6D2&2)ฬn[j+0ZЩFS)V4A݊qh&OR)iR+)XavZA\ qY#:_(0.hhjdf\f錌B 5ZMk>|6# n7KZqPy(G]tJ@rӜ9: u󖊃.K*'jz@#*O2cBE?1ŚAL<P+y (MBz2)oAQ$ymt(9i}E@4Iج F4M/(cȘ:'%J{wzd,JVRG)rE}%]TKEHݨ`Ժȫ^H `Da:6dZ,f7Ih m#Қq @~Ď d\HN&;PL*[Xβ.{˧ ;eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/geometry/000077500000000000000000000000001166301720600253235ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/geometry/Dimension.java000066400000000000000000000367521166301720600301300ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.geometry; /** * Stores an integer width and height. This class provides various methods for * manipulating this Dimension or creating new derived Objects. */ public class Dimension implements Cloneable, java.io.Serializable, Translatable { private static final long serialVersionUID = 1L; /** * A singleton for use in short calculations. */ public static final Dimension SINGLETON = new Dimension(); /** * Creates a new Dimension representing the MAX of two provided Dimensions. * * @param d1 * first dimension * @param d2 * second dimension * @return A new Dimension representing the Max() * @since 3.7 */ public static Dimension max(Dimension d1, Dimension d2) { return new Dimension(Math.max(d1.width(), d2.width()), Math.max( d1.height(), d2.height())); } /** * Creates a new Dimension representing the MIN of two provided Dimensions. * * @param d1 * first dimension * @param d2 * second dimension * @return A new Dimension representing the Min() * @since 3.7 */ public static Dimension min(Dimension d1, Dimension d2) { return new Dimension(Math.min(d1.width(), d2.width()), Math.min( d1.height(), d2.height())); } /** * The width. */ public int width; /** * The height. */ public int height; /** * Constructs a Dimension of zero width and height. * * @since 2.0 */ public Dimension() { } /** * Constructs a Dimension with the width and height of the passed Dimension. * * @param d * the Dimension supplying the initial values * @since 2.0 */ public Dimension(Dimension d) { width = d.width(); height = d.height(); } /** * Constructs a Dimension with the supplied width and height values. * * @param w * the width * @param h * the height * @since 2.0 */ public Dimension(int w, int h) { width = w; height = h; } /** * Constructs a Dimension with the width and height of the Image supplied as * input. * * @param image * the image supplying the dimensions * @since 2.0 */ public Dimension(org.eclipse.swt.graphics.Image image) { org.eclipse.swt.graphics.Rectangle r = image.getBounds(); width = r.width; height = r.height; } /** * Constructs a Dimension where the width and height are the x and y * distances of the input point from the origin. * * @param p * the Point supplying the initial values * @since 2.0 */ public Dimension(org.eclipse.swt.graphics.Point p) { width = p.x; height = p.y; } /** * Returns true if the input Dimension fits into this * Dimension. A Dimension of the same size is considered to "fit". * * @param d * the dimension being tested * @return true if this Dimension contains d * @since 2.0 */ public boolean contains(Dimension d) { return width >= d.width() && height >= d.height(); } /** * Returns true if this Dimension properly contains the one * specified. Proper containment is defined as containment using \"<\", * instead of \"<=\". * * @param d * the dimension being tested * @return true if this Dimension properly contains the one * specified * @since 2.0 */ public boolean containsProper(Dimension d) { return width > d.width() && height > d.height(); } /** * Returns true if this Dimension's width and height are equal * to the given width and height. * * @param w * the width * @param h * the height * @return true if this dimension's width and height are equal * to those given. * @since 2.0 */ public boolean equals(int w, int h) { return width == w && height == h; } /** * Returns whether the input Object is equivalent to this Dimension. * true if the Object is a Dimension and its width and height * are equal to this Dimension's width and height, false * otherwise. * * @param o * the Object being tested for equality * @return true if the given object is equal to this dimension * @since 2.0 */ public boolean equals(Object o) { if (o instanceof Dimension) { Dimension d = (Dimension) o; return (d.width() == width && d.height() == height); } return false; } /** * Expands the size of this Dimension by the specified amount. * * @param d * the Dimension providing the expansion width and height * @return this for convenience * @since 2.0 */ public Dimension expand(Dimension d) { return expand(d.width(), d.height()); } /** * Expands the size of this Dimension by the specified width and height. * * @param w * Value by which the width should be increased * @param h * Value by which the height should be increased * @return this for convenience * @since 2.0 */ public Dimension expand(int w, int h) { width += w; height += h; return this; } /** * Expands the size of this Dimension by the specified amound. * * @param p * the Point supplying the dimensional values * @return this for convenience * @since 2.0 * @deprecated Use {@link #expand(int, int)} instead. */ public Dimension expand(Point p) { return expand(p.x(), p.y()); } /** * Returns the area of this Dimension. * * @return the area * @since 2.0 */ public int getArea() { return width * height; } /** * Creates and returns a copy of this Dimension. * * @return a copy of this Dimension * @since 2.0 */ public Dimension getCopy() { return new Dimension(this); } /** * Creates and returns a new Dimension representing the difference between * this Dimension and the one specified. * * @param d * the dimension being compared * @return a new dimension representing the difference * @since 2.0 * @deprecated Use {@link #getShrinked(Dimension)} instead. */ public Dimension getDifference(Dimension d) { return getShrinked(d); } /** * Creates and returns a Dimension representing the sum of this Dimension * and the one specified. * * @param d * the dimension providing the expansion width and height * @return a new dimension expanded by d * @since 2.0 */ public Dimension getExpanded(Dimension d) { return getCopy().expand(d); } /** * Creates and returns a new Dimension representing the sum of this * Dimension and the one specified. * * @param w * value by which the width of this is to be expanded * @param h * value by which the height of this is to be expanded * @return a new Dimension expanded by the given values * @since 2.0 */ public Dimension getExpanded(int w, int h) { return getCopy().expand(w, h); } /** * Creates and returns a new Dimension representing the intersection of this * Dimension and the one specified. * * @param d * the Dimension to intersect with * @return A new Dimension representing the intersection * @since 2.0 */ public Dimension getIntersected(Dimension d) { return getCopy().intersect(d); } /** * Creates and returns a new Dimension with negated values. * * @return a new Dimension with negated values * @since 2.0 */ public Dimension getNegated() { return getCopy().negate(); } /** * Creates a new Dimension with its width and height scaled by the specified * value. * * @param amount * Value by which the width and height are scaled * @return a new dimension with the scale applied * @since 2.0 */ public Dimension getScaled(double amount) { return getCopy().scale(amount); } /** * Creates and returns a new Dimension whose size will be reduced by the * width and height of the given Dimension. * * @param d * the dimension whose width and height values will be considered * @return a new dimension representing the difference * @since 3.7 */ public Dimension getShrinked(Dimension d) { return getCopy().shrink(d); } /** * Creates and returns a new Dimension whose size will be reduced by the * width and height of the given Dimension. * * @param w * the value by which the width is to be reduced * @param h * the value by which the height is to be reduced * @return a new dimension representing the difference * @since 3.7 */ public Dimension getShrinked(int w, int h) { return getCopy().shrink(w, h); } /** * Creates a new Dimension with its height and width swapped. Useful in * orientation change calculations. * * @return a new Dimension with its height and width swapped * @since 2.0 */ public Dimension getTransposed() { return getCopy().transpose(); } /** * Creates a new Dimension representing the union of this Dimension with the * one specified. Union is defined as the max() of the values from each * Dimension. * * @param d * the Dimension to be unioned * @return a new Dimension * @since 2.0 */ public Dimension getUnioned(Dimension d) { return getCopy().union(d); } /** * @see java.lang.Object#hashCode() */ public int hashCode() { return (width * height) ^ (width + height); } /** * Returns the height of this dimension. * * @return The current height * @since 3.7 */ public int height() { return height; } /** * This Dimension is intersected with the one specified. Intersection is * performed by taking the min() of the values from each dimension. * * @param d * the Dimension used to perform the min() * @return this for convenience * @since 2.0 */ public Dimension intersect(Dimension d) { width = Math.min(d.width(), width); height = Math.min(d.height(), height); return this; } /** * Returns true if either dimension is less than or equal to 0. * * @return true if either dimension is less than or equal to 0. * @since 2.0 */ public boolean isEmpty() { return (width <= 0) || (height <= 0); } /** * Negates the width and height of this Dimension. * * @return this for convenience * @since 2.0 */ public Dimension negate() { return scale(-1); } /** * @see org.eclipse.draw2d.geometry.Translatable#performScale(double) */ public void performScale(double factor) { scale(factor); } /** * @see org.eclipse.draw2d.geometry.Translatable#performTranslate(int, int) */ public void performTranslate(int dx, int dy) { // FIXME: actually Dimension are not translatable. Remove this // method as soon as bug #307276 is resolved. } /** * Returns double height * * @return double height * @since 3.4 */ public double preciseHeight() { return height; } /** * Returns double width * * @return double width * @since 3.4 */ public double preciseWidth() { return width; } /** * Scales the width and height of this Dimension by the amount supplied, and * returns this for convenience. * * @param factor * value by which this Dimension's width and height are to be * scaled * @return this for convenience * @since 2.0 */ public Dimension scale(double factor) { return scale(factor, factor); } /** * Scales the width of this Dimension by w and scales the height of * this Dimension by h. Returns this for convenience. * * @param widthFactor * the value by which the width is to be scaled * @param heightFactor * the value by which the height is to be scaled * @return this for convenience * @since 2.0 */ public Dimension scale(double widthFactor, double heightFactor) { width = (int) (Math.floor(width * widthFactor)); height = (int) (Math.floor(height * heightFactor)); return this; } /** * Sets the height of this Rectangle to the specified one. * * @param height * The new height * @return this for convenience * @since 3.7 */ public Dimension setHeight(int height) { this.height = height; return this; } /** * Copies the width and height values of the input Dimension to this * Dimension. * * @param d * the dimension supplying the values * @since 2.0 */ public void setSize(Dimension d) { // TODO: This should for the sake of consistency also return this // by convenience; however, this is regarded as API break so it // may be done not sooner than in 4.0; if this is done, it has // to be ensured that the overwritten method in PrecisionDimension // is adjusted as well. width = d.width(); height = d.height(); } /** * Sets the size of this dimension to the specified width and height. * * @param w * The new width * @param h * The new height * @since 3.7 */ public Dimension setSize(int w, int h) { width = w; height = h; return this; } /** * Sets the width of this Rectangle to the specified one. * * @param width * The new width * @return this for convenience * @since 3.7 */ public Dimension setWidth(int width) { this.width = width; return this; } /** * Shrinks the size of this Dimension by the width and height values of the * given Dimension. * * @param d * The dimension whose width and height values are to be used * @return this for convenience * @since 3.7 */ public Dimension shrink(Dimension d) { return shrink(d.width(), d.height()); } /** * Reduces the width of this Dimension by w, and reduces the height * of this Dimension by h. Returns this for convenience. * * @param w * the value by which the width is to be reduced * @param h * the value by which the height is to be reduced * @return this for convenience * @since 2.0 */ public Dimension shrink(int w, int h) { width -= w; height -= h; return this; } /** * @see Object#toString() */ public String toString() { return "Dimension(" + //$NON-NLS-1$ width + ", " + //$NON-NLS-1$ height + ")"; //$NON-NLS-1$ } /** * Swaps the width and height of this Dimension, and returns this for * convenience. Can be useful in orientation changes. * * @return this for convenience * @since 2.0 */ public Dimension transpose() { int temp = width; width = height; height = temp; return this; } /** * Sets the width of this Dimension to the greater of this Dimension's width * and d.width. Likewise for this Dimension's height. * * @param d * the Dimension to union with this Dimension * @return this for convenience * @since 2.0 */ public Dimension union(Dimension d) { width = Math.max(width, d.width()); height = Math.max(height, d.height()); return this; } /** * Returns the width of this dimension * * @return the current width of this dimension * @since 3.7 */ public int width() { return width; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/geometry/Geometry.java000066400000000000000000000166211166301720600277670ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2005, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation * Alexander Shatalin (Borland) - Contribution for Bug 238874 *******************************************************************************/ package org.eclipse.draw2d.geometry; /** * A Utilities class for geometry operations. * * @author Pratik Shah * @author Alexander Nyssen * @since 3.1 */ public class Geometry { /** * Determines whether the two line segments p1->p2 and p3->p4, given by * p1=(x1, y1), p2=(x2,y2), p3=(x3,y3), p4=(x4,y4) intersect. Two line * segments are regarded to be intersecting in case they share at least one * common point, i.e if one of the two line segments starts or ends on the * other line segment or the line segments are collinear and overlapping, * then they are as well considered to be intersecting. * * @param x1 * x coordinate of starting point of line segment 1 * @param y1 * y coordinate of starting point of line segment 1 * @param x2 * x coordinate of ending point of line segment 1 * @param y2 * y coordinate of ending point of line segment 1 * @param x3 * x coordinate of the starting point of line segment 2 * @param y3 * y coordinate of the starting point of line segment 2 * @param x4 * x coordinate of the ending point of line segment 2 * @param y4 * y coordinate of the ending point of line segment 2 * * @return true if the two line segments formed by the given * coordinates share at least one common point. * * @since 3.1 */ public static boolean linesIntersect(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) { // calculate bounding box of segment p1->p2 int bb1_x = Math.min(x1, x2); int bb1_y = Math.min(y1, y2); int bb2_x = Math.max(x1, x2); int bb2_y = Math.max(y1, y2); // calculate bounding box of segment p3->p4 int bb3_x = Math.min(x3, x4); int bb3_y = Math.min(y3, y4); int bb4_x = Math.max(x3, x4); int bb4_y = Math.max(y3, y4); // check if bounding boxes intersect if (!(bb2_x >= bb3_x && bb4_x >= bb1_x && bb2_y >= bb3_y && bb4_y >= bb1_y)) { // if bounding boxes do not intersect, line segments cannot // intersect either return false; } // If p3->p4 is inside the triangle p1-p2-p3, then check whether the // line p1->p2 crosses the line p3->p4. long p1p3_x = (long) x1 - x3; long p1p3_y = (long) y1 - y3; long p2p3_x = (long) x2 - x3; long p2p3_y = (long) y2 - y3; long p3p4_x = (long) x3 - x4; long p3p4_y = (long) y3 - y4; if (productSign(crossProduct(p2p3_x, p2p3_y, p3p4_x, p3p4_y), crossProduct(p3p4_x, p3p4_y, p1p3_x, p1p3_y)) >= 0) { long p2p1_x = (long) x2 - x1; long p2p1_y = (long) y2 - y1; long p1p4_x = (long) x1 - x4; long p1p4_y = (long) y1 - y4; return productSign(crossProduct(-p1p3_x, -p1p3_y, p2p1_x, p2p1_y), crossProduct(p2p1_x, p2p1_y, p1p4_x, p1p4_y)) <= 0; } return false; } private static int productSign(long x, long y) { if (x == 0 || y == 0) { return 0; } else if (x < 0 ^ y < 0) { return -1; } return 1; } private static long crossProduct(long x1, long y1, long x2, long y2) { return x1 * y2 - x2 * y1; } /** * @see PointList#polylineContainsPoint(int, int, int) * @since 3.5 */ public static boolean polylineContainsPoint(PointList points, int x, int y, int tolerance) { int coordinates[] = points.toIntArray(); /* * For each segment of PolyLine calling isSegmentPoint */ for (int index = 0; index < coordinates.length - 3; index += 2) { if (segmentContainsPoint(coordinates[index], coordinates[index + 1], coordinates[index + 2], coordinates[index + 3], x, y, tolerance)) { return true; } } return false; } /** * @return true if the least distance between point (px,py) and segment * (x1,y1) - (x2,y2) is less then specified tolerance */ private static boolean segmentContainsPoint(int x1, int y1, int x2, int y2, int px, int py, int tolerance) { /* * Point should be located inside Rectangle(x1 -+ tolerance, y1 -+ * tolerance, x2 +- tolerance, y2 +- tolerance) */ Rectangle lineBounds = Rectangle.SINGLETON; lineBounds.setSize(0, 0); lineBounds.setLocation(x1, y1); lineBounds.union(x2, y2); lineBounds.expand(tolerance, tolerance); if (!lineBounds.contains(px, py)) { return false; } /* * If this is horizontal, vertical line or dot then the distance between * specified point and segment is not more then tolerance (due to the * lineBounds check above) */ if (x1 == x2 || y1 == y2) { return true; } /* * Calculating square distance from specified point to this segment * using formula for Dot product of two vectors. */ long v1x = x2 - x1; long v1y = y2 - y1; long v2x = px - x1; long v2y = py - y1; long numerator = v2x * v1y - v1x * v2y; long denominator = v1x * v1x + v1y * v1y; long squareDistance = numerator * numerator / denominator; return squareDistance <= tolerance * tolerance; } /** * One simple way of finding whether the point is inside or outside a simple * polygon is to test how many times a ray starting from the point * intersects the edges of the polygon. If the point in question is not on * the boundary of the polygon, the number of intersections is an even * number if the point is outside, and it is odd if inside. * * @see PointList#polygonContainsPoint(int, int) * @since 3.5 */ public static boolean polygonContainsPoint(PointList points, int x, int y) { boolean isOdd = false; int coordinates[] = points.toIntArray(); int n = coordinates.length; if (n > 3) { // If there are at least 2 Points (4 ints) int x1, y1; int x0 = coordinates[n - 2]; int y0 = coordinates[n - 1]; for (int i = 0; i < n; x0 = x1, y0 = y1) { x1 = coordinates[i++]; y1 = coordinates[i++]; if (!segmentContaintPoint(y0, y1, y)) { // Current edge has no intersection with the point by Y // coordinates continue; } int crossProduct = crossProduct(x1, y1, x0, y0, x, y); if (crossProduct == 0) { // cross product == 0 only if this point is on the line // containing selected edge if (segmentContaintPoint(x0, x1, x)) { // This point is on the edge return true; } // This point is outside the edge - simply skipping possible // intersection (no parity changes) } else if ((y0 <= y && y < y1 && crossProduct > 0) || (y1 <= y && y < y0 && crossProduct < 0)) { // has intersection isOdd = !isOdd; } } return isOdd; } return false; } /** * @return true if segment with two ends x0, x1 contains point x */ private static boolean segmentContaintPoint(int x0, int x1, int x) { return !((x < x0 && x < x1) || (x > x0 && x > x1)); } /** * Calculating cross product of two vectors: 1. [ax - cx, ay - cx] 2. [bx - * cx, by - cy] */ private static int crossProduct(int ax, int ay, int bx, int by, int cx, int cy) { return (ax - cx) * (by - cy) - (ay - cy) * (bx - cx); } }eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/geometry/Insets.java000066400000000000000000000112201166301720600274270ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.geometry; /** * Stores four integers for top, left, bottom, and right measurements. */ public class Insets implements Cloneable, java.io.Serializable { private static final long serialVersionUID = 1L; /** distance from left */ public int left; /** distance from top */ public int top; /** distance from bottom */ public int bottom; /** distance from right */ public int right; /** * Constructs an Insets with all zeroes. * * @since 2.0 */ public Insets() { } /** * Constructs a new Insets with initial values the same as the provided * Insets. * * @param i * The insets to copy. * @since 2.0 */ public Insets(Insets i) { this(i.top, i.left, i.bottom, i.right); } /** * Constructs a new Insets with all the sides set to the speicifed value. * * @param i * Value applied to all sides of new Insets. * @since 2.0 */ public Insets(int i) { this(i, i, i, i); } /** * Creates a new Insets with the specified top, left, bottom, and right * values. * * @param top * Value of the top space. * @param left * Value of the left space. * @param bottom * Value of the bottom space. * @param right * Value of the right space. * @since 2.0 */ public Insets(int top, int left, int bottom, int right) { this.top = top; this.left = left; this.bottom = bottom; this.right = right; } /** * Adds the values of the specified Insets to this Insets' values. * * @return this for convenience * @param insets * the Insets being added * @since 2.0 */ public Insets add(Insets insets) { top += insets.top; bottom += insets.bottom; left += insets.left; right += insets.right; return this; } /** * Test for equality. The Insets are equal if their top, left, bottom, and * right values are equivalent. * * @param o * Object being tested for equality. * @return true if all values are the same. * @since 2.0 */ public boolean equals(Object o) { if (o instanceof Insets) { Insets i = (Insets) o; return i.top == top && i.bottom == bottom && i.left == left && i.right == right; } return false; } /** * Creates an Insets representing the sum of this Insets with the specified * Insets. * * @param insets * Insets to be added * @return A new Insets * @since 2.0 */ public Insets getAdded(Insets insets) { return new Insets(this).add(insets); } /** * Returns the height for this Insets, equal to top + * bottom. * * @return The sum of top + bottom * @see #getWidth() * @since 2.0 */ public int getHeight() { return top + bottom; } /** * Creates a new Insets with transposed values. Top and Left are transposed. * Bottom and Right are transposed. * * @return New Insets with the transposed values. * @since 2.0 */ public Insets getTransposed() { return new Insets(this).transpose(); } /** * Returns the width for this Insets, equal to left + * right. * * @return The sum of left + right * @see #getHeight() * @since 2.0 */ public int getWidth() { return left + right; } /** * @see java.lang.Object#hashCode() */ public int hashCode() { return top * 7 + left * 2 + bottom * 31 + right * 37; } /** * Returns true if all values are 0. * * @return true if all values are 0 * @since 2.0 */ public boolean isEmpty() { return (left == 0 && right == 0 && top == 0 && bottom == 0); } /** * @return String representation. * @since 2.0 */ public String toString() { return "Insets(t=" + top + ", l=" + left + //$NON-NLS-2$//$NON-NLS-1$ ", b=" + bottom + ", r=" + right + ")";//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$ } /** * Transposes this object. Top and Left are exchanged. Bottom and Right are * exchanged. Can be used in orientation changes. * * @return this for convenience * @since 2.0 */ public Insets transpose() { int temp = top; top = left; left = temp; temp = right; right = bottom; bottom = temp; return this; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/geometry/Point.java000066400000000000000000000274211166301720600272650ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.geometry; import org.eclipse.draw2d.PositionConstants; /** * Represents a point (x, y) in 2-dimensional space. This class provides various * methods for manipulating this Point or creating new derived geometrical * Objects. */ public class Point implements Cloneable, java.io.Serializable, Translatable { private static final long serialVersionUID = 1L; /** * A singleton for use in short calculations */ public static final Point SINGLETON = new Point(); /** * Creates a new Point representing the MAX of two provided Points. * * @param p1 * first point * @param p2 * second point * @return A new Point representing the Max() */ public static Point max(Point p1, Point p2) { return new Rectangle(p1, p2).getBottomRight().translate(-1, -1); } /** * Creates a new Point representing the MIN of two provided Points. * * @param p1 * first point * @param p2 * second point * @return A new Point representing the Min() */ public static Point min(Point p1, Point p2) { return new Rectangle(p1, p2).getTopLeft(); } /** * x value */ public int x; /** * y value */ public int y; /** * Constructs a Point at location (0,0). * * @since 2.0 */ public Point() { } /** * Constructs a Point at the specified x and y locations. * * @param x * x value * @param y * y value * @since 2.0 * @deprecated Use {@link PrecisionPoint} or {@link #Point(int, int)} * instead. */ public Point(double x, double y) { this.x = (int) x; this.y = (int) y; } /** * Constructs a Point at the specified x and y locations. * * @param x * x value * @param y * y value * @since 2.0 */ public Point(int x, int y) { this.x = x; this.y = y; } /** * Constructs a Point at the same location as the given SWT Point. * * @param p * Point from which the initial values are taken. * @since 2.0 */ public Point(org.eclipse.swt.graphics.Point p) { x = p.x; y = p.y; } /** * Constructs a Point at the same location as the given Point. * * @param p * Point from which the initial values are taken. * @since 2.0 */ public Point(Point p) { x = p.x(); y = p.y(); } /** * Returns true if this Points x and y are equal to the given x * and y. * * @param x * the x value * @param y * the y value * @return true if this point's x and y are equal to those * given. * @since 3.7 */ public boolean equals(int x, int y) { return this.x == x && this.y == y; } /** * Test for equality. * * @param o * Object being tested for equality * @return true if both x and y values are equal * @since 2.0 */ public boolean equals(Object o) { if (o instanceof Point) { Point p = (Point) o; return p.x() == x && p.y() == y; } return false; } /** * @return a copy of this Point * @since 2.0 */ public Point getCopy() { return new Point(this); } /** * Calculates the difference in between this Point and the one specified. * * @param p * The Point being subtracted from this Point * @return A new Dimension representing the difference * @since 2.0 */ public Dimension getDifference(Point p) { return new Dimension(this.x - p.x(), this.y - p.y()); } /** * Calculates the distance from this Point to the one specified. * * @param p * The Point being compared to this * @return The distance * @since 2.0 */ public double getDistance(Point p) { double i = p.preciseX() - preciseX(); double j = p.preciseY() - preciseY(); return Math.sqrt(i * i + j * j); } /** * Calculates the distance squared between this Point and the one specified. * If the distance squared is larger than the maximum integer value, then * Integer.MAX_VALUE will be returned. * * @param p * The reference Point * @return distance2 * @since 2.0 * @deprecated Use {@link #getDistance(Point)} and square the result * instead. */ public int getDistance2(Point p) { long i = p.x() - x; long j = p.y() - y; long result = i * i + j * j; if (result > Integer.MAX_VALUE) return Integer.MAX_VALUE; return (int) result; } /** * Calculates the orthogonal distance to the specified point. The orthogonal * distance is the sum of the horizontal and vertical differences. * * @param p * The reference Point * @return the orthogonal distance * @deprecated May not be guaranteed by precision subclasses and should thus * not be used any more. */ public int getDistanceOrthogonal(Point p) { return Math.abs(y - p.y()) + Math.abs(x - p.x()); } /** * Creates a Point with negated x and y values. * * @return A new Point * @since 2.0 */ public Point getNegated() { return getCopy().negate(); } /** * Calculates the relative position of the specified Point to this Point. * * @param p * The reference Point * @return NORTH, SOUTH, EAST, or WEST, as defined in * {@link PositionConstants} */ public int getPosition(Point p) { int dx = p.x() - x; int dy = p.y() - y; if (Math.abs(dx) > Math.abs(dy)) { if (dx < 0) return PositionConstants.WEST; return PositionConstants.EAST; } if (dy < 0) return PositionConstants.NORTH; return PositionConstants.SOUTH; } /** * Creates a new Point from this Point by scaling by the specified amount. * * @param factor * scale factor * @return A new Point * @since 2.0 */ public Point getScaled(double factor) { return getCopy().scale(factor); } /** * Creates a new SWT {@link org.eclipse.swt.graphics.Point Point} from this * Point. * * @return A new SWT Point * @since 2.0 */ public org.eclipse.swt.graphics.Point getSWTPoint() { return new org.eclipse.swt.graphics.Point(x, y); } /** * Creates a new Point which is translated by the values of the input * Dimension. * * @param d * Dimension which provides the translation amounts. * @return A new Point * @since 2.0 */ public Point getTranslated(Dimension d) { return getCopy().translate(d); } /** * Creates a new Point which is translated by the specified x and y values * * @param x * horizontal component * @param y * vertical component * @return A new Point * @since 2.0 */ public Point getTranslated(int x, int y) { return getCopy().translate(x, y); } /** * Creates a new Point which is translated by the values of the provided * Point. * * @param p * Point which provides the translation amounts. * @return A new Point * @since 2.0 */ public Point getTranslated(Point p) { return getCopy().translate(p); } /** * Creates a new Point with the transposed values of this Point. Can be * useful in orientation change calculations. * * @return A new Point * @since 2.0 */ public Point getTransposed() { return getCopy().transpose(); } /** * @see java.lang.Object#hashCode() */ public int hashCode() { return (x * y) ^ (x + y); } /** * Negates the x and y values of this Point. * * @return this for convenience * @since 2.0 */ public Point negate() { x = -x; y = -y; return this; } /** @see Translatable#performScale(double) */ public void performScale(double factor) { scale(factor); } /** @see Translatable#performTranslate(int, int) */ public void performTranslate(int dx, int dy) { translate(dx, dy); } /** * Returns double x coordinate * * @return double x coordinate * @since 3.4 */ public double preciseX() { return x; } /** * Returns double y coordinate * * @return double y coordinate * @since 3.4 */ public double preciseY() { return y; } /** * Scales this Point by the specified amount. * * @return this for convenience * @param factor * scale factor * @since 2.0 */ public Point scale(double factor) { return scale(factor, factor); } /** * Scales this Point by the specified values. * * @param xFactor * horizontal scale factor * @param yFactor * vertical scale factor * @return this for convenience * @since 2.0 */ public Point scale(double xFactor, double yFactor) { x = (int) Math.floor(x * xFactor); y = (int) Math.floor(y * yFactor); return this; } /** * Sets the location of this Point to the provided x and y locations. * * @return this for convenience * @param x * the x location * @param y * the y location * @since 2.0 */ public Point setLocation(int x, int y) { this.x = x; this.y = y; return this; } /** * Sets the location of this Point to the specified Point. * * @return this for convenience * @param p * the Location * @since 2.0 */ public Point setLocation(Point p) { x = p.x(); y = p.y(); return this; } /** * Sets the x value of this Point to the given value. * * @param x * The new x value * @return this for convenience * @since 3.7 */ public Point setX(int x) { this.x = x; return this; } /** * Sets the y value of this Point to the given value; * * @param y * The new y value * @return this for convenience * @since 3.7 */ public Point setY(int y) { this.y = y; return this; } /** * @return String representation. * @since 2.0 */ public String toString() { return "Point(" + x + ", " + y + ")";//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$ } /** * Shifts this Point by the values of the Dimension along each axis, and * returns this for convenience. * * @param d * Dimension by which the origin is being shifted. * @return this for convenience * @since 2.0 */ public Point translate(Dimension d) { return translate(d.width(), d.height()); } /** * Shifts this Point by the values supplied along each axes, and returns * this for convenience. * * @param dx * Amount by which point is shifted along X axis. * @param dy * Amount by which point is shifted along Y axis. * @return this for convenience * @since 2.0 */ public Point translate(int dx, int dy) { x += dx; y += dy; return this; } /** * Shifts the location of this Point by the location of the input Point * along each of the axes, and returns this for convenience. * * @param p * Point to which the origin is being shifted. * @return this for convenience * @since 2.0 */ public Point translate(Point p) { return translate(p.x(), p.y()); } /** * Transposes this object. X and Y values are exchanged. * * @return this for convenience * @since 2.0 */ public Point transpose() { int temp = x; x = y; y = temp; return this; } /** * Returns the x value of this Point. * * @return The current x value * @since 3.7 */ public int x() { return x; } /** * Returns the y value of this Point. * * @return The current y value * @since 3.7 */ public int y() { return y; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/geometry/PointList.java000066400000000000000000000320771166301720600301240ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation * Alexander Shatalin (Borland) - Contribution for Bug 238874 *******************************************************************************/ package org.eclipse.draw2d.geometry; /** * Represents a List of Points. This class is used for building an * int[]. The array is internal, and is constructed and queried by * the client using {@link Point Points}. SWT uses integer arrays when painting * polylines and polygons. */ public class PointList implements java.io.Serializable, Translatable { private int[] points = new int[0]; private Rectangle bounds; private int size = 0; static final long serialVersionUID = 1; /** * Constructs an empty PointList. * * @since 2.0 */ public PointList() { } /** * Constructs a PointList with the given points. * * @param points * int array where two consecutive ints form the coordinates of a * point * @since 3.1 */ public PointList(int points[]) { this.points = points; this.size = points.length / 2; } /** * Constructs a PointList with initial capacity size, but no points. * * @param size * Number of points to hold. * @since 2.0 */ public PointList(int size) { points = new int[size * 2]; } /** * Appends all of the given points to this PointList. * * @param source * the source pointlist */ public void addAll(PointList source) { ensureCapacity(size + source.size); System.arraycopy(source.points, 0, points, size * 2, source.size * 2); size += source.size; } /** * Adds Point p to this PointList. * * @param p * the point to be added * @see #removePoint(int) * @since 2.0 */ public void addPoint(Point p) { addPoint(p.x, p.y); } /** * Adds the input point values to this PointList. * * @param x * X value of a point to add * @param y * Y value of a point to add * @since 2.0 */ public void addPoint(int x, int y) { bounds = null; int index = size * 2; ensureCapacity(size + 1); points[index] = x; points[index + 1] = y; size++; } private void ensureCapacity(int newSize) { newSize *= 2; if (points.length < newSize) { int old[] = points; points = new int[Math.max(newSize, size * 4)]; System.arraycopy(old, 0, points, 0, size * 2); } } /** * Returns the smallest Rectangle which contains all Points. * * @return The smallest Rectangle which contains all Points. * @since 2.0 */ public Rectangle getBounds() { if (bounds != null) return bounds; bounds = new Rectangle(); if (size > 0) { bounds.setLocation(getPoint(0)); for (int i = 0; i < size; i++) bounds.union(getPoint(i)); } return bounds; } /** * Creates a copy * * @return PointList A copy of this PointList */ public PointList getCopy() { PointList result = new PointList(size); System.arraycopy(points, 0, result.points, 0, size * 2); result.size = size; result.bounds = null; return result; } /** * Returns the first Point in the list. * * @return The first point in the list. * @throws IndexOutOfBoundsException * if the list is empty * @since 2.0 */ public Point getFirstPoint() { return getPoint(0); } /** * Returns the last point in the list. * * @throws IndexOutOfBoundsException * if the list is empty * @return The last Point in the list * @since 2.0 */ public Point getLastPoint() { return getPoint(size - 1); } /** * Returns the midpoint of the list of Points. The midpoint is the median of * the List, unless there are 2 medians (size is even), then the middle of * the medians is returned. * * @return The midpoint * @throws IndexOutOfBoundsException * if the list is empty */ public Point getMidpoint() { if (size() % 2 == 0) return getPoint(size() / 2 - 1).getTranslated(getPoint(size() / 2)) .scale(0.5f); return getPoint(size() / 2); } /** * Returns the Point in the list at the specified index. * * @param index * Index of the desired Point * @return The requested Point * @throws IndexOutOfBoundsException * If the specified index is out of range * @since 2.0 */ public Point getPoint(int index) { if (index < 0 || index >= size) throw new IndexOutOfBoundsException("Index: " + index + //$NON-NLS-1$ ", Size: " + size); //$NON-NLS-1$ index *= 2; return new Point(points[index], points[index + 1]); } /** * Copies the x and y values at given index into a specified Point. This * method exists to avoid the creation of a new Point. * * @see #getPoint(int) * @param p * The Point which will be set with the <x, y> values * @param index * The index being requested * @return The parameter p is returned for convenience * @since 2.0 */ public Point getPoint(Point p, int index) { if (index < 0 || index >= size) throw new IndexOutOfBoundsException("Index: " + index + //$NON-NLS-1$ ", Size: " + size); //$NON-NLS-1$ index *= 2; p.x = points[index]; p.y = points[index + 1]; return p; } /** * Inserts a given point at a specified index. * * @param p * Point to be inserted. * @param index * Position where the point is to be inserted. * @exception IndexOutOfBoundsException * if the index is invalid * @see #setPoint(Point, int) * @since 2.0 */ public void insertPoint(Point p, int index) { if (bounds != null && !bounds.contains(p)) bounds = null; if (index > size || index < 0) throw new IndexOutOfBoundsException("Index: " + index + //$NON-NLS-1$ ", Size: " + size); //$NON-NLS-1$ index *= 2; int length = points.length; int old[] = points; points = new int[length + 2]; System.arraycopy(old, 0, points, 0, index); System.arraycopy(old, index, points, index + 2, length - index); points[index] = p.x; points[index + 1] = p.y; size++; } /** * Determines whether any of the line segments represented by this PointList * intersect the given Rectangle. If a segment touches the given rectangle, * that's considered intersection. * * @param r * the rectangle * @return true if the given rectangle intersects any of the * line segments represented by this PointList * @since 3.1 */ public boolean intersects(Rectangle r) { if (r.isEmpty()) return false; for (int i = 0; i < size * 2; i += 2) { if (r.contains(points[i], points[i + 1])) return true; } int diagonal1x1 = r.x, diagonal1y1 = r.y, diagonal1x2 = r.x + r.width - 1, diagonal1y2 = r.y + r.height - 1, diagonal2x1 = r.x + r.width - 1, diagonal2y1 = r.y, diagonal2x2 = r.x, diagonal2y2 = r.y + r.height - 1; for (int i = 0; i < (size - 1) * 2; i += 2) { if (Geometry.linesIntersect(diagonal1x1, diagonal1y1, diagonal1x2, diagonal1y2, points[i], points[i + 1], points[i + 2], points[i + 3]) || Geometry.linesIntersect(diagonal2x1, diagonal2y1, diagonal2x2, diagonal2y2, points[i], points[i + 1], points[i + 2], points[i + 3])) return true; } return false; } /** * @see org.eclipse.draw2d.geometry.Translatable#performScale(double) */ public void performScale(double factor) { for (int i = 0; i < points.length; i++) points[i] = (int) Math.floor(points[i] * factor); bounds = null; } /** * @see org.eclipse.draw2d.geometry.Translatable#performTranslate(int, int) */ public void performTranslate(int dx, int dy) { for (int i = 0; i < size * 2; i += 2) { points[i] += dx; points[i + 1] += dy; } if (bounds != null) bounds.translate(dx, dy); } /** * Removes all the points stored by this list. Resets all the properties * based on the point information. * * @since 2.0 */ public void removeAllPoints() { bounds = null; size = 0; } /** * Removes the point at the specified index from the PointList, and returns * it. * * @since 2.0 * @see #addPoint(Point) * @param index * Index of the point to be removed. * @return The point which has been removed * @throws IndexOutOfBoundsException * if the removal index is beyond the list capacity */ public Point removePoint(int index) { bounds = null; if (index < 0 || index >= size) throw new IndexOutOfBoundsException("Index: " + index + //$NON-NLS-1$ ", Size: " + size); //$NON-NLS-1$ index *= 2; Point pt = new Point(points[index], points[index + 1]); if (index != size * 2 - 2) System.arraycopy(points, index + 2, points, index, size * 2 - index - 2); size--; return pt; } /** * Reverses the order of the points in the list. * * @since 3.2 */ public void reverse() { int temp; for (int i = 0, j = size * 2 - 2; i < size; i += 2, j -= 2) { temp = points[i]; points[i] = points[j]; points[j] = temp; temp = points[i + 1]; points[i + 1] = points[j + 1]; points[j + 1] = temp; } } /** * Overwrites a point at a given index in the list with the specified Point. * * @param pt * Point which is to be stored at the index. * @param index * Index where the given point is to be stored. * @since 2.0 */ public void setPoint(Point pt, int index) { if (index < 0 || index >= size) throw new IndexOutOfBoundsException("Index: " + index + //$NON-NLS-1$ ", Size: " + size); //$NON-NLS-1$ if (bounds != null && !bounds.contains(pt)) bounds = null; points[index * 2] = pt.x; points[index * 2 + 1] = pt.y; } /** * Sets the size of this PointList. * * @param newSize * the new size */ public void setSize(int newSize) { if (points.length > newSize * 2) { size = newSize; return; } int[] newArray = new int[newSize * 2]; System.arraycopy(points, 0, newArray, 0, points.length); points = newArray; size = newSize; } /** * Returns the number of points in this PointList. * * @return The number of points * @since 2.0 */ public int size() { return size; } /** * Returns the contents of this PointList as an integer array. The returned * array is by reference. Any changes made to the array will also be * changing the original PointList. * * @return the integer array of points by reference * @since 2.0 */ public int[] toIntArray() { if (points.length != size * 2) { int[] old = points; points = new int[size * 2]; System.arraycopy(old, 0, points, 0, size * 2); } return points; } /** * Moves the origin (0,0) of the coordinate system of all the points to the * Point pt. This updates the position of all the points in this * PointList. * * @param pt * Position by which all the points will be shifted. * @see #translate(int,int) * @since 2.0 */ public final void translate(Point pt) { translate(pt.x, pt.y); } /** * Moves the origin (0,0) of the coordinate system of all the points to the * Point (x,y). This updates the position of all the points in this * PointList. * * @param x * Amount by which all the points will be shifted on the X axis. * @param y * Amount by which all the points will be shifted on the Y axis. * @see #translate(Point) * @since 2.0 */ public void translate(int x, int y) { if (x == 0 && y == 0) return; if (bounds != null) bounds.translate(x, y); for (int i = 0; i < size * 2; i += 2) { points[i] += x; points[i + 1] += y; } } /** * Transposes all x and y values. Useful for orientation changes. * * @since 3.2 */ public void transpose() { int temp; if (bounds != null) bounds.transpose(); for (int i = 0; i < size * 2; i += 2) { temp = points[i]; points[i] = points[i + 1]; points[i + 1] = temp; } } /** * @param x * - X coordinate of the point * @param y * - Y coordinate of the point * * @return true if specified point belongs to the polygon drawn using this * PointList * @see Geometry#polygonContainsPoint(PointList, int, int) * @since 3.5 */ public boolean polygonContainsPoint(int x, int y) { return Geometry.polygonContainsPoint(this, x, y); } /** * @param x * - X coordinate of the point * @param y * - Y coordinate of the point * @param tolerance * - allowed distance between point and polyline segment * * @return true if the least distance between specified point and polyline * drawn using this PointList is less then specified tolerance * @see Geometry#polylineContainsPoint(PointList, int, int, int) * @since 3.5 */ public boolean polylineContainsPoint(int x, int y, int tolerance) { return Geometry.polylineContainsPoint(this, x, y, tolerance); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/geometry/PrecisionDimension.java000066400000000000000000000226261166301720600317770ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.geometry; /** * @author Randy Hudson */ public class PrecisionDimension extends Dimension { private static final long serialVersionUID = 1L; /** * The height in double precision. * * @noreference * @deprecated Use {@link #setPreciseHeight(double)} and * {@link #preciseHeight()} instead. This field will become * private in the future. */ public double preciseHeight; /** * The width in double precision. * * @noreference * @deprecated Use {@link #setPreciseWidth(double)} and * {@link #preciseWidth()} instead. This field will become * private in the future. */ public double preciseWidth; /** * Constructs a new precision dimension. */ public PrecisionDimension() { } /** * Constructs a precision representation of the given dimension. * * @param d * the reference dimension */ public PrecisionDimension(Dimension d) { this(d.preciseWidth(), d.preciseHeight()); } /** * Constructs a new precision dimension with the given values. * * @param w * the width * @param h * the height */ public PrecisionDimension(double w, double h) { setPreciseSize(w, h); } /** * @see org.eclipse.draw2d.geometry.Dimension#contains(org.eclipse.draw2d.geometry.Dimension) */ public boolean contains(Dimension d) { return preciseWidth() >= d.preciseWidth() && preciseHeight() >= d.preciseHeight(); } /** * @see org.eclipse.draw2d.geometry.Dimension#containsProper(org.eclipse.draw2d.geometry.Dimension) */ public boolean containsProper(Dimension d) { return preciseWidth() > d.preciseWidth() && preciseHeight() > d.preciseHeight(); } /** * @see org.eclipse.draw2d.geometry.Dimension#equals(java.lang.Object) */ public boolean equals(Object o) { if (o instanceof PrecisionDimension) { PrecisionDimension d = (PrecisionDimension) o; return d.preciseWidth() == preciseWidth() && d.preciseHeight() == preciseHeight(); } return super.equals(o); } /** * @see org.eclipse.draw2d.geometry.Dimension#expand(org.eclipse.draw2d.geometry.Dimension) */ public Dimension expand(Dimension d) { return expandPrecise(d.preciseWidth(), d.preciseHeight()); } /** * @see org.eclipse.draw2d.geometry.Dimension#expand(int, int) */ public Dimension expand(int w, int h) { return expandPrecise(w, h); } /** * Expands the size of this PrecisionDimension by the specified width and * height. * * @param w * Value by which the width should be increased * @param h * Value by which the height should be increased * @return this for convenience * @since 3.7 */ private PrecisionDimension expandPrecise(double w, double h) { setPreciseWidth(preciseWidth() + w); setPreciseHeight(preciseHeight() + h); return this; } /** * @see org.eclipse.draw2d.geometry.Dimension#getCopy() */ public Dimension getCopy() { return getPreciseCopy(); } /** * Returns a precise copy of this. * * @return a precise copy * @since 3.7 */ public PrecisionDimension getPreciseCopy() { PrecisionDimension result = new PrecisionDimension(); result.setPreciseWidth(preciseWidth()); result.setPreciseHeight(preciseHeight()); return result; } /** * @see org.eclipse.draw2d.geometry.Dimension#intersect(org.eclipse.draw2d.geometry.Dimension) */ public Dimension intersect(Dimension d) { setPreciseWidth(Math.min(d.preciseWidth(), preciseWidth())); setPreciseHeight(Math.min(d.preciseHeight(), preciseHeight())); return this; } /** * @see org.eclipse.draw2d.geometry.Dimension#performScale(double) */ public void performScale(double factor) { setPreciseWidth(preciseWidth() * factor); setPreciseHeight(preciseHeight() * factor); } /** * @see org.eclipse.draw2d.geometry.Dimension#preciseHeight() */ public double preciseHeight() { updatePreciseHeightDouble(); return preciseHeight; } /** * @see org.eclipse.draw2d.geometry.Dimension#preciseWidth() */ public double preciseWidth() { updatePreciseWidthDouble(); return preciseWidth; } /** * @see org.eclipse.draw2d.geometry.Dimension#scale(double, double) */ public Dimension scale(double widthFactor, double heightFactor) { setPreciseWidth(preciseWidth() * widthFactor); setPreciseHeight(preciseHeight() * heightFactor); return this; } /** * @see org.eclipse.draw2d.geometry.Dimension#setHeight(int) */ public Dimension setHeight(int h) { return setPreciseHeight(h); } /** * Sets the height. * * @param h * the new height * @return this for convenience * @since 3.7 */ public PrecisionDimension setPreciseHeight(double h) { preciseHeight = h; updateHeightInt(); return this; } /** * Sets the size of this PrecisionDimension to the given width and height. * * @param w * The new width * @param h * The new height * @return this for convenience * @since 3.7 */ public PrecisionDimension setPreciseSize(double w, double h) { setPreciseWidth(w); setPreciseHeight(h); return this; } /** * Sets the size of this Dimension to the width and height of the given one. * * @param d * The PrecisionDimension specifying the new width and height * values. * @return This for convenience * @since 3.7 */ public PrecisionDimension setPreciseSize(PrecisionDimension d) { return setPreciseSize(d.preciseWidth(), d.preciseHeight()); } /** * Sets the width. * * @param w * the new width * @return this for convenience * @since 3.7 */ public PrecisionDimension setPreciseWidth(double w) { preciseWidth = w; updateWidthInt(); return this; } /** * @see org.eclipse.draw2d.geometry.Dimension#setSize(org.eclipse.draw2d.geometry.Dimension) */ public void setSize(Dimension d) { setPreciseSize(d.preciseWidth(), d.preciseHeight()); } /** * @see org.eclipse.draw2d.geometry.Dimension#setSize(int, int) */ public Dimension setSize(int w, int h) { return setPreciseSize(w, h); } /** * @see org.eclipse.draw2d.geometry.Dimension#setWidth(int) */ public Dimension setWidth(int width) { return setPreciseWidth(width); } /** * @see org.eclipse.draw2d.geometry.Dimension#shrink(org.eclipse.draw2d.geometry.Dimension) */ public Dimension shrink(Dimension d) { return shrinkPrecise(d.preciseWidth(), d.preciseHeight()); } /** * @see org.eclipse.draw2d.geometry.Dimension#shrink(int, int) */ public Dimension shrink(int w, int h) { return shrinkPrecise(w, h); } /** * Reduces the width of this Dimension by w, and reduces the height * of this Dimension by h. Returns this for convenience. * * @param w * the value by which the width is to be reduced * @param h * the value by which the height is to be reduced * @return this for convenience * @since 3.7 */ private PrecisionDimension shrinkPrecise(double w, double h) { setPreciseWidth(preciseWidth() - w); setPreciseHeight(preciseHeight() - h); return this; } /** * @see org.eclipse.draw2d.geometry.Dimension#transpose() */ public Dimension transpose() { double temp = preciseWidth(); setPreciseWidth(preciseHeight()); setPreciseHeight(temp); return this; } /** * @see org.eclipse.draw2d.geometry.Dimension#union(org.eclipse.draw2d.geometry.Dimension) */ public Dimension union(Dimension d) { setPreciseWidth(Math.max(preciseWidth(), d.preciseWidth())); setPreciseHeight(Math.max(preciseHeight(), d.preciseHeight())); return this; } /** * Updates the height integer field using the value of preciseHeight. */ private final void updateHeightInt() { height = PrecisionGeometry.doubleToInteger(preciseHeight); } /** * Updates the integer fields using the precise versions. * * @deprecated This method should not be accessed by clients any more (it * will be made private in future releases). The update of * integer and precision fields is performed automatically if * {@link #preciseWidth} and {@link #preciseHeight} field values * are not manipulated directly, but only via respective methods * offered by this class. */ public final void updateInts() { updateWidthInt(); updateHeightInt(); } /** * Updates the width integer field using the value of preciseWidth. */ private final void updateWidthInt() { width = PrecisionGeometry.doubleToInteger(preciseWidth); } /** * Updates the preciseWidth double field using the value of width. */ private final void updatePreciseWidthDouble() { if (width != PrecisionGeometry.doubleToInteger(preciseWidth)) { preciseWidth = width; } } /** * Updates the preciseHeight double field using the value of height. */ private final void updatePreciseHeightDouble() { if (height != PrecisionGeometry.doubleToInteger(preciseHeight)) { preciseHeight = height; } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/geometry/PrecisionGeometry.java000066400000000000000000000047661166301720600316520ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.geometry; import java.math.BigDecimal; /** * A Utilities class for precise geometry calculations. * * @author Alexander Nyssen * @since 3.7 */ public class PrecisionGeometry { /* * Precise calculations on doubles are performed based on BigDecimals, * converting to 16 digits scale, so there are no undesired rounding * effects. */ private static final int ROUNDING = BigDecimal.ROUND_HALF_EVEN; private static final int SCALE = 16; protected static final double preciseAdd(double d1, double d2) { return doubleToBigDecimal(d1).add(doubleToBigDecimal(d2)) .setScale(SCALE, ROUNDING).doubleValue(); } protected static final double preciseSubtract(double d1, double d2) { return doubleToBigDecimal(d1).subtract(doubleToBigDecimal(d2)) .setScale(SCALE, ROUNDING).doubleValue(); } protected static final double preciseMultiply(double d1, double d2) { return doubleToBigDecimal(d1).multiply(doubleToBigDecimal(d2)) .setScale(SCALE, ROUNDING).doubleValue(); } protected static final double preciseDivide(double d1, double d2) { return doubleToBigDecimal(d1).divide(doubleToBigDecimal(d2), SCALE, ROUNDING).doubleValue(); } protected static final double preciseNegate(double d) { return doubleToBigDecimal(d).negate().setScale(SCALE, ROUNDING) .doubleValue(); } protected static final double preciseAbs(double d) { return doubleToBigDecimal(d).abs().setScale(SCALE, ROUNDING) .doubleValue(); } protected static final BigDecimal doubleToBigDecimal(double d) { // may not use BigDecimal.valueOf due to J2SE-1.4 backwards // compatibility return new BigDecimal(Double.toString(d)); } /** * Converts a double value into an integer value, avoiding rounding effects. * * @param doubleValue * the double value to convert * @return the integer value for the double. */ protected static final int doubleToInteger(double doubleValue) { return (int) Math.floor(doubleValue + 0.000000001); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/geometry/PrecisionPoint.java000066400000000000000000000173721166301720600311450ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.geometry; /** * @author danlee */ public class PrecisionPoint extends Point { private static final long serialVersionUID = 1L; /** * Double value for X * * @noreference * @deprecated Use {@link #setPreciseX(double)} and {@link #preciseX()} * instead. This field will become private in future versions. */ public double preciseX; /** * Double value for Y * * @noreference * @deprecated Use {@link #setPreciseY(double)} and {@link #preciseY()} * instead. This field will become private in future versions. */ public double preciseY; /** * Constructor for PrecisionPoint. */ public PrecisionPoint() { super(); } /** * Constructor for PrecisionPoint. * * @param x * X value * @param y * Y value */ public PrecisionPoint(double x, double y) { setPreciseLocation(x, y); } /** * Constructor for PrecisionPoint. * * @param x * X value * @param y * Y value */ public PrecisionPoint(int x, int y) { this((double) x, (double) y); } /** * Constructor for PrecisionPoint. * * @param p * Point from which the initial values are taken */ public PrecisionPoint(Point p) { this(p.preciseX(), p.preciseY()); } /** * @see org.eclipse.draw2d.geometry.Point#equals(java.lang.Object) */ public boolean equals(Object o) { if (o instanceof PrecisionPoint) { PrecisionPoint p = (PrecisionPoint) o; return p.preciseX() == preciseX() && p.preciseY() == preciseY(); } return super.equals(o); } /** * @see org.eclipse.draw2d.geometry.Point#getCopy() */ public Point getCopy() { return getPreciseCopy(); } /** * @see org.eclipse.draw2d.geometry.Point#getDifference(org.eclipse.draw2d.geometry.Point) */ public Dimension getDifference(Point p) { return new PrecisionDimension(this.preciseX() - p.preciseX(), this.preciseY() - p.preciseY()); } /** * Returns a precise copy of this. * * @return a precise copy * @since 3.7 */ public PrecisionPoint getPreciseCopy() { return new PrecisionPoint(preciseX(), preciseY()); } /** * @see org.eclipse.draw2d.geometry.Point#performScale(double) */ public void performScale(double factor) { setPreciseX(preciseX() * factor); setPreciseY(preciseY() * factor); } /** * @see org.eclipse.draw2d.geometry.Point#performTranslate(int, int) */ public void performTranslate(int dx, int dy) { setPreciseX(preciseX() + dx); setPreciseY(preciseY() + dy); } /** * @see org.eclipse.draw2d.geometry.Point#preciseX() */ public double preciseX() { updatePreciseXDouble(); return preciseX; } /** * @see org.eclipse.draw2d.geometry.Point#preciseY() */ public double preciseY() { updatePreciseYDouble(); return preciseY; } /** * @see org.eclipse.draw2d.geometry.Point#scale(double, double) */ public Point scale(double xFactor, double yFactor) { setPreciseX(preciseX() * xFactor); setPreciseY(preciseY() * yFactor); return this; } /** * @see org.eclipse.draw2d.geometry.Point#setLocation(int, int) */ public Point setLocation(int x, int y) { return setPreciseLocation(x, y); } /** * @see org.eclipse.draw2d.geometry.Point#setLocation(Point) */ public Point setLocation(Point pt) { return setPreciseLocation(pt.preciseX(), pt.preciseY()); } /** * Sets the precise location of this PrecisionPoint to the given x and y * values. * * @param x * The new x value * @param y * The new y value * @return this for convenience * @since 3.7 */ public PrecisionPoint setPreciseLocation(double x, double y) { setPreciseX(x); setPreciseY(y); return this; } /** * Sets the precise location of this PrecisionPoint to the x and y values of * the given one. * * @param p * The PrecisionPoint specifying the new x and y values. * @return this for convenience * @since 3.7 */ public PrecisionPoint setPreciseLocation(PrecisionPoint p) { return setPreciseLocation(p.preciseX(), p.preciseY()); } /** * Sets the precise x value of this PrecisionPoint to the given value. * * @param x * The new x value * @return this for convenience * @since 3.7 */ public PrecisionPoint setPreciseX(double x) { preciseX = x; updateXInt(); return this; } /** * Sets the precise y value of this PrecisionPoint to the given value. * * @param y * The new y value * @return this for convenience * @since 3.7 */ public PrecisionPoint setPreciseY(double y) { preciseY = y; updateYInt(); return this; } /** * @see org.eclipse.draw2d.geometry.Point#setX(int) */ public Point setX(int x) { return setPreciseX(x); } /** * @see org.eclipse.draw2d.geometry.Point#setY(int) */ public Point setY(int y) { return setPreciseY(y); } /** * @see org.eclipse.draw2d.geometry.Point#translate(org.eclipse.draw2d.geometry.Dimension) */ public Point translate(Dimension d) { return translatePrecise(d.preciseWidth(), d.preciseHeight()); } /** * @see org.eclipse.draw2d.geometry.Point#translate(int, int) */ public Point translate(int dx, int dy) { return translatePrecise(dx, dy); } /** * @see org.eclipse.draw2d.geometry.Point#translate(org.eclipse.draw2d.geometry.Point) */ public Point translate(Point p) { return translatePrecise(p.preciseX(), p.preciseY()); } /** * Shifts this Point by the values supplied along each axes, and returns * this for convenience. * * @param dx * Amount by which point is shifted along X axis. * @param dy * Amount by which point is shifted along Y axis. * @return this for convenience * @since 3.7 */ private PrecisionPoint translatePrecise(double dx, double dy) { setPreciseX(preciseX() + dx); setPreciseY(preciseY() + dy); return this; } /** * @see org.eclipse.draw2d.geometry.Point#transpose() */ public Point transpose() { double temp = preciseX(); setPreciseX(preciseY()); setPreciseY(temp); return this; } /** * Updates the integer fields using the precise versions. * * @deprecated This method should not be accessed by clients any more (it * will be made private in future releases). The update of * integer and precision fields is performed automatically if * {@link #preciseX} and {@link #preciseY} field values are not * manipulated directly, but only via respective methods offered * by this class. */ public final void updateInts() { updateXInt(); updateYInt(); } /** * Updates the x integer field using the value of preciseX. */ private final void updateXInt() { x = PrecisionGeometry.doubleToInteger(preciseX); } /** * Updates the y integer field using the value of preciseY. */ private final void updateYInt() { y = PrecisionGeometry.doubleToInteger(preciseY); } /** * Updates the preciseX double field using the value of x. */ private final void updatePreciseXDouble() { if (x != PrecisionGeometry.doubleToInteger(preciseX)) { preciseX = x; } } /** * Updates the preciseY double field using the value of y. */ private final void updatePreciseYDouble() { if (y != PrecisionGeometry.doubleToInteger(preciseY)) { preciseY = y; } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/geometry/PrecisionRectangle.java000066400000000000000000000622261166301720600317560ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.geometry; /** * A Rectangle implementation using floating point values which are truncated * into the inherited integer fields. The use of floating point prevents * rounding errors from accumulating. * * @author hudsonr Created on Apr 9, 2003 */ public final class PrecisionRectangle extends Rectangle { private static final long serialVersionUID = 1L; /** * Double value for height * * @noreference * @deprecated Use {@link #setPreciseHeight(double)} and * {@link #preciseHeight()} instead. This field will become * private in the future. */ public double preciseHeight; /** * Double value for width * * @noreference * @deprecated Use {@link #setPreciseWidth(double)} and * {@link #preciseWidth()} instead. This field will become * private in the future. */ public double preciseWidth; /** * Double value for X * * @noreference * @deprecated Use {@link #setPreciseX(double)} and {@link #preciseX()} * instead. This field will become private in the future. */ public double preciseX; /** * Double value for Y * * @noreference * @deprecated Use {@link #setPreciseX(double)} and {@link #preciseY()} * instead. This field will become private in the future. */ public double preciseY; /** * Constructs a new PrecisionRectangle with all values 0. */ public PrecisionRectangle() { } /** * Constructs a PrecisionRectangle with the provided values. * * @param x * X location * @param y * Y location * @param width * Width of the rectangle * @param height * Height of the rectangle * @since 3.7 */ public PrecisionRectangle(double x, double y, double width, double height) { setPreciseLocation(x, y); setPreciseSize(width, height); } /** * * Constructs a new PrecisionRectangle from a given Point and a Dimension * * @param p * The Point to specify x and y location of the * PrecisionRectangle * @param d * The Dimension to use for width and height of the * PrecisionRectangle * @since 3.7 */ public PrecisionRectangle(Point p, Dimension d) { this(p.preciseX(), p.preciseY(), d.preciseWidth(), d.preciseHeight()); } /** * Constructs a new PrecisionRectangle from the given integer Rectangle. * * @param rect * the base rectangle */ public PrecisionRectangle(Rectangle rect) { this(rect.preciseX(), rect.preciseY(), rect.preciseWidth(), rect .preciseHeight()); } /** * @see org.eclipse.draw2d.geometry.Rectangle#contains(int, int) */ public boolean contains(int x, int y) { return containsPrecise(x, y); } /** * @see org.eclipse.draw2d.geometry.Rectangle#contains(org.eclipse.draw2d.geometry.Point) */ public boolean contains(Point p) { return containsPrecise(p.preciseX(), p.preciseY()); } /** * @see org.eclipse.draw2d.geometry.Rectangle#contains(org.eclipse.draw2d.geometry.Rectangle) */ public boolean contains(Rectangle rect) { return preciseX() <= rect.preciseX() && preciseY() <= rect.preciseY() && right() >= rect.right() && bottom() >= rect.bottom(); } /** * Returns whether the given coordinates are within the boundaries of this * Rectangle. The boundaries are inclusive of the top and left edges, but * exclusive of the bottom and right edges. * * @param x * X value * @param y * Y value * @return true if the coordinates are within this Rectangle * @since 3.7 */ private boolean containsPrecise(double x, double y) { return y >= preciseY() && y < preciseY() + preciseHeight() && x >= preciseX() && x < preciseX() + preciseWidth(); } /** * @see Rectangle#equals(Object) */ public boolean equals(Object o) { if (o instanceof PrecisionRectangle) { PrecisionRectangle rect = (PrecisionRectangle) o; return super.equals(o) && Math.abs(rect.preciseX() - preciseX()) < 0.000000001 && Math.abs(rect.preciseY() - preciseY()) < 0.000000001 && Math.abs(rect.preciseWidth() - preciseWidth()) < 0.000000001 && Math.abs(rect.preciseHeight() - preciseHeight()) < 0.00000001; } return super.equals(o); } /** * Expands the horizontal and vertical sides of this Rectangle with the * values provided as input, and returns this for convenience. The location * of its center is kept constant. * * @param h * Horizontal increment * @param v * Vertical increment * @return this for convenience * @since 3.4 * @deprecated Use {@link #expandPrecise(double, double)} instead. */ public Rectangle expand(double h, double v) { return shrink(-h, -v); } /** * @see org.eclipse.draw2d.geometry.Rectangle#expand(org.eclipse.draw2d.geometry.Insets) */ public Rectangle expand(Insets insets) { if (insets == null) return this; setPreciseX(preciseX() - insets.left); setPreciseY(preciseY() - insets.top); setPreciseWidth(preciseWidth() + insets.getWidth()); setPreciseHeight(preciseHeight() + insets.getHeight()); return this; } /** * @see org.eclipse.draw2d.geometry.Rectangle#expand(int, int) */ public Rectangle expand(int h, int v) { return expandPrecise(h, v); } /** * Expands the horizontal and vertical sides of this Rectangle with the * values provided as input, and returns this for convenience. The location * of its center is kept constant. * * @param h * Horizontal increment * @param v * Vertical increment * @return this for convenience * @since 3.7 */ private PrecisionRectangle expandPrecise(double h, double v) { return shrinkPrecise(-h, -v); } /** * @see org.eclipse.draw2d.geometry.Rectangle#getBottom() */ public Point getBottom() { return new PrecisionPoint(preciseX() + preciseWidth() / 2, bottom()); } /** * @see org.eclipse.draw2d.geometry.Rectangle#getBottomLeft() */ public Point getBottomLeft() { return new PrecisionPoint(preciseX(), preciseY() + preciseHeight()); } /** * @see org.eclipse.draw2d.geometry.Rectangle#getBottomRight() */ public Point getBottomRight() { return new PrecisionPoint(preciseX() + preciseWidth(), preciseY() + preciseHeight()); } /** * @see org.eclipse.draw2d.geometry.Rectangle#getCenter() */ public Point getCenter() { return new PrecisionPoint(preciseX() + preciseWidth() / 2.0, preciseY() + preciseHeight() / 2.0); } /** * @see org.eclipse.draw2d.geometry.Rectangle#getCopy() */ public Rectangle getCopy() { return getPreciseCopy(); } /** * Returns a precise copy of this. * * @return a precise copy */ public PrecisionRectangle getPreciseCopy() { return new PrecisionRectangle(preciseX(), preciseY(), preciseWidth(), preciseHeight()); } /** * @see org.eclipse.draw2d.geometry.Rectangle#getTop() */ public Point getTop() { return new PrecisionPoint(preciseX() + preciseWidth() / 2, preciseY()); } /** * @see org.eclipse.draw2d.geometry.Rectangle#getTopLeft() */ public Point getTopLeft() { return new PrecisionPoint(preciseX(), preciseY()); } /** * @see org.eclipse.draw2d.geometry.Rectangle#getTopRight() */ public Point getTopRight() { return new PrecisionPoint(preciseX() + preciseWidth(), preciseY()); } /** * @see org.eclipse.draw2d.geometry.Rectangle#intersect(org.eclipse.draw2d.geometry.Rectangle) */ public Rectangle intersect(Rectangle rect) { return intersectPrecise(rect); } /** * Sets the size of this Rectangle to the intersection region with the * Rectangle supplied as input, and returns this for convenience. The * location and dimensions are set to zero if there is no intersection with * the input Rectangle. * * @param rect * Rectangle for the calculating intersection. * @return this for convenience * @since 3.7 */ private PrecisionRectangle intersectPrecise(Rectangle rect) { double x1 = Math.max(preciseX(), rect.preciseX()); double x2 = Math.min(preciseX() + preciseWidth(), rect.preciseX() + rect.preciseWidth()); double y1 = Math.max(preciseY(), rect.preciseY()); double y2 = Math.min(preciseY() + preciseHeight(), rect.preciseY() + rect.preciseHeight()); if (((x2 - x1) < 0) || ((y2 - y1) < 0)) return setPreciseBounds(0, 0, 0, 0); // no intersection else { return setPreciseBounds(x1, y1, x2 - x1, y2 - y1); } } /** * @see org.eclipse.draw2d.geometry.Rectangle#performScale(double) */ public void performScale(double factor) { setPreciseX(preciseX() * factor); setPreciseY(preciseY() * factor); setPreciseWidth(preciseWidth() * factor); setPreciseHeight(preciseHeight() * factor); } /** * @see org.eclipse.draw2d.geometry.Rectangle#performTranslate(int, int) */ public void performTranslate(int dx, int dy) { setPreciseX(preciseX() + dx); setPreciseY(preciseY() + dy); } /** * Returns the bottom coordinte in double precision. * * @return the precise bottom */ public double preciseBottom() { return preciseHeight() + preciseY(); } /** * @see org.eclipse.draw2d.geometry.Rectangle#preciseHeight() */ public double preciseHeight() { updatePreciseHeightDouble(); return preciseHeight; } /** * Returns the right side in double precision. * * @return the precise right */ public double preciseRight() { return preciseWidth() + preciseX(); } /** * @see org.eclipse.draw2d.geometry.Rectangle#preciseWidth() */ public double preciseWidth() { updatePreciseWidthDouble(); return preciseWidth; } /** * @see org.eclipse.draw2d.geometry.Rectangle#preciseX() */ public double preciseX() { updatePreciseXDouble(); return preciseX; } /** * @see org.eclipse.draw2d.geometry.Rectangle#preciseY() */ public double preciseY() { updatePreciseYDouble(); return preciseY; } /** * @see org.eclipse.draw2d.geometry.Rectangle#resize(org.eclipse.draw2d.geometry.Dimension) */ public Rectangle resize(Dimension d) { return resizePrecise(d.preciseWidth(), d.preciseHeight()); } /** * @see org.eclipse.draw2d.geometry.Rectangle#resize(int, int) */ public Rectangle resize(int w, int h) { return resizePrecise(w, h); } /** * Resizes this Rectangle by adding the values supplied, returning this for * convenience. * * @param w * Amount by which width is to be resized * @param h * Amount by which height is to be resized * @return this for convenience * @since 3.7 */ private PrecisionRectangle resizePrecise(double w, double h) { setPreciseWidth(preciseWidth() + w); setPreciseHeight(preciseHeight() + h); return this; } /** * @see org.eclipse.draw2d.geometry.Rectangle#setBounds(int, int, int, int) */ public Rectangle setBounds(int x, int y, int width, int height) { return setPreciseBounds(x, y, width, height); } /** * @see org.eclipse.draw2d.geometry.Rectangle#setBounds(org.eclipse.draw2d.geometry.Point, * org.eclipse.draw2d.geometry.Dimension) */ public Rectangle setBounds(Point location, Dimension size) { return setPreciseBounds(location.preciseX(), location.preciseY(), size.preciseWidth(), size.preciseHeight()); } /** * @see org.eclipse.draw2d.geometry.Rectangle#setBounds(org.eclipse.draw2d.geometry.Rectangle) */ public Rectangle setBounds(Rectangle rect) { return setPreciseBounds(rect.preciseX(), rect.preciseY(), rect.preciseWidth(), rect.preciseHeight()); } /** * Sets the height. * * @param value * the new height * @deprecated Use {@link #setPreciseHeight(double)} instead. */ public void setHeight(double value) { setPreciseHeight(value); } /** * @see org.eclipse.draw2d.geometry.Rectangle#setHeight(int) */ public Rectangle setHeight(int height) { return setPreciseHeight(height); } /** * @see org.eclipse.draw2d.geometry.Rectangle#setLocation(int, int) */ public Rectangle setLocation(int x, int y) { return setPreciseLocation(x, y); } /** * @see org.eclipse.draw2d.geometry.Rectangle#setLocation(org.eclipse.draw2d.geometry.Point) */ public Rectangle setLocation(Point loc) { return setPreciseLocation(loc.preciseX(), loc.preciseY()); } /** * Sets the preciseX, preciseY, preciseWidth, and preciseHeight values of * this PrecisionRectangle to the provided values and updates the integer * values of x, y, width, and height accordingly. * * @param x * The new x * @param y * The new y * @param width * The new width * @param height * The new height * @return this for convenience * @since 3.7 */ public PrecisionRectangle setPreciseBounds(double x, double y, double width, double height) { setPreciseLocation(x, y); setPreciseSize(width, height); return this; } /** * Sets the height of this PrecisionRectangle to the specified value. * * @param value * The new height. * @return this for convenience * @since 3.7 */ public PrecisionRectangle setPreciseHeight(double value) { preciseHeight = value; updateHeightInt(); return this; } /** * Sets the preciseX and preciseY values of this PrecisionRectangle to the * provided values and updates the integer values of x and y accordingly. * * @param x * The new x value * @param y * The new y value * @return this for convenience * @since 3.7 */ public PrecisionRectangle setPreciseLocation(double x, double y) { setPreciseX(x); setPreciseY(y); return this; } /** * Sets the precise location of this PrecisionRectangle * * @param loc * The new location * @return this for convenience. * @since 3.7 */ public PrecisionRectangle setPreciseLocation(PrecisionPoint loc) { return setPreciseLocation(loc.preciseX(), loc.preciseY()); } /** * Sets the preciseWidth and preciseHeight values of this PrecisionRectangle * to the provided values and updates the integer values of width and height * accordingly. * * @param w * The new width * @param h * The new height * @return this for convenience. * @since 3.7 */ public PrecisionRectangle setPreciseSize(double w, double h) { setPreciseWidth(w); setPreciseHeight(h); return this; } /** * Set the size of this PrecisionRectangle to the given dimension's width * and height. Returns this for convenience. * * @param size * The new size * @return this for convenience. * @since 3.7 */ public PrecisionRectangle setPreciseSize(PrecisionDimension size) { return setPreciseSize(size.preciseWidth(), size.preciseHeight()); } /** * Sets the width of this PrecisionRectangle to the specified one. * * @param value * The new width * @return this for convenience * @since 3.7 */ public PrecisionRectangle setPreciseWidth(double value) { preciseWidth = value; updateWidthInt(); return this; } /** * Sets the x value. * * @param value * The new x value * @return this for convenience * @since 3.7 */ public PrecisionRectangle setPreciseX(double value) { preciseX = value; updateXInt(); return this; } /** * Sets the y value. * * @param value * the new y value * @return this for convenience * @since 3.7 */ public PrecisionRectangle setPreciseY(double value) { preciseY = value; updateYInt(); return this; } /** * @see org.eclipse.draw2d.geometry.Rectangle#setSize(org.eclipse.draw2d.geometry.Dimension) */ public Rectangle setSize(Dimension d) { return setPreciseSize(d.preciseWidth(), d.preciseHeight()); } /** * @see org.eclipse.draw2d.geometry.Rectangle#setSize(int, int) */ public Rectangle setSize(int w, int h) { return setPreciseSize(w, h); } /** * Sets the width. * * @param value * the new width * @deprecated Use {@link #setPreciseWidth(double)} instead. */ public void setWidth(double value) { setPreciseWidth(value); } /** * @see org.eclipse.draw2d.geometry.Rectangle#setWidth(int) */ public Rectangle setWidth(int width) { return setPreciseWidth(width); } /** * Sets the x value. * * @param value * the new x value * @deprecated Use {@link #setPreciseX(double)} instead. */ public void setX(double value) { setPreciseX(value); } /** * @see org.eclipse.draw2d.geometry.Rectangle#setX(int) */ public Rectangle setX(int value) { return setPreciseX(value); } /** * Sets the y value. * * @param value * the new y value * @deprecated Use {@link #setPreciseX(double)} instead. */ public void setY(double value) { setPreciseY(value); } /** * @see org.eclipse.draw2d.geometry.Rectangle#setY(int) */ public Rectangle setY(int value) { return setPreciseY(value); } /** * Shrinks the sides of this Rectangle by the horizontal and vertical values * provided as input, and returns this Rectangle for convenience. The center * of this Rectangle is kept constant. * * @param h * Horizontal reduction amount * @param v * Vertical reduction amount * @return this for convenience * @since 3.4 * @deprecated Use {@link #shrink(int, int)} or * {@link #shrinkPrecise(double, double)} instead. */ public Rectangle shrink(double h, double v) { return shrinkPrecise(h, v); } /** * @see org.eclipse.draw2d.geometry.Rectangle#shrink(org.eclipse.draw2d.geometry.Insets) */ public Rectangle shrink(Insets insets) { if (insets == null) return this; setPreciseX(preciseX() + insets.left); setPreciseY(preciseY() + insets.top); setPreciseWidth(preciseWidth() - insets.getWidth()); setPreciseHeight(preciseHeight() - insets.getHeight()); return this; } /** * @see org.eclipse.draw2d.geometry.Rectangle#shrink(int, int) */ public Rectangle shrink(int h, int v) { return shrinkPrecise(h, v); } /** * Shrinks the sides of this Rectangle by the horizontal and vertical values * provided as input, and returns this Rectangle for convenience. The center * of this Rectangle is kept constant. * * @param h * Horizontal reduction amount * @param v * Vertical reduction amount * @return this for convenience * @since 3.7 */ private PrecisionRectangle shrinkPrecise(double h, double v) { setPreciseX(preciseX() + h); setPreciseWidth(preciseWidth() - (h + h)); setPreciseY(preciseY() + v); setPreciseHeight(preciseHeight() - (v + v)); return this; } /** * @see org.eclipse.draw2d.geometry.Rectangle#touches(org.eclipse.draw2d.geometry.Rectangle) */ public boolean touches(Rectangle rect) { return rect.preciseX() <= preciseX() + preciseWidth() && rect.preciseY() <= preciseY() + preciseHeight() && rect.preciseX() + rect.preciseWidth() >= preciseX() && rect.preciseY() + rect.preciseHeight() >= preciseY(); } /** * @see org.eclipse.draw2d.geometry.Rectangle#translate(int, int) */ public Rectangle translate(int dx, int dy) { return translatePrecise(dx, dy); } /** * @see org.eclipse.draw2d.geometry.Rectangle#translate(org.eclipse.draw2d.geometry.Point) */ public Rectangle translate(Point p) { return translatePrecise(p.preciseX(), p.preciseY()); } /** * Moves this Rectangle horizontally by dx and vertically by dy, then * returns this Rectangle for convenience. * * @param dx * Shift along X axis * @param dy * Shift along Y axis * @return this for convenience * @since 3.7 */ private PrecisionRectangle translatePrecise(double dx, double dy) { setPreciseX(preciseX() + dx); setPreciseY(preciseY() + dy); return this; } /** * @see org.eclipse.draw2d.geometry.Rectangle#transpose() */ public Rectangle transpose() { double temp = preciseX(); setPreciseX(preciseY()); setPreciseY(temp); temp = preciseWidth(); setPreciseWidth(preciseHeight()); setPreciseHeight(temp); return this; } /** * @see org.eclipse.draw2d.geometry.Rectangle#union(int, int) */ public Rectangle union(int x, int y) { return unionPrecise(x, y); } /** * @see org.eclipse.draw2d.geometry.Rectangle#union(org.eclipse.draw2d.geometry.Point) */ public void union(Point p) { unionPrecise(p.preciseX(), p.preciseY()); } /** * Unions the given PrecisionRectangle with this rectangle and returns * this for convenience. * * @since 3.0 * @param rect * the rectangle being unioned * @return this for convenience * @deprecated Use {@link #union(Rectangle)} instead */ public PrecisionRectangle union(PrecisionRectangle rect) { if (rect == null || rect.isEmpty()) { return this; } return unionPrecise(rect.preciseX(), rect.preciseY(), rect.preciseWidth(), rect.preciseHeight()); } /** * @see org.eclipse.draw2d.geometry.Rectangle#union(org.eclipse.draw2d.geometry.Rectangle) */ public Rectangle union(Rectangle rect) { if (rect == null || rect.isEmpty()) return this; return unionPrecise(rect.preciseX(), rect.preciseY(), rect.preciseWidth(), rect.preciseHeight()); } /** * Updates this Rectangle's bounds to the minimum size which can hold both * this Rectangle and the coordinate (x,y). * * @return this for convenience * @param x * X coordinate * @param y * Y coordinate * @since 3.7 */ private PrecisionRectangle unionPrecise(double x, double y) { if (x < preciseX()) { setPreciseWidth(preciseWidth() + (preciseX() - x)); setPreciseX(x); } else { double right = preciseX() + preciseWidth(); if (x > right) { setPreciseWidth(x - preciseX()); } } if (y < preciseY()) { setPreciseHeight(preciseHeight() + (preciseY() - y)); setPreciseY(y); } else { double bottom = preciseY() + preciseHeight(); if (y > bottom) { setPreciseHeight(y - preciseY()); } } return this; } /** * Updates this Rectangle's dimensions to the minimum size which can hold * both this Rectangle and the rectangle (x, y, w, h). * * @param x * X coordinate of desired union. * @param y * Y coordinate of desired union. * @param w * Width of desired union. * @param h * Height of desired union. * @return this for convenience * @since 3.7 */ private PrecisionRectangle unionPrecise(double x, double y, double w, double h) { double right = Math.max(preciseX() + preciseWidth(), x + w); double bottom = Math.max(preciseY() + preciseHeight(), y + h); setPreciseX(Math.min(preciseX(), x)); setPreciseY(Math.min(preciseY(), y)); setPreciseWidth(right - preciseX()); setPreciseHeight(bottom - preciseY()); return this; } /** * Updates the height integer field using the value of preciseHeight. */ private final void updateHeightInt() { height = PrecisionGeometry.doubleToInteger(preciseHeight); } /** * Updates the integer values based on the current precise values. * * @deprecated This method should not be accessed by clients any more (it * will be made private in future releases). The update of * integer and precision fields is performed automatically if * {@link #preciseX}, {@link #preciseY}, {@link #preciseWidth}, * and {@link #preciseHeight} field values are not manipulated * directly, but only via respective methods offered by this * class. * * @since 3.0 */ public void updateInts() { updateXInt(); updateYInt(); updateWidthInt(); updateHeightInt(); } /** * Updates the preciseHeight double field using the value of height. */ private final void updatePreciseHeightDouble() { if (height != PrecisionGeometry.doubleToInteger(preciseHeight)) { preciseHeight = height; } } /** * Updates the preciseWidth double field using the value of width. */ private final void updatePreciseWidthDouble() { if (width != PrecisionGeometry.doubleToInteger(preciseWidth)) { preciseWidth = width; } } /** * Updates the preciseX double field using the value of x. */ private final void updatePreciseXDouble() { if (x != PrecisionGeometry.doubleToInteger(preciseX)) { preciseX = x; } } /** * Updates the preciseY double field using the value of y. */ private final void updatePreciseYDouble() { if (y != PrecisionGeometry.doubleToInteger(preciseY)) { preciseY = y; } } /** * Updates the width integer field using the value of preciseWidth. */ private final void updateWidthInt() { width = PrecisionGeometry.doubleToInteger(preciseWidth); } /** * Updates the x integer field using the value of preciseX. */ private final void updateXInt() { x = PrecisionGeometry.doubleToInteger(preciseX); } /** * Updates the y integer field using the value of preciseY. */ private final void updateYInt() { y = PrecisionGeometry.doubleToInteger(preciseY); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/geometry/Ray.java000066400000000000000000000114771166301720600267330ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * *******************************************************************************/ package org.eclipse.draw2d.geometry; /** * Represents a 2-dimensional directional Vector, or Ray. * {@link java.util.Vector} is commonly imported, so the name Ray was chosen. * * @deprecated Use {@link Vector} instead, which offers double precision instead * of integer precision. */ public final class Ray { /** the X value */ public int x; /** the Y value */ public int y; /** * Constructs a Ray <0, 0> with no direction and magnitude. * * @since 2.0 */ public Ray() { } /** * Constructs a Ray pointed in the specified direction. * * @param x * X value. * @param y * Y value. * @since 2.0 */ public Ray(int x, int y) { this.x = x; this.y = y; } /** * Constructs a Ray pointed in the direction specified by a Point. * * @param p * the Point * @since 2.0 */ public Ray(Point p) { x = p.x; y = p.y; } /** * Constructs a Ray representing the direction and magnitude between to * provided Points. * * @param start * Strarting Point * @param end * End Point * @since 2.0 */ public Ray(Point start, Point end) { x = end.x - start.x; y = end.y - start.y; } /** * Constructs a Ray representing the difference between two provided Rays. * * @param start * The start Ray * @param end * The end Ray * @since 2.0 */ public Ray(Ray start, Ray end) { x = end.x - start.x; y = end.y - start.y; } /** * Calculates the magnitude of the cross product of this Ray with another. * Represents the amount by which two Rays are directionally different. * Parallel Rays return a value of 0. * * @param r * Ray being compared * @return The assimilarity * @see #similarity(Ray) * @since 2.0 */ public int assimilarity(Ray r) { return Math.abs(x * r.y - y * r.x); } /** * Calculates the dot product of this Ray with another. * * @param r * the Ray used to perform the dot product * @return The dot product * @since 2.0 */ public int dotProduct(Ray r) { return x * r.x + y * r.y; } /** * Calculates the dot product of this Ray with another. * * @param r * the Ray used to perform the dot product * @return The dot product as long to avoid possible integer * overflow * @since 3.4.1 */ long dotProductL(Ray r) { return (long) x * r.x + (long) y * r.y; } /** * @see java.lang.Object#equals(Object) */ public boolean equals(Object obj) { if (obj == this) return true; if (obj instanceof Ray) { Ray r = (Ray) obj; return x == r.x && y == r.y; } return false; } /** * Creates a new Ray which is the sum of this Ray with another. * * @param r * Ray to be added with this Ray * @return a new Ray * @since 2.0 */ public Ray getAdded(Ray r) { return new Ray(r.x + x, r.y + y); } /** * Creates a new Ray which represents the average of this Ray with another. * * @param r * Ray to calculate the average. * @return a new Ray * @since 2.0 */ public Ray getAveraged(Ray r) { return new Ray((x + r.x) / 2, (y + r.y) / 2); } /** * Creates a new Ray which represents this Ray scaled by the amount * provided. * * @param s * Value providing the amount to scale. * @return a new Ray * @since 2.0 */ public Ray getScaled(int s) { return new Ray(x * s, y * s); } /** * @see java.lang.Object#hashCode() */ public int hashCode() { return (x * y) ^ (x + y); } /** * Returns true if this Ray has a non-zero horizontal comonent. * * @return true if this Ray has a non-zero horizontal comonent * @since 2.0 */ public boolean isHorizontal() { return x != 0; } /** * Returns the length of this Ray. * * @return Length of this Ray * @since 2.0 */ public double length() { return Math.sqrt(dotProductL(this)); } /** * Calculates the similarity of this Ray with another. Similarity is defined * as the absolute value of the dotProduct() * * @param r * Ray being tested for similarity * @return the Similarity * @see #assimilarity(Ray) * @since 2.0 */ public int similarity(Ray r) { return Math.abs(dotProduct(r)); } /** * @return a String representation */ public String toString() { return "(" + x + "," + y + ")";//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$ } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/geometry/Rectangle.java000066400000000000000000000735201166301720600301010ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation * Mariot Chauvin - bug 260740 *******************************************************************************/ package org.eclipse.draw2d.geometry; import org.eclipse.draw2d.PositionConstants; /** * Represents a Rectangle(x, y, width, height). This class provides various * methods for manipulating this Rectangle or creating new derived geometrical * Objects. */ public class Rectangle implements Cloneable, java.io.Serializable, Translatable { private static final long serialVersionUID = 1L; /** * A singleton for use in short calculations. Use to avoid newing * unnecessary objects. */ public static final Rectangle SINGLETON = new Rectangle(); /** * The height */ public int height; /** * The width */ public int width; /** * The x value */ public int x; /** * The y value */ public int y; /** * Constructs a Rectangle at the origin with zero width and height. * * @since 2.0 */ public Rectangle() { } /** * Constructs a Rectangle with the provided values. * * @param x * X location * @param y * Y location * @param width * Width of the rectangle * @param height * Height of the rectangle * @since 2.0 */ public Rectangle(int x, int y, int width, int height) { this.x = x; this.y = y; this.width = width; this.height = height; } /** * Constructs a copy of the provided SWT * {@link org.eclipse.swt.graphics.Rectangle}. * * @param rect * The SWT Rectangle being copied * @since 2.0 */ public Rectangle(org.eclipse.swt.graphics.Rectangle rect) { this(rect.x, rect.y, rect.width, rect.height); } /** * Constructs a Rectangle given a location and size. * * @param p * the location * @param size * the size * @since 2.0 */ public Rectangle(Point p, Dimension size) { this(p.x(), p.y(), size.width(), size.height()); } /** * Constructs the smallest Rectangle that contains the specified Points. * * @param p1 * Upper left hand corner * @param p2 * Lower right hand corner * @since 2.0 */ public Rectangle(Point p1, Point p2) { this.x = Math.min(p1.x(), p2.x()); this.y = Math.min(p1.y(), p2.y()); this.width = Math.abs(p2.x() - p1.x()) + 1; this.height = Math.abs(p2.y() - p1.y()) + 1; } /** * Constructs a copy of the provided Rectangle. * * @param rect * Rectangle supplying the initial values * @since 2.0 */ public Rectangle(Rectangle rect) { this(rect.x(), rect.y(), rect.width(), rect.height()); } /** * Returns the y-coordinate of the bottom of this Rectangle. * * @return The Y coordinate of the bottom * @since 2.0 */ public int bottom() { return y + height; } /** * Returns whether the given coordinates are within the boundaries of this * Rectangle. The boundaries are inclusive of the top and left edges, but * exclusive of the bottom and right edges. * * @param x * X value * @param y * Y value * @return true if the coordinates are within this Rectangle * @since 2.0 */ public boolean contains(int x, int y) { return y >= this.y && y < this.y + this.height && x >= this.x && x < this.x + this.width; } /** * Returns whether the given point is within the boundaries of this * Rectangle. The boundaries are inclusive of the top and left edges, but * exclusive of the bottom and right edges. * * @param p * Point being tested for containment * @return true if the Point is within this Rectangle * @since 2.0 */ public boolean contains(Point p) { return contains(p.x(), p.y()); } /** * Returns true if the given rectangle is contained within the * boundaries of this Rectangle. * * @param rect * the Rectangle to test * @return true if the Rectangle is within this Rectangle */ public boolean contains(Rectangle rect) { return x <= rect.x() && y <= rect.y() && right() >= rect.right() && bottom() >= rect.bottom(); } /** * Crops this rectangle by the amount specified in insets. * * @param insets * Insets to be removed from the Rectangle * @return this for convenience * @since 2.0 * @deprecated Use {@link #shrink(Insets)} instead. */ public Rectangle crop(Insets insets) { return shrink(insets); } /** * Returns true if this Rectangle's x, y, width, and height * values are identical to the provided ones. * * @param x * The x value to test * @param y * The y value to test * @param width * The width value to test * @param height * The height value to test * @return true if this Rectangle's x, y, width, and height * values are identical to the provided ones, false * otherwise * @since 3.7 */ public boolean equals(int x, int y, int width, int height) { return this.x == x && this.y == y && this.width == width && this.height == height; } /** * Returns whether the input object is equal to this Rectangle or not. * Rectangles are equivalent if their x, y, height, and width values are the * same. * * @param o * Object being tested for equality * @return Returns the result of the equality test * @since 2.0 */ public boolean equals(Object o) { if (this == o) return true; if (o instanceof Rectangle) { Rectangle r = (Rectangle) o; return (x == r.x()) && (y == r.y()) && (width == r.width()) && (height == r.height()); } return false; } /** * Expands the horizontal and vertical sides of this Rectangle by the width * and height of the given Insets, and returns this for convenience. * * @param insets * contains the amounts to expand on each side * @return this for convenience * @since 2.0 */ public Rectangle expand(Insets insets) { x -= insets.left; y -= insets.top; width += insets.getWidth(); height += insets.getHeight(); return this; } /** * Expands the horizontal and vertical sides of this Rectangle with the * values provided as input, and returns this for convenience. The location * of its center is kept constant. * * @param h * Horizontal increment * @param v * Vertical increment * @return this for convenience * @since 2.0 */ public Rectangle expand(int h, int v) { return shrink(-h, -v); } /** * Returns a new Point representing the middle point of the bottom side of * this Rectangle. * * @return Point at the bottom of the Rectangle * @since 2.0 */ public Point getBottom() { return new Point(x + width / 2, bottom()); } /** * Returns a new Point representing the bottom left point of this Rectangle. * * @return Point at the bottom left of the rectangle * @since 2.0 */ public Point getBottomLeft() { return new Point(x, y + height); } /** * Returns a new Point representing the bottom right point of this * Rectangle. * * @return Point at the bottom right of the rectangle * @since 2.0 */ public Point getBottomRight() { return new Point(x + width, y + height); } /** * Returns a new point representing the center of this Rectangle. * * @return Point at the center of the rectangle */ public Point getCenter() { return new Point(x + width / 2, y + height / 2); } /** * Returns a new Rectangle which has the exact same parameters as this * Rectangle. * * @return Copy of this Rectangle * @since 2.0 */ public Rectangle getCopy() { // FIXME: This is inconsistent with the behavior of getCopy() within // Point and Dimension and should only return a new Rectangle, leaving // the property copying of others to subclasses. Clients should // not relay on this method performing a clone() if (getClass() == Rectangle.class) { /* avoid clone() call cost see bug #260740 */ return new Rectangle(this); } else { try { return (Rectangle) clone(); } catch (CloneNotSupportedException exc) { return new Rectangle(this); } } } /** * Returns a new Rectangle with the specified insets cropped. * * @param insets * Insets being cropped from the Rectangle * @return Cropped new Rectangle * @deprecated Use {@link #getShrinked(Insets)} instead. */ public Rectangle getCropped(Insets insets) { return getShrinked(insets); } /** * Creates and returns a new Rectangle with the bounds of this * Rectangle, expanded by the given Insets. * * @param insets * The insets used to expand this rectangle * @return A new expanded Rectangle * @since 2.0 */ public Rectangle getExpanded(Insets insets) { return getCopy().expand(insets); } /** * Returns a new incremented Rectangle, where the sides are expanded by the * horizontal and vertical values provided. The center of the Rectangle is * maintained constant. * * @param h * Horizontal increment * @param v * Vertical increment * @return A new expanded Rectangle * @since 2.0 */ public Rectangle getExpanded(int h, int v) { return getCopy().expand(h, v); } /** * Returns a new Rectangle which has the intersection of this Rectangle and * the rectangle provided as input. Returns an empty Rectangle if there is * no intersection. * * @param rect * Rectangle provided to test for intersection * @return A new Rectangle representing the intersection * @since 2.0 */ public Rectangle getIntersection(Rectangle rect) { return getCopy().intersect(rect); } /** * Returns a new Point representing the middle point of the left hand side * of this Rectangle. * * @return Point at the left of the Rectangle */ public Point getLeft() { return new Point(x, y + height / 2); } /** * Returns the upper left hand corner of the rectangle. * * @return Location of the rectangle * @see #setLocation(Point) */ public Point getLocation() { return new Point(x, y); } /** *

    * Returns an integer which represents the position of the given point with * respect to this rectangle. Possible return values are bitwise ORs of the * constants WEST, EAST, NORTH, and SOUTH as found in * {@link org.eclipse.draw2d.PositionConstants}. * *

    * Returns PositionConstant.NONE if the given point is inside this * Rectangle. * * @param p * The Point whose position has to be determined * @return An int which is a PositionConstant * @see org.eclipse.draw2d.PositionConstants * @since 2.0 */ public int getPosition(Point p) { int result = PositionConstants.NONE; if (contains(p)) return result; if (p.x() < x) result = PositionConstants.WEST; else if (p.x() >= (x + width)) result = PositionConstants.EAST; if (p.y() < y) result = result | PositionConstants.NORTH; else if (p.y() >= (y + height)) result = result | PositionConstants.SOUTH; return result; } /** * Returns a new Rectangle which is equivalent to this Rectangle with its * dimensions modified by the passed Dimension d. * * @param d * Dimensions by which the rectangle's size should be modified * @return The new rectangle with the modified dimensions * @since 2.0 */ public Rectangle getResized(Dimension d) { return getCopy().resize(d); } /** * Returns a new Rectangle which is equivalent to this Rectangle with its * dimensions modified by the passed width w and height h. * * @param w * Amount by which width is to be resized * @param h * Amount by which height is to be resized * @return a new rectangle with its width and height modified */ public Rectangle getResized(int w, int h) { return getCopy().resize(w, h); } /** * Returns a new Point which represents the middle point of the right hand * side of this Rectangle. * * @return Point at the right of the Rectangle * @since 2.0 */ public Point getRight() { return new Point(right(), y + height / 2); } /** * Returns a new Rectangle shrinked by the specified insets. * * @param insets * Insets being cropped from the Rectangle * @return Shrinked new Rectangle * @since 3.7 */ public Rectangle getShrinked(Insets insets) { return getCopy().shrink(insets); } /** * Returns a new Rectangle, where the sides are shrinked by the horizontal * and vertical values supplied. The center of this Rectangle is kept * constant. * * @param h * Horizontal reduction amount * @param v * Vertical reduction amount * @return this for convenience * @since 3.7 */ public Rectangle getShrinked(int h, int v) { return getCopy().shrink(h, v); } /** * Retuns the dimensions of this Rectangle. * * @return Size of this Rectangle as a Dimension * @since 2.0 */ public Dimension getSize() { return new Dimension(width, height); } /** * Returns a new Point which represents the middle point of the top side of * this Rectangle. * * @return Point at the top of the Rectangle * @since 2.0 */ public Point getTop() { return new Point(x + width / 2, y); } /** * Returns a new Point which represents the top left hand corner of this * Rectangle. * * @return Point at the top left of the rectangle * @since 2.0 */ public Point getTopLeft() { return new Point(x, y); } /** * Returns a new Point which represents the top right hand corner of this * Rectangle. * * @return Point at the top right of the rectangle * @since 2.0 */ public Point getTopRight() { return new Point(x + width, y); } /** * Returns a new Rectangle which is shifted along each axis by the passed * values. * * @param dx * Displacement along X axis * @param dy * Displacement along Y axis * @return The new translated rectangle * @since 2.0 */ public Rectangle getTranslated(int dx, int dy) { return getCopy().translate(dx, dy); } /** * Returns a new Rectangle which is shifted by the position of the given * Point. * * @param pt * Point providing the amount of shift along each axis * @return The new translated Rectangle * @since 2.0 */ public Rectangle getTranslated(Point pt) { return getCopy().translate(pt); } /** * Returns a new rectangle whose width and height have been interchanged, as * well as its x and y values. This can be useful in orientation changes. * * @return The transposed rectangle * @since 2.0 */ public Rectangle getTransposed() { return getCopy().transpose(); } /** * Returns a new Rectangle which contains both this Rectangle and the Point * supplied as input. * * @param p * Point for calculating union * @return A new unioned Rectangle * @since 3.7 */ public Rectangle getUnion(Point p) { Rectangle copy = getCopy(); copy.union(p); return copy; } /** * Returns a new Rectangle which contains both this Rectangle and the * Rectangle supplied as input. * * @param rect * Rectangle for calculating union * @return A new unioned Rectangle * @since 2.0 */ public Rectangle getUnion(Rectangle rect) { return getCopy().union(rect); } /** * @see java.lang.Object#hashCode() */ public int hashCode() { return (x + height + 1) * (y + width + 1) ^ x ^ y; } /** * Returns the current height of this Rectangle * * @return The current height * @since 3.7 */ public int height() { return height; } /** * Sets the size of this Rectangle to the intersection region with the * Rectangle supplied as input, and returns this for convenience. The * location and dimensions are set to zero if there is no intersection with * the input Rectangle. * * @param rect * Rectangle for the calculating intersection. * @return this for convenience * @since 2.0 */ public Rectangle intersect(Rectangle rect) { int x1 = Math.max(x, rect.x()); int x2 = Math.min(x + width, rect.x() + rect.width()); int y1 = Math.max(y, rect.y()); int y2 = Math.min(y + height, rect.y() + rect.height()); if (((x2 - x1) < 0) || ((y2 - y1) < 0)) return setBounds(0, 0, 0, 0); // no intersection else { return setBounds(x1, y1, x2 - x1, y2 - y1); } } /** * Returns true if the input Rectangle intersects this * Rectangle. * * @param rect * Rectangle for the intersection test * @return true if the input Rectangle intersects this * Rectangle * @since 2.0 */ public boolean intersects(Rectangle rect) { return !getIntersection(rect).isEmpty(); } /** * Returns true if this Rectangle's width or height is less * than or equal to 0. * * @return true if this Rectangle is empty * @since 2.0 */ public boolean isEmpty() { return width <= 0 || height <= 0; } /** * @see Translatable#performScale(double) */ public void performScale(double factor) { scale(factor); } /** * @see Translatable#performTranslate(int, int) */ public void performTranslate(int dx, int dy) { translate(dx, dy); } /** * Returns double height * * @return double height * @since 3.4 */ public double preciseHeight() { return height; } /** * Returns double width * * @return double width * @since 3.4 */ public double preciseWidth() { return width; } /** * Returns double x coordinate * * @return double x coordinate * @since 3.4 */ public double preciseX() { return x; } /** * Returns double y coordinate * * @return double y coordinate * @since 3.4 */ public double preciseY() { return y; } /** * Resizes this Rectangle by the Dimension provided as input and returns * this for convenience. This Rectange's width will become this.width + * sizeDelta.width. Likewise for height. * * @param d * Resize data as a Dimension * @return this for convenience * @since 2.0 */ public Rectangle resize(Dimension d) { width += d.width(); height += d.height(); return this; } /** * Resizes this Rectangle by the values supplied as input and returns this * for convenience. This Rectangle's width will become this.width + dw. This * Rectangle's height will become this.height + dh. * * @param w * Amount by which width is to be resized * @param h * Amount by which height is to be resized * @return this for convenience * @since 2.0 */ public Rectangle resize(int w, int h) { width += w; height += h; return this; } /** * Returns the x-coordinate of the right side of this Rectangle. * * @return The X coordinate of the right side * @since 2.0 */ public int right() { return x + width; } /** * Scales the location and size of this Rectangle by the given scale and * returns this for convenience. * * @param scaleFactor * The factor by which this rectangle will be scaled * @return this for convenience * @since 2.0 */ public final Rectangle scale(double scaleFactor) { return scale(scaleFactor, scaleFactor); } /** * Scales the location and size of this Rectangle by the given scales and * returns this for convenience. * * @param scaleX * the factor by which the X dimension has to be scaled * @param scaleY * the factor by which the Y dimension has to be scaled * @return this for convenience * @since 2.0 */ public Rectangle scale(double scaleX, double scaleY) { int oldX = x; int oldY = y; x = (int) (Math.floor(x * scaleX)); y = (int) (Math.floor(y * scaleY)); width = (int) (Math.ceil((oldX + width) * scaleX)) - x; height = (int) (Math.ceil((oldY + height) * scaleY)) - y; return this; } /** * Sets the x, y, width, and height values of this Rectangle to the provided * values. * * @param x * The new x * @param y * The new y * @param width * The new width * @param height * The new height * @return this for convenience * @since 3.7 */ public Rectangle setBounds(int x, int y, int width, int height) { this.x = x; this.y = y; this.width = width; this.height = height; return this; } /** * Sets the location and size of this rectangle to the provided ones. * * @param location * The new location * @param size * The new size * @return this for convenience * @since 3.7 */ public Rectangle setBounds(Point location, Dimension size) { return setBounds(location.x(), location.y(), size.width(), size.height()); } /** * Sets the parameters of this Rectangle from the Rectangle passed in and * returns this for convenience. * * @return this for convenience * @param rect * Rectangle providing the bounding values * @since 2.0 */ public Rectangle setBounds(Rectangle rect) { return setBounds(rect.x(), rect.y(), rect.width(), rect.height()); } /** * Sets the height of this Rectangle to the specified one. * * @param height * The new height * @return this for convenience. * @since 3.7 */ public Rectangle setHeight(int height) { this.height = height; return this; } /** * Sets the location of this Rectangle to the coordinates given as input and * returns this for convenience. * * @param x * The new X coordinate * @param y * The new Y coordinate * @return this for convenience * @since 2.0 */ public Rectangle setLocation(int x, int y) { this.x = x; this.y = y; return this; } /** * Sets the location of this Rectangle to the point given as input and * returns this for convenience. * * @return this for convenience * @param p * New position of this Rectangle * @since 2.0 */ public Rectangle setLocation(Point p) { return setLocation(p.x(), p.y()); } /** * Sets the width and height of this Rectangle to the width and height of * the given Dimension and returns this for convenience. * * @param d * The new Dimension * @return this for convenience * @since 2.0 */ public Rectangle setSize(Dimension d) { return setSize(d.width(), d.height()); } /** * Sets the width of this Rectangle to w and the height of this * Rectangle to h and returns this for convenience. * * @return this for convenience * @param w * The new width * @param h * The new height * @since 2.0 */ public Rectangle setSize(int w, int h) { width = w; height = h; return this; } /** * Sets the width of this Rectangle to the specified one. * * @param width * The new width * @return this for convenience. * @since 3.7 */ public Rectangle setWidth(int width) { this.width = width; return this; } /** * Sets the x value of the Rectangle and returns this for convenience. * * @return this for convenience * @param x * The new x value * @since 3.7 */ public Rectangle setX(int x) { this.x = x; return this; } /** * Sets the y value of the Rectangle and returns this for convenience. * * @return this for convenience * @param y * The new y value * @since 3.7 */ public Rectangle setY(int y) { this.y = y; return this; } /** * Shrinks this rectangle by the amount specified in insets. * * @param insets * Insets to be removed from the Rectangle * @return this for convenience * @since 3.7 */ public Rectangle shrink(Insets insets) { if (insets == null) return this; x += insets.left; y += insets.top; width -= (insets.getWidth()); height -= (insets.getHeight()); return this; } /** * Shrinks the sides of this Rectangle by the horizontal and vertical values * provided as input, and returns this Rectangle for convenience. The center * of this Rectangle is kept constant. * * @param h * Horizontal reduction amount * @param v * Vertical reduction amount * @return this for convenience * @since 2.0 */ public Rectangle shrink(int h, int v) { x += h; width -= (h + h); y += v; height -= (v + v); return this; } /** * Returns the description of this Rectangle. * * @return String containing the description * @since 2.0 */ public String toString() { return "Rectangle(" + x + ", " + y + ", " + //$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$ width + ", " + height + ")";//$NON-NLS-2$//$NON-NLS-1$ } /** * Returns true if the input Rectangle touches this Rectangle. * * @param rect * Rectangle being checked for contact * @return true if rect touches this Rectangle * @since 2.0 */ public boolean touches(Rectangle rect) { return rect.x() <= x + width && rect.y() <= y + height && rect.x() + rect.width() >= x && rect.y() + rect.height() >= y; } /** * Moves this Rectangle horizontally by dx and vertically by dy, then * returns this Rectangle for convenience. * * @param dx * Shift along X axis * @param dy * Shift along Y axis * @return this for convenience * @since 2.0 */ public Rectangle translate(int dx, int dy) { x += dx; y += dy; return this; } /** * Moves this Rectangle horizontally by the x value of the given Point and * vertically by the y value of the given Point, then returns this Rectangle * for convenience. * * @param p * Point which provides translation information * @return this for convenience */ public Rectangle translate(Point p) { x += p.x; y += p.y; return this; } /** * Switches the x and y values, as well as the width and height of this * Rectangle. Useful for orientation changes. * * @return this for convenience * @since 2.0 */ public Rectangle transpose() { int temp = x; x = y; y = temp; temp = width; width = height; height = temp; return this; } /** * Unions this Rectangle's width and height with the specified Dimension. * * @param d * Dimension being unioned * @return this for convenience * @since 2.0 * @deprecated Union with a dimension generally does not make much sense, * thus deprecating this. Use * {@link Dimension#max(Dimension, Dimension)} and * {@link #setSize(Dimension)} to implement the desired behavior * instead. */ public Rectangle union(Dimension d) { width = Math.max(width, d.width); height = Math.max(height, d.height); return this; } /** * Updates this Rectangle's bounds to the minimum size which can hold both * this Rectangle and the coordinate (x,y). * * @return this for convenience * @param x1 * X coordinate * @param y1 * Y coordinate * @since 2.0 */ public Rectangle union(int x1, int y1) { if (x1 < x) { width += (x - x1); x = x1; } else { int right = x + width; if (x1 >= right) { right = x1 + 1; width = right - x; } } if (y1 < y) { height += (y - y1); y = y1; } else { int bottom = y + height; if (y1 >= bottom) { bottom = y1 + 1; height = bottom - y; } } return this; } /** * Updates this Rectangle's dimensions to the minimum size which can hold * both this Rectangle and the rectangle (x, y, w, h). * * @param x * X coordinate of desired union. * @param y * Y coordinate of desired union. * @param w * Width of desired union. * @param h * Height of desired union. * @return this for convenience * @since 2.0 */ public Rectangle union(int x, int y, int w, int h) { int right = Math.max(this.x + width, x + w); int bottom = Math.max(this.y + height, y + h); this.x = Math.min(this.x, x); this.y = Math.min(this.y, y); this.width = right - this.x; this.height = bottom - this.y; return this; } /** * Updates this Rectangle's bounds to the minimum size which can hold both * this Rectangle and the given Point. * * @param p * Point to be unioned with this Rectangle * @since 2.0 */ public void union(Point p) { // TODO: This should for the sake of consistency also return this // by convenience; however, this is regarded as API break so it // may be done not sooner than in 4.0; if this is done, it has // to be ensured that the overwritten method in PrecisionRectangle // is adjusted as well. union(p.x(), p.y()); } /** * Updates this Rectangle's dimensions to the minimum size which can hold * both this Rectangle and the given Rectangle. * * @return this for convenience * @param rect * Rectangle to be unioned with this Rectangle * @since 2.0 */ public Rectangle union(Rectangle rect) { if (rect == null || rect.isEmpty()) return this; return union(rect.x, rect.y, rect.width, rect.height); } /** * Returns the current width of this Rectangle * * @return The current width * @since 3.7 */ public int width() { return width; } /** * Returns the x value of this Rectangle. * * @return The current x value * @since 3.7 */ public int x() { return x; } /** * Returns the y value of the Rectangle * * @return The current y value * @since 3.7 */ public int y() { return y; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/geometry/Straight.java000066400000000000000000000213751166301720600277630ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Research Group Software Construction, * RWTH Aachen University, Germany - initial API and implementation * *******************************************************************************/ package org.eclipse.draw2d.geometry; /** * Represents a straight line within 2-dimensional Euclidean space. * * @author Alexander Nyssen * @since 3.6 */ public class Straight { /** position vector of this straight */ public Vector position; /** direction vector of this straight */ public Vector direction; /** * Constructs a new Straight with the given position and direction. * * @param position * @param direction */ public Straight(Vector position, Vector direction) { if (direction.isNull()) { throw new IllegalArgumentException( "direction has to be unequal to (0,0)"); //$NON-NLS-1$ } this.position = position; this.direction = direction; } /** * Constructs a new Straight between the two given Points. * * @param point1 * a first waypoint of the Straight to be constructed * @param point2 * a second waypoint of the Straight to be constructed */ public Straight(PrecisionPoint point1, PrecisionPoint point2) { this(new Vector(point1), new Vector(point1, point2)); } /** * Checks whether this Straight and the provided one have an intersection * point. * * @param other * The Straight to use for the calculation. * @return true if the two Straights intersect, false otherwise. */ public boolean intersects(Straight other) { return direction.getDotProduct(other.direction .getOrthogonalComplement()) != 0; } /** * Checks whether this Straight and the provided one have an intersection * point, which is inside the specified segment between segmentStart and * segmentEnd. * * segmentStart a Vector indicating the start point of the segment. Has to * be a point on the straight. * * @param segmentEnd * a Vector indicating the end point of the segment. Has to be a * point on the straight. * @param other * the Straight to test * @return true if the true straights intersect and the intersection point * is contained within the specified segment, false otherwise. * @since 3.2 */ public boolean intersectsWithinSegment(Vector segmentStart, Vector segmentEnd, Straight other) { // precondition: segment start and end have to be points on this // straight. if (!contains(segmentStart) || !contains(segmentEnd)) { throw new IllegalArgumentException( "segment points have to be contained"); //$NON-NLS-1$ } // check if segmentStart->segmentEnd is a legal segment or a single // point Vector segmentDirection = segmentEnd.getSubtracted(segmentStart); if (segmentDirection.isNull()) { return other.contains(segmentStart); } // legal segment, check if there is an intersection within the segment if (intersects(other)) { Vector intersection = getIntersection(other); return containsWithinSegment(segmentStart, segmentEnd, intersection); } return false; } /** * Computes the intersection point of this Straight and the provided one, if * it exists. * * @param other * The Straight to use for calculations. * @return A Vector pointing to the intersection point, if it exists, null * if no intersection point exists (or the Straights are equal). */ public Vector getIntersection(Straight other) { // first check if there is a single intersection point if (!intersects(other)) { return null; } // calculate intersection point Vector s1 = direction.getMultiplied(other.position .getDotProduct(other.direction.getOrthogonalComplement())); Vector s2 = other.direction.getMultiplied(position .getDotProduct(direction.getOrthogonalComplement())); return s1.getSubtracted(s2).getDivided( direction.getDotProduct(other.direction .getOrthogonalComplement())); } /** * Returns the (smallest) angle between this Straight and the provided one. * * @param other * The Straight to be used for the calculation. * @return The angle spanned between the two Straights. */ public double getAngle(Straight other) { return direction.getAngle(other.direction); } /** * Returns the projection of the given Vector onto this Straight, which is * the point on this Straight with the minimal distance to the point, * denoted by the provided Vector. * * @param vector * The Vector whose projection should be determined. * @return A new Vector representing the projection of the provided Vector * onto this Straight. */ public Vector getProjection(Vector vector) { return getIntersection(new Straight(vector, direction.getOrthogonalComplement())); } /** * Returns the distance of the provided Vector to this Straight, which is * the distance between the provided Vector and its projection onto this * Straight. * * @param vector * The Vector whose distance is to be calculated. * @return the distance between this Straight and the provided Vector. */ public double getDistance(Vector vector) { return getProjection(vector).getSubtracted(vector).getLength(); } /** * Calculates whether the point indicated by the provided Vector is a point * on this Straight. * * @param vector * the Vector who has to be checked. * @return true if the point indicated by the given Vector is a point of * this Straight, false otherwise. */ public boolean contains(Vector vector) { return getDistance(vector) == 0; } /** * Calculates whether the point indicated by the provided Vector is a point * on the straight segment between the given start and end points. * * @param segmentStart * a Vector indicating the start point of the segment. Has to be * a point on the straight. * @param segmentEnd * a Vector indicating the end point of the segment. Has to be a * point on the straight. * @param vector * the Vector who has to be checked. * @return true if point indicated by the given Vector is a point on this * straight, within the specified segment, false otherwise. */ public boolean containsWithinSegment(Vector segmentStart, Vector segmentEnd, Vector vector) { // precondition: segment start and end have to be points on this // straight. if (!contains(segmentStart) || !contains(segmentEnd)) { throw new IllegalArgumentException( "segment points have to be contained"); //$NON-NLS-1$ } // check if segmentStart->segmentEnd is a legal segment or a single // point Vector segmentDirection = segmentEnd.getSubtracted(segmentStart); if (segmentDirection.isNull()) { return segmentStart.equals(vector); } // legal segment if (new Straight(segmentStart, segmentDirection).contains(vector)) { // compute parameter s, so that vector = segmentStart + s * // (segmentEnd - segmentStart). double s = segmentDirection.isVertical() ? (vector.y - segmentStart.y) / segmentDirection.y : (vector.x - segmentStart.x) / segmentDirection.x; // if s is between 0 and 1, intersection point lies within // segment if (0 <= s && s <= 1) { return true; } } return false; } /** * Checks whether this Straight and the provided one are parallel to each * other. * * @param other * The Straight to test for parallelism. * @return true if the direction vectors of this Straight and the provided * one are parallel, false otherwise. */ public boolean isParallelTo(Straight other) { return direction.isParallelTo(other.direction); } /** * Checks whether this Straight is equal to the provided Straight. Two * Straights s1 and s2 are equal, if the position vector of s2 is a point on * s1 and the direction vectors of s1 and s2 are parallel. * * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object other) { if (!(other instanceof Straight)) { return false; } else { Straight otherStraight = (Straight) other; return contains(otherStraight.position) && isParallelTo(otherStraight); } } /** * @see java.lang.Object#hashCode() */ public int hashCode() { return position.hashCode() + direction.hashCode(); } /** * @see java.lang.Object#toString() */ public String toString() { return position.toString() + " + s * " + direction.toString(); //$NON-NLS-1$ } }eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/geometry/Transform.java000066400000000000000000000042541166301720600301460ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.geometry; /** * Provides support for transformations of scaling, translation and rotation. */ public class Transform { private double scaleX = 1.0, scaleY = 1.0, dx, dy, cos = 1.0, sin; /** * Sets the value for the amount of scaling to be done along both axes. * * @param scale * Scale factor * @since 2.0 */ public void setScale(double scale) { scaleX = scaleY = scale; } /** * Sets the value for the amount of scaling to be done along X and Y axes * individually. * * @param x * Amount of scaling on X axis * @param y * Amount of scaling on Y axis * @since 2.0 */ public void setScale(double x, double y) { scaleX = x; scaleY = y; } /** * Sets the rotation angle. * * @param angle * Angle of rotation * @since 2.0 */ public void setRotation(double angle) { cos = Math.cos(angle); sin = Math.sin(angle); } /** * Sets the translation amounts for both axes. * * @param x * Amount of shift on X axis * @param y * Amount of shift on Y axis * @since 2.0 */ public void setTranslation(double x, double y) { dx = x; dy = y; } /** * Returns a new transformed Point of the input Point based on the * transformation values set. * * @param p * Point being transformed * @return The transformed Point * @since 2.0 */ public Point getTransformed(Point p) { double x = p.x; double y = p.y; double temp; x *= scaleX; y *= scaleY; temp = x * cos - y * sin; y = x * sin + y * cos; x = temp; return new Point(Math.round(x + dx), Math.round(y + dy)); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/geometry/Translatable.java000066400000000000000000000022221166301720600306000ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.geometry; /** * A translatable object can be translated (or moved) vertically and/or * horizontally. */ public interface Translatable { /** * Translates this object horizontally by dx and vertically by * dy. * * @param dx * The amount to translate horizontally * @param dy * The amount to translate vertically * @since 2.0 */ void performTranslate(int dx, int dy); /** * Scales this object by the scale factor. * * @param factor * The scale factor * @since 2.0 */ void performScale(double factor); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/geometry/Transposer.java000066400000000000000000000050551166301720600303330ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.geometry; /** * Conditionally transposes geometrical objects based on an "enabled" flag. When * enabled, the method t(Object) will transpose the passed geometrical object. * Otherwise, the object will be returned without modification */ public class Transposer { private boolean enabled = false; /** * Disables transposing of inputs. * * @since 2.0 */ public void disable() { enabled = false; } /** * Enables transposing of inputs. * * @since 2.0 */ public void enable() { enabled = true; } /** * Returns true if this Transposer is enabled. * * @return true if this Transposer is enabled * @since 2.0 */ public boolean isEnabled() { return enabled; } /** * Sets the enabled state of this Transposer. * * @param e * New enabled value * @since 2.0 */ public void setEnabled(boolean e) { enabled = e; } /** * Returns a new transposed Dimension of the input Dimension. * * @param d * Input dimension being transposed. * @return The new transposed dimension. * @since 2.0 */ public Dimension t(Dimension d) { if (isEnabled()) return d.getTransposed(); return d; } /** * Returns a new transposed Insets of the input Insets. * * @param i * Insets to be transposed. * @return The new transposed Insets. * @since 2.0 */ public Insets t(Insets i) { if (isEnabled()) return i.getTransposed(); return i; } /** * Returns a new transposed Point of the input Point. * * @param p * Point to be transposed. * @return The new transposed Point. * @since 2.0 */ public Point t(Point p) { if (isEnabled()) return p.getTransposed(); return p; } /** * Returns a new transposed Rectangle of the input Rectangle. * * @param r * Rectangle to be transposed. * @return The new trasnposed Rectangle. * @since 2.0 */ public Rectangle t(Rectangle r) { if (isEnabled()) return r.getTransposed(); return r; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/geometry/Vector.java000066400000000000000000000202271166301720600274330ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation * Research Group Software Construction, * RWTH Aachen University, Germany - Contribution for Bugzilla 245182 * *******************************************************************************/ package org.eclipse.draw2d.geometry; /** * Represents a vector within 2-dimensional Euclidean space. * * @since 3.6 */ public class Vector { /** the X value */ public double x; /** the Y value */ public double y; // internal constant used for comparisons. private static final Vector NULL = new Vector(0, 0); /** * Constructs a Vector pointed in the specified direction. * * @param x * X value. * @param y * Y value. */ public Vector(double x, double y) { this.x = x; this.y = y; } /** * Constructs a Vector pointed in the direction specified by a Point. * * @param p * the point */ public Vector(PrecisionPoint p) { x = p.preciseX(); y = p.preciseY(); } /** * Constructs a Vector representing the direction and magnitude between to * provided Points. * * @param start * starting point * @param end * End Point */ public Vector(PrecisionPoint start, PrecisionPoint end) { x = end.preciseX() - start.preciseX(); y = end.preciseY() - start.preciseY(); } /** * Constructs a Vector representing the difference between two provided * Vectors. * * @param start * The start Ray * @param end * The end Ray */ public Vector(Vector start, Vector end) { x = end.x - start.x; y = end.y - start.y; } /** * Calculates the magnitude of the cross product of this Vector with * another. Represents the amount by which two Vectors are directionally * different. Parallel Vectors return a value of 0. * * @param other * Vector being compared * @return The dissimilarity */ public double getDissimilarity(Vector other) { return PrecisionGeometry.preciseAbs(getCrossProduct(other)); } /** * Calculates whether this Vector and the provided one are parallel to each * other. * * @param other * The Vector to test for parallelism * @return true if this Vector and the provided one are parallel, false * otherwise. */ public boolean isParallelTo(Vector other) { return getDissimilarity(other) == 0; } /** * Calculates the dot product of this Vector with another. * * @param other * the Vector used to calculate the dot product * @return The dot product */ public double getDotProduct(Vector other) { return PrecisionGeometry.preciseAdd( PrecisionGeometry.preciseMultiply(x, other.x), PrecisionGeometry.preciseMultiply(y, other.y)); } /** * Calculates the cross product of this Vector with another. * * @param other * the Vector used to calculate the cross product * @return The cross product. */ public double getCrossProduct(Vector other) { return PrecisionGeometry.preciseSubtract( PrecisionGeometry.preciseMultiply(x, other.y), PrecisionGeometry.preciseMultiply(y, other.x)); } /** * Creates a new Vector which is the sum of this Vector with another. * * @param other * Vector to be added to this Vector * @return a new Vector representing the sum */ public Vector getAdded(Vector other) { return new Vector(PrecisionGeometry.preciseAdd(x, other.x), PrecisionGeometry.preciseAdd(y, other.y)); } /** * Creates a new Vector which is the difference of this Vector with the * provided Vector. * * @param other * Vector to be subtracted from this Vector * @return a new Vector representing the difference. */ public Vector getSubtracted(Vector other) { return new Vector(PrecisionGeometry.preciseSubtract(x, other.x), PrecisionGeometry.preciseSubtract(y, other.y)); } /** * Returns the angle (in degrees) between this Vector and the provided * Vector. * * @param other * Vector to calculate the angle. * @return the angle between the two Vectors in degrees. */ public double getAngle(Vector other) { double cosAlpha = PrecisionGeometry.preciseDivide( getDotProduct(other), (PrecisionGeometry.preciseMultiply(getLength(), other.getLength()))); return Math.toDegrees(Math.acos(cosAlpha)); } /** * Creates a new Vector which represents the average of this Vector with * another. * * @param other * Vector to calculate the average. * @return a new Vector */ public Vector getAveraged(Vector other) { return new Vector(PrecisionGeometry.preciseDivide( PrecisionGeometry.preciseAdd(x, other.x), 2), PrecisionGeometry.preciseDivide( PrecisionGeometry.preciseAdd(y, other.y), 2)); } /** * Creates a new Vector which represents this Vector multiplied by the * provided scalar factor. * * @param factor * Value providing the amount to scale. * @return a new Vector */ public Vector getMultiplied(double factor) { return new Vector(PrecisionGeometry.preciseMultiply(x, factor), PrecisionGeometry.preciseMultiply(y, factor)); } /** * Creates a new Vector which represents this Vector divided by the provided * scalar factor. * * @param factor * Value providing the amount to scale. * @return a new Vector */ public Vector getDivided(double factor) { return new Vector(PrecisionGeometry.preciseDivide(x, factor), PrecisionGeometry.preciseDivide(y, factor)); } /** * Returns the orthogonal complement of this Vector, which is defined to be * (-y, x). * * @return the orthogonal complement of this Vector */ public Vector getOrthogonalComplement() { return new Vector(PrecisionGeometry.preciseNegate(y), x); } /** * Returns the length of this Vector. * * @return Length of this Vector */ public double getLength() { return Math.sqrt(getDotProduct(this)); } /** * Calculates the similarity of this Vector with another. Similarity is * defined as the absolute value of the dotProduct(). Orthogonal vectors * return a value of 0. * * @param other * Vector being tested for similarity * @return the Similarity * @see #getDissimilarity(Vector) */ public double getSimilarity(Vector other) { return PrecisionGeometry.preciseAbs(getDotProduct(other)); } /** * Calculates whether this Vector and the provided one are orthogonal to * each other. * * @param other * Vector being tested for orthogonality * @return true, if this Vector and the provide one are orthogonal, false * otherwise */ public boolean isOrthogonalTo(Vector other) { return getSimilarity(other) == 0; } /** * Checks whether this vector has a horizontal component. * * @return true if x != 0, false otherwise. */ public boolean isHorizontal() { return x != 0; } /** * Checks whether this vector has a vertical component. * * @return true if y != 0, false otherwise. */ public boolean isVertical() { return y != 0; } /** * Checks whether this vector equals (0,0); * * @return true if x == 0 and y == 0. */ public boolean isNull() { return equals(NULL); } /** * Returns a point representation of this Vector. * * @return a PrecisionPoint representation */ public PrecisionPoint toPoint() { return new PrecisionPoint(x, y); } /** * @see java.lang.Object#toString() */ public String toString() { return "(" + x + "," + y + ")";//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$ } /** * @see java.lang.Object#equals(Object) */ public boolean equals(Object obj) { if (obj == this) return true; if (obj instanceof Vector) { Vector r = (Vector) obj; return x == r.x && y == r.y; } return false; } /** * @see java.lang.Object#hashCode() */ public int hashCode() { return (int) x + (int) y; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/geometry/package.html000066400000000000000000000002761166301720600276110ustar00rootroot00000000000000 Types representing or manipulating geometric values, such as Points, Dimensions, etc. eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/000077500000000000000000000000001166301720600245715ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/BreakCycles.java000066400000000000000000000156771166301720600276430ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import java.util.ArrayList; import java.util.List; /** * This visitor eliminates cycles in the graph using a "greedy" heuristic. Nodes * which are sources and sinks are marked and placed in a source and sink list, * leaving only nodes involved in cycles. A remaining node with the highest * (outgoing-incoming) edges score is then chosen greedily as if it were a * source. The process is repeated until all nodes have been marked and placed * in a list. The lists are then concatenated, and any edges which go backwards * in this list will be inverted during the layout procedure. * * @author Daniel Lee * @since 2.1.2 */ class BreakCycles extends GraphVisitor { // Used in identifying cycles and in cycle removal. // Flag field indicates "presence". If true, the node has been removed from // the list. NodeList graphNodes = new NodeList(); private boolean allNodesFlagged() { for (int i = 0; i < graphNodes.size(); i++) { if (graphNodes.getNode(i).flag == false) return false; } return true; } private void breakCycles(DirectedGraph g) { initializeDegrees(g); greedyCycleRemove(g); invertEdges(g); } /* * Returns true if g contains cycles, false otherwise */ private boolean containsCycles(DirectedGraph g) { List noLefts = new ArrayList(); // Identify all initial nodes for removal for (int i = 0; i < graphNodes.size(); i++) { Node node = graphNodes.getNode(i); if (getIncomingCount(node) == 0) sortedInsert(noLefts, node); } while (noLefts.size() > 0) { Node node = (Node) noLefts.remove(noLefts.size() - 1); node.flag = true; for (int i = 0; i < node.outgoing.size(); i++) { Node right = node.outgoing.getEdge(i).target; setIncomingCount(right, getIncomingCount(right) - 1); if (getIncomingCount(right) == 0) sortedInsert(noLefts, right); } } if (allNodesFlagged()) return false; return true; } /* * Returns the node in graphNodes with the largest (outgoing edge count - * incoming edge count) value */ private Node findNodeWithMaxDegree() { int max = Integer.MIN_VALUE; Node maxNode = null; for (int i = 0; i < graphNodes.size(); i++) { Node node = graphNodes.getNode(i); if (getDegree(node) >= max && node.flag == false) { max = getDegree(node); maxNode = node; } } return maxNode; } private int getDegree(Node n) { return n.workingInts[3]; } private int getIncomingCount(Node n) { return n.workingInts[0]; } private int getInDegree(Node n) { return n.workingInts[1]; } private int getOrderIndex(Node n) { return n.workingInts[0]; } private int getOutDegree(Node n) { return n.workingInts[2]; } private void greedyCycleRemove(DirectedGraph g) { NodeList sL = new NodeList(); NodeList sR = new NodeList(); do { // Add all sinks and isolated nodes to sR boolean hasSink; do { hasSink = false; for (int i = 0; i < graphNodes.size(); i++) { Node node = graphNodes.getNode(i); if (getOutDegree(node) == 0 && node.flag == false) { hasSink = true; node.flag = true; updateIncoming(node); sR.add(node); break; } } } while (hasSink); // Add all sources to sL boolean hasSource; do { hasSource = false; for (int i = 0; i < graphNodes.size(); i++) { Node node = graphNodes.getNode(i); if (getInDegree(node) == 0 && node.flag == false) { hasSource = true; node.flag = true; updateOutgoing(node); sL.add(node); break; } } } while (hasSource); // When all sinks and sources are removed, choose a node with the // maximum degree (outDegree - inDegree) and add it to sL Node max = findNodeWithMaxDegree(); if (max != null) { sL.add(max); max.flag = true; updateIncoming(max); updateOutgoing(max); } } while (!allNodesFlagged()); // Assign order indexes int orderIndex = 0; for (int i = 0; i < sL.size(); i++) { setOrderIndex(sL.getNode(i), orderIndex++); } for (int i = sR.size() - 1; i >= 0; i--) { setOrderIndex(sR.getNode(i), orderIndex++); } } private void initializeDegrees(DirectedGraph g) { graphNodes.resetFlags(); for (int i = 0; i < g.nodes.size(); i++) { Node n = graphNodes.getNode(i); setInDegree(n, n.incoming.size()); setOutDegree(n, n.outgoing.size()); setDegree(n, n.outgoing.size() - n.incoming.size()); } } private void invertEdges(DirectedGraph g) { for (int i = 0; i < g.edges.size(); i++) { Edge e = g.edges.getEdge(i); if (getOrderIndex(e.source) > getOrderIndex(e.target)) { e.invert(); e.isFeedback = true; } } } private void setDegree(Node n, int deg) { n.workingInts[3] = deg; } private void setIncomingCount(Node n, int count) { n.workingInts[0] = count; } private void setInDegree(Node n, int deg) { n.workingInts[1] = deg; } private void setOutDegree(Node n, int deg) { n.workingInts[2] = deg; } private void setOrderIndex(Node n, int index) { n.workingInts[0] = index; } private void sortedInsert(List list, Node node) { int insert = 0; while (insert < list.size() && ((Node) list.get(insert)).sortValue > node.sortValue) insert++; list.add(insert, node); } /* * Called after removal of n. Updates the degree values of n's incoming * nodes. */ private void updateIncoming(Node n) { for (int i = 0; i < n.incoming.size(); i++) { Node in = n.incoming.getEdge(i).source; if (in.flag == false) { setOutDegree(in, getOutDegree(in) - 1); setDegree(in, getOutDegree(in) - getInDegree(in)); } } } /* * Called after removal of n. Updates the degree values of n's outgoing * nodes. */ private void updateOutgoing(Node n) { for (int i = 0; i < n.outgoing.size(); i++) { Node out = n.outgoing.getEdge(i).target; if (out.flag == false) { setInDegree(out, getInDegree(out) - 1); setDegree(out, getOutDegree(out) - getInDegree(out)); } } } public void revisit(DirectedGraph g) { for (int i = 0; i < g.edges.size(); i++) { Edge e = g.edges.getEdge(i); if (e.isFeedback()) e.invert(); } } /** * @see GraphVisitor#visit(org.eclipse.draw2d.graph.DirectedGraph) */ public void visit(DirectedGraph g) { // put all nodes in list, initialize index graphNodes.resetFlags(); for (int i = 0; i < g.nodes.size(); i++) { Node n = g.nodes.getNode(i); setIncomingCount(n, n.incoming.size()); graphNodes.add(n); } if (containsCycles(g)) { breakCycles(g); } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/Cell.java000066400000000000000000000013211166301720600263100ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2005, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; public class Cell { public int index; public int rank; public Cell(int rank, int index) { this.rank = rank; this.index = index; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/CollapsedEdges.java000066400000000000000000000044451166301720600303210ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2005, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; /** * Contains the information from all edges going from a given cluster to some * other cluster. An edge with minimal slack as chosen to maintain the link * between clusters. The weight and any slack more than the minimal edge's slack * is tracked for all other edges. * * @since 3.1 */ class CollapsedEdges { /** * The total weight of the collapsed edges. */ int collapsedWeight; int collapsedCount; /** * The total amount of weighted difference in the collapsed edges slack and * the tightest edge's slack. */ int overage; int unOverage; Edge tightestEdge; CollapsedEdges(Edge edge) { tightestEdge = edge; collapsedWeight = edge.weight; collapsedCount++; } public int getWeightedPull() { return tightestEdge.getSlack() * collapsedWeight + overage; } public boolean isTight() { return tightestEdge.getSlack() == 0; } /** * Compares the given edge to the current tightest edge. If the given edge * is tighter than the current, the current tightest is returned. Otherwise, * the edge itself is returned. The returned edge would be the one to remove * from the graph. * * @param candidate * another edge * @return the edge which is not the tightest edge * @since 3.1 */ Edge processEdge(Edge candidate) { collapsedCount++; if (candidate.getSlack() < tightestEdge.getSlack()) { overage += collapsedWeight * (tightestEdge.getSlack() - candidate.getSlack()); Edge temp = tightestEdge; tightestEdge = candidate; collapsedWeight += candidate.weight; return temp; } else { int over = candidate.getSlack() - tightestEdge.getSlack(); unOverage += over; overage += candidate.weight * over; collapsedWeight += candidate.weight; return candidate; } } }eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/CompoundBreakCycles.java000066400000000000000000000306331166301720600313350ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; /** * This visitor eliminates cycles in the graph via a modified implementation of * the greedy cycle removal algorithm for directed graphs. The algorithm has * been modified to handle the presence of Subgraphs and compound cycles which * may result. This algorithm determines a set of edges which can be inverted * and result in a graph without compound cycles. * * @author Daniel Lee * @author Randy Hudson * @since 2.1.2 */ class CompoundBreakCycles extends GraphVisitor { /* * Caches all nodes in the graph. Used in identifying cycles and in cycle * removal. Flag field indicates "presence". If true, the node has been * removed from the list. */ private NodeList graphNodes; private NodeList sL = new NodeList(); private boolean allFlagged(NodeList nodes) { for (int i = 0; i < nodes.size(); i++) { if (nodes.getNode(i).flag == false) return false; } return true; } private int buildNestingTreeIndices(NodeList nodes, int base) { for (int i = 0; i < nodes.size(); i++) { Node node = (Node) nodes.get(i); if (node instanceof Subgraph) { Subgraph s = (Subgraph) node; s.nestingTreeMin = base; base = buildNestingTreeIndices(s.members, base); } node.nestingIndex = base++; } return base++; } private boolean canBeRemoved(Node n) { return !n.flag && getChildCount(n) == 0; } private boolean changeInDegree(Node n, int delta) { return (n.workingInts[1] += delta) == 0; } private boolean changeOutDegree(Node n, int delta) { return (n.workingInts[2] += delta) == 0; } /* * Execution of the modified greedy cycle removal algorithm. */ private void cycleRemove(NodeList children) { NodeList sR = new NodeList(); do { findSinks(children, sR); findSources(children); // all sinks and sources added, find node with highest // outDegree - inDegree Node max = findNodeWithMaxDegree(children); if (max != null) { for (int i = 0; i < children.size(); i++) { Node child = (Node) children.get(i); if (child.flag) continue; if (child == max) restoreSinks(max, sR); else restoreSources(child); } remove(max); } } while (!allFlagged(children)); while (!sR.isEmpty()) sL.add(sR.remove(sR.size() - 1)); } private void findInitialSinks(NodeList children, NodeList sinks) { for (int i = 0; i < children.size(); i++) { Node node = children.getNode(i); if (node.flag) continue; if (isSink(node) && canBeRemoved(node)) { sinks.add(node); node.flag = true; } if (node instanceof Subgraph) findInitialSinks(((Subgraph) node).members, sinks); } } private void findInitialSources(NodeList children, NodeList sources) { for (int i = 0; i < children.size(); i++) { Node node = children.getNode(i); if (isSource(node) && canBeRemoved(node)) { sources.add(node); node.flag = true; } if (node instanceof Subgraph) findInitialSources(((Subgraph) node).members, sources); } } private Node findNodeWithMaxDegree(NodeList nodes) { int max = Integer.MIN_VALUE; Node maxNode = null; for (int i = 0; i < nodes.size(); i++) { Node node = nodes.getNode(i); if (node.flag) continue; int degree = getNestedOutDegree(node) - getNestedInDegree(node); if (degree >= max && node.flag == false) { max = degree; maxNode = node; } } return maxNode; } /* * Finds all sinks in graphNodes and adds them to the passed NodeList */ private void findSinks(NodeList children, NodeList rightList) { // NodeList rightList = new NodeList(); NodeList sinks = new NodeList(); findInitialSinks(children, sinks); while (!sinks.isEmpty()) { Node sink = sinks.getNode(sinks.size() - 1); rightList.add(sink); sinks.remove(sink); removeSink(sink, sinks); // Check to see if the removal has made the parent node a sink if (sink.getParent() != null) { Node parent = sink.getParent(); setChildCount(parent, getChildCount(parent) - 1); if (isSink(parent) && canBeRemoved(parent)) { sinks.add(parent); parent.flag = true; } } } } /* * Finds all sources in graphNodes and adds them to the sL NodeList. */ private void findSources(NodeList children) { NodeList sources = new NodeList(); findInitialSources(children, sources); while (!sources.isEmpty()) { Node source = sources.getNode(sources.size() - 1); sL.add(source); sources.remove(source); removeSource(source, sources); // Check to see if the removal has made the parent node a source if (source.getParent() != null) { Node parent = source.getParent(); setChildCount(parent, getChildCount(parent) - 1); if (isSource(parent) && canBeRemoved(parent)) { sources.add(parent); parent.flag = true; } } } } private int getChildCount(Node n) { return n.workingInts[3]; } private int getInDegree(Node n) { return n.workingInts[1]; } private int getNestedInDegree(Node n) { int result = getInDegree(n); if (n instanceof Subgraph) { Subgraph s = (Subgraph) n; for (int i = 0; i < s.members.size(); i++) if (!s.members.getNode(i).flag) result += getInDegree(s.members.getNode(i)); } return result; } private int getNestedOutDegree(Node n) { int result = getOutDegree(n); if (n instanceof Subgraph) { Subgraph s = (Subgraph) n; for (int i = 0; i < s.members.size(); i++) if (!s.members.getNode(i).flag) result += getOutDegree(s.members.getNode(i)); } return result; } private int getOrderIndex(Node n) { return n.workingInts[0]; } private int getOutDegree(Node n) { return n.workingInts[2]; } private void initializeDegrees(DirectedGraph g) { g.nodes.resetFlags(); g.edges.resetFlags(false); for (int i = 0; i < g.nodes.size(); i++) { Node n = g.nodes.getNode(i); setInDegree(n, n.incoming.size()); setOutDegree(n, n.outgoing.size()); if (n instanceof Subgraph) setChildCount(n, ((Subgraph) n).members.size()); else setChildCount(n, 0); } } private void invertEdges(DirectedGraph g) { // Assign order indices int orderIndex = 0; for (int i = 0; i < sL.size(); i++) { setOrderIndex(sL.getNode(i), orderIndex++); } // Invert edges that are causing a cycle for (int i = 0; i < g.edges.size(); i++) { Edge e = g.edges.getEdge(i); if (getOrderIndex(e.source) > getOrderIndex(e.target) && !e.source.isNested(e.target) && !e.target.isNested(e.source)) { e.invert(); e.isFeedback = true; } } } /** * Removes all edges connecting the given subgraph to other nodes outside of * it. * * @param s * @param n */ private void isolateSubgraph(Subgraph subgraph, Node member) { Edge edge = null; for (int i = 0; i < member.incoming.size(); i++) { edge = member.incoming.getEdge(i); if (!subgraph.isNested(edge.source) && !edge.flag) removeEdge(edge); } for (int i = 0; i < member.outgoing.size(); i++) { edge = member.outgoing.getEdge(i); if (!subgraph.isNested(edge.target) && !edge.flag) removeEdge(edge); } if (member instanceof Subgraph) { NodeList members = ((Subgraph) member).members; for (int i = 0; i < members.size(); i++) isolateSubgraph(subgraph, members.getNode(i)); } } private boolean isSink(Node n) { return getOutDegree(n) == 0 && (n.getParent() == null || isSink(n.getParent())); } private boolean isSource(Node n) { return getInDegree(n) == 0 && (n.getParent() == null || isSource(n.getParent())); } private void remove(Node n) { n.flag = true; if (n.getParent() != null) setChildCount(n.getParent(), getChildCount(n.getParent()) - 1); removeSink(n, null); removeSource(n, null); sL.add(n); if (n instanceof Subgraph) { Subgraph s = (Subgraph) n; isolateSubgraph(s, s); cycleRemove(s.members); } } private boolean removeEdge(Edge e) { if (e.flag) return false; e.flag = true; changeOutDegree(e.source, -1); changeInDegree(e.target, -1); return true; } /** * Removes all edges between a parent and any of its children or * descendants. */ private void removeParentChildEdges(DirectedGraph g) { for (int i = 0; i < g.edges.size(); i++) { Edge e = g.edges.getEdge(i); if (e.source.isNested(e.target) || e.target.isNested(e.source)) removeEdge(e); } } private void removeSink(Node sink, NodeList allSinks) { for (int i = 0; i < sink.incoming.size(); i++) { Edge e = sink.incoming.getEdge(i); if (!e.flag) { removeEdge(e); Node source = e.source; if (allSinks != null && isSink(source) && canBeRemoved(source)) { allSinks.add(source); source.flag = true; } } } } private void removeSource(Node n, NodeList allSources) { for (int i = 0; i < n.outgoing.size(); i++) { Edge e = n.outgoing.getEdge(i); if (!e.flag) { e.flag = true; changeInDegree(e.target, -1); changeOutDegree(e.source, -1); Node target = e.target; if (allSources != null && isSource(target) && canBeRemoved(target)) { allSources.add(target); target.flag = true; } } } } /** * Restores an edge if it has been removed, and both of its nodes are not * removed. * * @param e * the edge * @return true if the edge was restored */ private boolean restoreEdge(Edge e) { if (!e.flag || e.source.flag || e.target.flag) return false; e.flag = false; changeOutDegree(e.source, 1); changeInDegree(e.target, 1); return true; } /** * Brings back all nodes nested in the given node. * * @param node * the node to restore * @param sr * current sinks */ private void restoreSinks(Node node, NodeList sR) { if (node.flag && sR.contains(node)) { node.flag = false; if (node.getParent() != null) setChildCount(node.getParent(), getChildCount(node.getParent()) + 1); sR.remove(node); for (int i = 0; i < node.incoming.size(); i++) { Edge e = node.incoming.getEdge(i); restoreEdge(e); } for (int i = 0; i < node.outgoing.size(); i++) { Edge e = node.outgoing.getEdge(i); restoreEdge(e); } } if (node instanceof Subgraph) { Subgraph s = (Subgraph) node; for (int i = 0; i < s.members.size(); i++) { Node member = s.members.getNode(i); restoreSinks(member, sR); } } } /** * Brings back all nodes nested in the given node. * * @param node * the node to restore * @param sr * current sinks */ private void restoreSources(Node node) { if (node.flag && sL.contains(node)) { node.flag = false; if (node.getParent() != null) setChildCount(node.getParent(), getChildCount(node.getParent()) + 1); sL.remove(node); for (int i = 0; i < node.incoming.size(); i++) { Edge e = node.incoming.getEdge(i); restoreEdge(e); } for (int i = 0; i < node.outgoing.size(); i++) { Edge e = node.outgoing.getEdge(i); restoreEdge(e); } } if (node instanceof Subgraph) { Subgraph s = (Subgraph) node; for (int i = 0; i < s.members.size(); i++) { Node member = s.members.getNode(i); restoreSources(member); } } } public void revisit(DirectedGraph g) { for (int i = 0; i < g.edges.size(); i++) { Edge e = g.edges.getEdge(i); if (e.isFeedback()) e.invert(); } } private void setChildCount(Node n, int count) { n.workingInts[3] = count; } private void setInDegree(Node n, int deg) { n.workingInts[1] = deg; } private void setOrderIndex(Node n, int index) { n.workingInts[0] = index; } private void setOutDegree(Node n, int deg) { n.workingInts[2] = deg; } /** * @see GraphVisitor#visit(org.eclipse.draw2d.graph.DirectedGraph) */ public void visit(DirectedGraph g) { initializeDegrees(g); graphNodes = g.nodes; NodeList roots = new NodeList(); for (int i = 0; i < graphNodes.size(); i++) { if (graphNodes.getNode(i).getParent() == null) roots.add(graphNodes.getNode(i)); } buildNestingTreeIndices(roots, 0); removeParentChildEdges(g); cycleRemove(roots); invertEdges(g); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/CompoundDirectedGraph.java000066400000000000000000000026131166301720600316500ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; /** * A DirectedGraph whose Nodes may be compound {@link Subgraph}s, * which may contain other nodes. Any node in the graph may be parented by one * subgraph. Since subgraphs are nodes, the source or target end of an * {@link Edge} may be a subgraph. For additional restrictions, refer to the * JavaDoc for the layout algorithm being used. *

    * A CompoundDirectedGraph is passed to a graph layout, which will position all * of the nodes, subgraphs, and edges in that graph. This class serves as the * data structure for a layout algorithm. * * @author Randy Hudson * @since 2.1.2 */ public class CompoundDirectedGraph extends DirectedGraph { /** * For internal use only. */ public NodeList subgraphs = new NodeList(); /** * For internal use only. */ public EdgeList containment = new EdgeList(); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/CompoundDirectedGraphLayout.java000066400000000000000000000046521166301720600330530ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; /** * Performs a graph layout on a CompoundDirectedGraph. The input * format is the same as for {@link DirectedGraphLayout}. All nodes, including * subgraphs and their children, should be added to the * {@link DirectedGraph#nodes} field. *

    * The requirements for this algorithm are the same as those of * DirectedGraphLayout, with the following exceptions: *

      *
    • There is an implied edge between a subgraph and each of its member nodes. * These edges form the containment graph T. Thus, the compound * directed graph CG is said to be connected iff Union(G, * T) is connected, where G represents the given nodes (including * subgraphs) and edges. * *
    • This algorithm will remove any compound cycles found in the input graph * G by inverting edges according to a heuristic until no more cycles * are found. A compound cycle is defined as: a cycle comprised of edges from * G, T, and T-1, in the form * (c*e+p*e+)*, where * T-1 is the backwards graph of T, c element of T, * e element of G, and p element of T-1. *
    * * @author Randy Hudson * @since 2.1.2 */ public final class CompoundDirectedGraphLayout extends DirectedGraphLayout { void init() { steps.add(new CompoundTransposeMetrics()); steps.add(new CompoundBreakCycles()); steps.add(new RouteEdges()); steps.add(new ConvertCompoundGraph()); steps.add(new InitialRankSolver()); steps.add(new TightSpanningTreeSolver()); steps.add(new RankAssignmentSolver()); steps.add(new CompoundPopulateRanks()); steps.add(new CompoundVerticalPlacement()); steps.add(new MinCross(new CompoundRankSorter())); steps.add(new SortSubgraphs()); steps.add(new CompoundHorizontalPlacement()); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/CompoundHorizontalPlacement.java000066400000000000000000000103151166301720600331230ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import java.util.HashSet; import java.util.Set; /** * Calculates the X-coordinates for nodes in a compound directed graph. * * @author Randy Hudson * @since 2.1.2 */ class CompoundHorizontalPlacement extends HorizontalPlacement { class LeftRight { // $TODO Delete and use NodePair class, equivalent Object left, right; LeftRight(Object l, Object r) { left = l; right = r; } public boolean equals(Object obj) { LeftRight entry = (LeftRight) obj; return entry.left.equals(left) && entry.right.equals(right); } public int hashCode() { return left.hashCode() ^ right.hashCode(); } } Set entries = new HashSet(); /** * @see org.eclipse.graph.HorizontalPlacement#applyGPrime() */ void applyGPrime() { super.applyGPrime(); NodeList subgraphs = ((CompoundDirectedGraph) graph).subgraphs; for (int i = 0; i < subgraphs.size(); i++) { Subgraph s = (Subgraph) subgraphs.get(i); s.x = s.left.x; s.width = s.right.x + s.right.width - s.x; } } /** * @see HorizontalPlacement#buildRankSeparators(RankList) */ void buildRankSeparators(RankList ranks) { CompoundDirectedGraph g = (CompoundDirectedGraph) graph; Rank rank; for (int row = 0; row < g.ranks.size(); row++) { rank = g.ranks.getRank(row); Node n = null, prev = null; for (int j = 0; j < rank.size(); j++) { n = rank.getNode(j); if (prev == null) { Node left = addSeparatorsLeft(n, null); if (left != null) { Edge e = new Edge(graphLeft, getPrime(left), 0, 0); prime.edges.add(e); e.delta = graph.getPadding(n).left + graph.getMargin().left; } } else { Subgraph s = GraphUtilities.getCommonAncestor(prev, n); Node left = addSeparatorsRight(prev, s); Node right = addSeparatorsLeft(n, s); createEdge(left, right); } prev = n; } if (n != null) addSeparatorsRight(n, null); } } void createEdge(Node left, Node right) { LeftRight entry = new LeftRight(left, right); if (entries.contains(entry)) return; entries.add(entry); int separation = left.width + graph.getPadding(left).right + graph.getPadding(right).left; prime.edges .add(new Edge(getPrime(left), getPrime(right), separation, 0)); } Node addSeparatorsLeft(Node n, Subgraph graph) { Subgraph parent = n.getParent(); while (parent != graph && parent != null) { createEdge(getLeft(parent), n); n = parent.left; parent = parent.getParent(); } return n; } Node addSeparatorsRight(Node n, Subgraph graph) { Subgraph parent = n.getParent(); while (parent != graph && parent != null) { createEdge(n, getRight(parent)); n = parent.right; parent = parent.getParent(); } return n; } Node getLeft(Subgraph s) { if (s.left == null) { s.left = new SubgraphBoundary(s, graph.getPadding(s), 1); s.left.rank = (s.head.rank + s.tail.rank) / 2; Node head = getPrime(s.head); Node tail = getPrime(s.tail); Node left = getPrime(s.left); Node right = getPrime(getRight(s)); prime.edges.add(new Edge(left, right, s.width, 0)); prime.edges.add(new Edge(left, head, 0, 1)); prime.edges.add(new Edge(head, right, 0, 1)); prime.edges.add(new Edge(left, tail, 0, 1)); prime.edges.add(new Edge(tail, right, 0, 1)); } return s.left; } Node getRight(Subgraph s) { if (s.right == null) { s.right = new SubgraphBoundary(s, graph.getPadding(s), 3); s.right.rank = (s.head.rank + s.tail.rank) / 2; } return s.right; } Node getPrime(Node n) { Node nPrime = get(n); if (nPrime == null) { nPrime = new Node(n); prime.nodes.add(nPrime); map(n, nPrime); } return nPrime; } public void visit(DirectedGraph g) { super.visit(g); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/CompoundPopulateRanks.java000066400000000000000000000045661166301720600317440ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import java.util.Iterator; /** * Places nodes into ranks for a compound directed graph. If a subgraph spans a * rank without any nodes which belong to that rank, a bridge node is inserted * to prevent nodes from violating the subgraph boundary. * * @author Randy Hudson * @since 2.1.2 */ class CompoundPopulateRanks extends PopulateRanks { public void visit(DirectedGraph g) { CompoundDirectedGraph graph = (CompoundDirectedGraph) g; /** * Remove long containment edges at this point so they don't affect * MinCross. */ Iterator containment = graph.containment.iterator(); while (containment.hasNext()) { Edge e = (Edge) containment.next(); if (e.getSlack() > 0) { graph.removeEdge(e); containment.remove(); } } super.visit(g); NodeList subgraphs = graph.subgraphs; for (int i = 0; i < subgraphs.size(); i++) { Subgraph subgraph = (Subgraph) subgraphs.get(i); bridgeSubgraph(subgraph, graph); } } /** * @param subgraph */ private void bridgeSubgraph(Subgraph subgraph, CompoundDirectedGraph g) { int offset = subgraph.head.rank; boolean occupied[] = new boolean[subgraph.tail.rank - subgraph.head.rank + 1]; Node bridge[] = new Node[occupied.length]; for (int i = 0; i < subgraph.members.size(); i++) { Node n = (Node) subgraph.members.get(i); if (n instanceof Subgraph) { Subgraph s = (Subgraph) n; for (int r = s.head.rank; r <= s.tail.rank; r++) occupied[r - offset] = true; } else occupied[n.rank - offset] = true; } for (int i = 0; i < bridge.length; i++) { if (!occupied[i]) { Node br = bridge[i] = new Node("bridge", subgraph); //$NON-NLS-1$ br.rank = i + offset; br.height = br.width = 0; br.nestingIndex = subgraph.nestingIndex; g.ranks.getRank(br.rank).add(br); g.nodes.add(br); } } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/CompoundRankSorter.java000066400000000000000000000107401166301720600312350ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import java.util.HashMap; import java.util.Iterator; import java.util.Map; /** * Sorts nodes in a compound directed graph. * * @author Randy Hudson * @since 2.1.2 */ class CompoundRankSorter extends RankSorter { static class RowEntry { double contribution; int count; void reset() { count = 0; contribution = 0; } } static class RowKey { int rank; Subgraph s; RowKey() { } RowKey(Subgraph s, int rank) { this.s = s; this.rank = rank; } public boolean equals(Object obj) { RowKey rp = (RowKey) obj; return rp.s == s && rp.rank == rank; } public int hashCode() { return s.hashCode() ^ (rank * 31); } } boolean init; RowKey key = new RowKey(); Map map = new HashMap(); void addRowEntry(Subgraph s, int row) { key.s = s; key.rank = row; if (!map.containsKey(key)) map.put(new RowKey(s, row), new RowEntry()); } protected void assignIncomingSortValues() { super.assignIncomingSortValues(); } protected void assignOutgoingSortValues() { super.assignOutgoingSortValues(); } void optimize(DirectedGraph g) { CompoundDirectedGraph graph = (CompoundDirectedGraph) g; Iterator containment = graph.containment.iterator(); while (containment.hasNext()) graph.removeEdge((Edge) containment.next()); graph.containment.clear(); new LocalOptimizer().visit(graph); } double evaluateNodeOutgoing() { double result = super.evaluateNodeOutgoing(); // result += Math.random() * rankSize * (1.0 - progress) / 3.0; if (progress > 0.2) { Subgraph s = node.getParent(); double connectivity = mergeConnectivity(s, node.rank + 1, result, progress); result = connectivity; } return result; } double evaluateNodeIncoming() { double result = super.evaluateNodeIncoming(); // result += Math.random() * rankSize * (1.0 - progress) / 3.0; if (progress > 0.2) { Subgraph s = node.getParent(); double connectivity = mergeConnectivity(s, node.rank - 1, result, progress); result = connectivity; } return result; } double mergeConnectivity(Subgraph s, int row, double result, double scaleFactor) { while (s != null && getRowEntry(s, row) == null) s = s.getParent(); if (s != null) { RowEntry entry = getRowEntry(s, row); double connectivity = entry.contribution / entry.count; result = connectivity * 0.3 + (0.7) * result; s = s.getParent(); } return result; } RowEntry getRowEntry(Subgraph s, int row) { key.s = s; key.rank = row; return (RowEntry) map.get(key); } void copyConstraints(NestingTree tree) { if (tree.subgraph != null) tree.sortValue = tree.subgraph.rowOrder; for (int i = 0; i < tree.contents.size(); i++) { Object child = tree.contents.get(i); if (child instanceof Node) { Node n = (Node) child; n.sortValue = n.rowOrder; } else { copyConstraints((NestingTree) child); } } } public void init(DirectedGraph g) { super.init(g); init = true; for (int row = 0; row < g.ranks.size(); row++) { Rank rank = g.ranks.getRank(row); NestingTree tree = NestingTree.buildNestingTreeForRank(rank); copyConstraints(tree); tree.recursiveSort(true); rank.clear(); tree.repopulateRank(rank); for (int j = 0; j < rank.count(); j++) { Node n = rank.getNode(j); Subgraph s = n.getParent(); while (s != null) { addRowEntry(s, row); s = s.getParent(); } } } } protected void postSort() { super.postSort(); if (init) updateRank(rank); } void updateRank(Rank rank) { for (int j = 0; j < rank.count(); j++) { Node n = rank.getNode(j); Subgraph s = n.getParent(); while (s != null) { getRowEntry(s, currentRow).reset(); s = s.getParent(); } } for (int j = 0; j < rank.count(); j++) { Node n = rank.getNode(j); Subgraph s = n.getParent(); while (s != null) { RowEntry entry = getRowEntry(s, currentRow); entry.count++; entry.contribution += n.index; s = s.getParent(); } } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/CompoundTransposeMetrics.java000066400000000000000000000032651166301720600324540ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2005, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import org.eclipse.draw2d.PositionConstants; /** * Performs transposing of subgraphics in a compound directed graph. * * @since 3.7.1 */ class CompoundTransposeMetrics extends TransposeMetrics { public void visit(DirectedGraph g) { if (g.getDirection() == PositionConstants.SOUTH) return; super.visit(g); int temp; CompoundDirectedGraph cg = (CompoundDirectedGraph) g; for (int i = 0; i < cg.subgraphs.size(); i++) { Node node = cg.subgraphs.getNode(i); temp = node.width; node.width = node.height; node.height = temp; if (node.getPadding() != null) node.setPadding(t.t(node.getPadding())); } } public void revisit(DirectedGraph g) { if (g.getDirection() == PositionConstants.SOUTH) return; super.revisit(g); int temp; CompoundDirectedGraph cg = (CompoundDirectedGraph) g; for (int i = 0; i < cg.subgraphs.size(); i++) { Node node = (Node) cg.subgraphs.get(i); temp = node.width; node.width = node.height; node.height = temp; temp = node.y; node.y = node.x; node.x = temp; if (node.getPadding() != null) node.setPadding(t.t(node.getPadding())); } } }eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/CompoundVerticalPlacement.java000066400000000000000000000022001166301720600325350ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; /** * calculates the height and y-coordinates for nodes and subgraphs in a compound * directed graph. * * @author Randy Hudson * @since 2.1.2 */ class CompoundVerticalPlacement extends VerticalPlacement { /** * @see GraphVisitor#visit(DirectedGraph) Extended to set subgraph values. */ void visit(DirectedGraph dg) { CompoundDirectedGraph g = (CompoundDirectedGraph) dg; super.visit(g); for (int i = 0; i < g.subgraphs.size(); i++) { Subgraph s = (Subgraph) g.subgraphs.get(i); s.y = s.head.y; s.height = s.tail.height + s.tail.y - s.y; } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/ConvertCompoundGraph.java000066400000000000000000000116571166301720600315550ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import org.eclipse.draw2d.geometry.Insets; /** * Converts a compound directed graph into a simple directed graph. * * @author Randy Hudson * @since 2.1.2 */ class ConvertCompoundGraph extends GraphVisitor { private void addContainmentEdges(CompoundDirectedGraph graph) { // For all nested nodes, connect to head and/or tail of containing // subgraph if present for (int i = 0; i < graph.nodes.size(); i++) { Node node = graph.nodes.getNode(i); Subgraph parent = node.getParent(); if (parent == null) continue; if (node instanceof Subgraph) { Subgraph sub = (Subgraph) node; connectHead(graph, sub.head, parent); connectTail(graph, sub.tail, parent); } else { connectHead(graph, node, parent); connectTail(graph, node, parent); } } } int buildNestingTreeIndices(NodeList nodes, int base) { for (int i = 0; i < nodes.size(); i++) { Node node = (Node) nodes.get(i); if (node instanceof Subgraph) { Subgraph s = (Subgraph) node; s.nestingTreeMin = base; base = buildNestingTreeIndices(s.members, base); } node.nestingIndex = base++; } return base++; } private void connectHead(CompoundDirectedGraph graph, Node node, Subgraph parent) { boolean connectHead = true; for (int j = 0; connectHead && j < node.incoming.size(); j++) { Node ancestor = node.incoming.getEdge(j).source; if (parent.isNested(ancestor)) connectHead = false; } if (connectHead) { Edge e = new Edge(parent.head, node); e.weight = 0; graph.edges.add(e); graph.containment.add(e); } } private void connectTail(CompoundDirectedGraph graph, Node node, Subgraph parent) { boolean connectTail = true; for (int j = 0; connectTail && j < node.outgoing.size(); j++) { Node ancestor = node.outgoing.getEdge(j).target; if (parent.isNested(ancestor)) connectTail = false; } if (connectTail) { Edge e = new Edge(node, parent.tail); e.weight = 0; graph.edges.add(e); graph.containment.add(e); } } private void convertSubgraphEndpoints(CompoundDirectedGraph graph) { for (int i = 0; i < graph.edges.size(); i++) { Edge edge = (Edge) graph.edges.get(i); if (edge.source instanceof Subgraph) { Subgraph s = (Subgraph) edge.source; Node newSource; if (s.isNested(edge.target)) newSource = s.head; else newSource = s.tail; // s.outgoing.remove(edge); edge.source = newSource; newSource.outgoing.add(edge); } if (edge.target instanceof Subgraph) { Subgraph s = (Subgraph) edge.target; Node newTarget; if (s.isNested(edge.source)) newTarget = s.tail; else newTarget = s.head; // s.incoming.remove(edge); edge.target = newTarget; newTarget.incoming.add(edge); } } } private void replaceSubgraphsWithBoundaries(CompoundDirectedGraph graph) { for (int i = 0; i < graph.subgraphs.size(); i++) { Subgraph s = (Subgraph) graph.subgraphs.get(i); graph.nodes.add(s.head); graph.nodes.add(s.tail); graph.nodes.remove(s); } } void revisit(DirectedGraph g) { for (int i = 0; i < g.edges.size(); i++) { Edge e = g.edges.getEdge(i); if (e.source instanceof SubgraphBoundary) { e.source.outgoing.remove(e); e.source = e.source.getParent(); } if (e.target instanceof SubgraphBoundary) { e.target.incoming.remove(e); e.target = e.target.getParent(); } } } /** * @see GraphVisitor#visit(org.eclipse.draw2d.graph.DirectedGraph) */ public void visit(DirectedGraph dg) { CompoundDirectedGraph graph = (CompoundDirectedGraph) dg; NodeList roots = new NodeList(); // Find all subgraphs and root subgraphs for (int i = 0; i < graph.nodes.size(); i++) { Object node = graph.nodes.get(i); if (node instanceof Subgraph) { Subgraph s = (Subgraph) node; Insets padding = dg.getPadding(s); s.head = new SubgraphBoundary(s, padding, 0); s.tail = new SubgraphBoundary(s, padding, 2); Edge headToTail = new Edge(s.head, s.tail); headToTail.weight = 10; graph.edges.add(headToTail); graph.containment.add(headToTail); graph.subgraphs.add(s); if (s.getParent() == null) roots.add(s); if (s.members.size() == 2) // The 2 being the head and tail only graph.edges.add(new Edge(s.head, s.tail)); } } buildNestingTreeIndices(roots, 0); convertSubgraphEndpoints(graph); addContainmentEdges(graph); replaceSubgraphsWithBoundaries(graph); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/DirectedGraph.java000066400000000000000000000124771166301720600301540ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import org.eclipse.draw2d.PositionConstants; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Insets; /** * A graph consisting of nodes and directed edges. A DirectedGraph serves as the * input to a graph layout algorithm. The algorithm will place the graph's nodes * and edges according to certain goals, such as short, non-crossing edges, and * readability. * * @author hudsonr * @since 2.1.2 */ public class DirectedGraph { private int direction = PositionConstants.SOUTH; /** * The default padding to be used for nodes which don't specify any padding. * Padding is the amount of empty space to be left around a node. The * default value is undefined. */ private Insets defaultPadding = new Insets(16); /** * All of the edges in the graph. */ public EdgeList edges = new EdgeList(); /** * All of the nodes in the graph. */ public NodeList nodes = new NodeList(); /** * For internal use only. The list of rows which makeup the final graph * layout. * * @deprecated */ public RankList ranks = new RankList(); Node forestRoot; Insets margin = new Insets(); int[] rankLocations; int[][] cellLocations; int tensorStrength; int tensorSize; Dimension size = new Dimension(); /** * Returns the default padding for nodes. * * @return the default padding * @since 3.2 */ public Insets getDefaultPadding() { return defaultPadding; } /** * Returns the direction in which the graph will be layed out. * * @return the layout direction * @since 3.2 */ public int getDirection() { return direction; } /** * Sets the outer margin for the entire graph. The margin is the space in * which nodes should not be placed. * * @return the graph's margin * @since 3.2 */ public Insets getMargin() { return margin; } /** * Returns the effective padding for the given node. If the node has a * specified padding, it will be used, otherwise, the graph's defaultPadding * is returned. The returned value must not be modified. * * @param node * the node * @return the effective padding for that node */ public Insets getPadding(Node node) { Insets pad = node.getPadding(); if (pad == null) return defaultPadding; return pad; } int[] getCellLocations(int rank) { return cellLocations[rank]; } int[] getRankLocations() { return rankLocations; } // // public Cell getCell(Point pt) { // int rank = 0; // while (rank < rankLocations.length - 1 && rankLocations[rank] < pt.y) // rank++; // int cells[] = cellLocations[rank]; // int cell = 0; // while (cell < cells.length - 1 && cells[cell] < pt.x) // cell++; // return new Cell(rank, cell, ranks.getRank(rank).getNode(index)); // } public Node getNode(int rank, int index) { if (ranks.size() <= rank) return null; Rank r = ranks.getRank(rank); if (r.size() <= index) return null; return r.getNode(index); } /** * Removes the given edge from the graph. * * @param edge * the edge to be removed */ public void removeEdge(Edge edge) { edges.remove(edge); edge.source.outgoing.remove(edge); edge.target.incoming.remove(edge); if (edge.vNodes != null) for (int j = 0; j < edge.vNodes.size(); j++) removeNode(edge.vNodes.getNode(j)); } /** * Removes the given node from the graph. Does not remove the node's edges. * * @param node * the node to remove */ public void removeNode(Node node) { nodes.remove(node); if (ranks != null) ranks.getRank(node.rank).remove(node); } /** * Sets the default padding for all nodes in the graph. Padding is the empty * space left around the outside of each node. The default padding * is used for all nodes which do not specify a specific amount of padding * (i.e., their padding is null). * * @param insets * the padding */ public void setDefaultPadding(Insets insets) { defaultPadding = insets; } /** * Sets the layout direction for the graph. Edges will be layed out in the * specified direction (unless the graph contains cycles). Supported values * are: *
      *
    • {@link org.eclipse.draw2d.PositionConstants#EAST} *
    • {@link org.eclipse.draw2d.PositionConstants#SOUTH} *
    *

    * The default direction is south. * * @param direction * the layout direction * @since 3.2 */ public void setDirection(int direction) { this.direction = direction; } // public void setGraphTensor(int length, int strength) { // tensorStrength = strength; // tensorSize = length; // } /** * Sets the graphs margin. * * @param insets * the graph's margin * @since 3.2 */ public void setMargin(Insets insets) { this.margin = insets; } public Dimension getLayoutSize() { return size; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/DirectedGraphLayout.java000066400000000000000000000077371166301720600313550ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import java.util.ArrayList; import java.util.List; /** * Performs a graph layout of a DirectedGraph. The directed graph * must meet the following conditions: *

      *
    • The graph must be connected. *
    • All edge's must be added to the graph's {@link DirectedGraph#edges edges} * list exactly once. *
    • All nodes must be added to the graph's {@link DirectedGraph#nodes nodes} * list exactly once. *
    * * This algorithm will: *
      *
    • break cycles by inverting a set of feedback edges. Feedback edges will * have the flag {@link Edge#isFeedback} set to true. The following * statements are true with respect to the inverted edge. When the algorithm * completes, it will invert the edges again, but will leave the feedback flags * set. *
    • for each node n, assign n to a "rank" R(n), such that: for each * edge (m, n) in n.incoming, R(m)<=R(n)-(m,n).delta. The total weighted edge * lengths shall be no greater than is necessary to meet this requirement for * all edges in the graph. *
    • attempt to order the nodes in their ranks as to minimize crossings. *
    • assign y coordinates to each node based on its rank. The spacing * between ranks is the sum of the bottom padding of the previous rank, and the * top padding of the next rank. *
    • assign x coordinates such that the graph is easily readable. The * exact behavior is undefined, but will favor edge's with higher * {@link Edge#weight}s. The minimum x value assigned to a node or bendpoint * will be 0. *
    • assign bendpoints to all edge's which span more than 1 rank. *
    *

    * For each NODE: *

      *
    • The x coordinate will be assigned a value >= 0 *
    • The y coordinate will be assigned a value >= 0 *
    • The rank will be assigned a value >=0 *
    • The height will be set to the height of the tallest node on the same row *
    *

    * For each EDGE: *

      *
    • If an edge spans more than 1 row, it will have a list of * {@link org.eclipse.draw2d.graph.Edge#vNodes virtual} nodes. The virtual nodes * will be assigned an x coordinate indicating the routing path for that edge. *
    • If an edge is a feedback edge, it's isFeedback flag will be * set, and if it has virtual nodes, they will be in reverse order (bottom-up). *
    *

    * This class is not guaranteed to produce the same results for each invocation. * * @author Randy Hudson * @since 2.1.2 */ public class DirectedGraphLayout { List steps = new ArrayList(); /** * @since 3.1 */ public DirectedGraphLayout() { init(); } void init() { steps.add(new TransposeMetrics()); steps.add(new BreakCycles()); steps.add(new RouteEdges()); steps.add(new InitialRankSolver()); steps.add(new TightSpanningTreeSolver()); steps.add(new RankAssignmentSolver()); steps.add(new PopulateRanks()); steps.add(new VerticalPlacement()); steps.add(new MinCross()); steps.add(new LocalOptimizer()); steps.add(new HorizontalPlacement()); } /** * Lays out the given graph * * @param graph * the graph to layout */ public void visit(DirectedGraph graph) { if (graph.nodes.isEmpty()) return; for (int i = 0; i < steps.size(); i++) { GraphVisitor visitor = (GraphVisitor) steps.get(i); visitor.visit(graph); } for (int i = steps.size() - 1; i >= 0; i--) { GraphVisitor visitor = (GraphVisitor) steps.get(i); visitor.revisit(graph); } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/Edge.java000066400000000000000000000243471166301720600263120ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.PointList; /** * A directed Edge joining a source and target Node. Edges indicate the * dependencies between nodes. An Edge provides the information needed to * perform a graph layout, and it stores the result of the layout in its various * field. Therefore, it functions both as input and output. The input data * consists of: *

      *
    • {@link #source} - the source Node *
    • {@link #target} - the target Node *
    • {@link #delta} - the minimum number of rows the edge should span *
    • {@link #weight} - a hint indicating this edge's importance *
    • {@link #width} - the edge's width *
    • {@link #padding} - the amount of space to leave on either side of the * edge *
    • [{@link #offsetSource}] - the edge's attachment point at the source node *
    • [{@link #offsetTarget}] - the edge's attachment point at the target node *
    *

    * The output of a layout consists of bending longer edges, and potentially * inverting edges to remove cycles in the graph. The output consists of: *

      *
    • {@link #vNodes} - the virtual nodes (if any) which make up the bendpoints *
    • {@link #isFeedback} - true if the edge points backwards *
    * * @author hudsonr * @since 2.1.2 */ public class Edge { int cut; /** * An arbitrary data field for use by clients. */ public Object data; /** * The minimum rank separation between the source and target nodes. The * default value is 1. * * @deprecated use accessors instead */ public int delta = 1; /** * The ending point. * * @deprecated use {@link #getPoints()} */ public Point end; boolean flag; /** * @deprecated INTERNAL field, use accessor method Indicates an edge was * inverted during the layout */ public boolean isFeedback = false; /** * The edge's attachment point at the source node. The default * value is -1, which indicates that the edge should use the node's default * {@link Node#getOffsetOutgoing() outgoing} attachment point. * * @deprecated use accessors instead */ public int offsetSource = -1; /** * The edge's attachment point at the target node. The default * value is -1, which indicates that the edge should use the node's default * {@link Node#getOffsetIncoming() incoming} attachment point. * * @deprecated use accessors instead */ public int offsetTarget = -1; /** * The minimum amount of space to leave on both the left and right sides of * the edge. * * @deprecated use accessors instead */ public int padding = 10; private PointList points; /** * The source Node. */ public Node source; /** * The starting point. * * @deprecated use {@link #getPoints()} */ public Point start; /** * The target Node. */ public Node target; boolean tree; /** * The virtual nodes used to bend edges which go across one or more ranks. * Each virtual node is just a regular node which occupies some small amount * of space on a row. It's width is equivalent to the edge's width. Clients * can use each virtual node's location (x, y, width, and height) as the way * to position an edge which spans multiple rows. */ public NodeList vNodes; /** * A hint indicating how straight and short the edge should be relative to * other edges in the graph. The default value is 1. */ public int weight = 1; /** * @deprecated use accessors instead */ public int width = 1; /** * Constructs a new edge with the given source and target nodes. All other * fields will have their default values. * * @param source * the source Node * @param target * the target Node */ public Edge(Node source, Node target) { this(null, source, target); } /** * Constructs a new edge with the given source, target, delta, and weight. * * @param source * the source Node * @param target * the target Node * @param delta * the minimum edge span * @param weight * the weight hint */ public Edge(Node source, Node target, int delta, int weight) { this(source, target); this.delta = delta; this.weight = weight; } /** * Constructs a new edge with the given data object, source, and target * node. * * @param data * an arbitrary data object * @param source * the source node * @param target * the target node */ public Edge(Object data, Node source, Node target) { this.data = data; this.source = source; this.target = target; source.outgoing.add(this); target.incoming.add(this); } /** * Returns the delta value. The delta is the minimum rank separation for the * edge's source and target nodes. * * @return the delta. * @since 3.2 */ public int getDelta() { return delta; } /** * For internal use only. Returns the index of the {@link Node} (or * {@link VirtualNode}) on this edge at the given rank. If this edge doesn't * have a node at the given rank, -1 is returned. * * @param rank * the rank * @return the edges index at the given rank */ int getIndexForRank(int rank) { if (source.rank == rank) return source.index; if (target.rank == rank) return target.index; if (vNodes != null) return vNodes.getNode(rank - source.rank - 1).index; return -1; } /** * For internal use only. Returns the target node's row minus the source * node's row. * * @return the distance from the source to target ranks */ public int getLength() { return (target.rank - source.rank); } public int getPadding() { return padding; } /** * Returns the path connecting the edge's source and target. * * @return a point list * @since 3.2 */ public PointList getPoints() { return points; } int getSlack() { return (target.rank - source.rank) - delta; } /** * Returns the effective source offset for this edge. The effective source * offset is either the {@link #offsetSource} field, or the source node's * default outgoing offset if that field's value is -1. * * @return the source offset */ public int getSourceOffset() { if (offsetSource != -1) return offsetSource; return source.getOffsetOutgoing(); } /** * Returns the effective target offset for this edge. The effective target * offset is either the {@link #offsetTarget} field, or the target node's * default incoming offset if that field's value is -1. * * @return the target offset */ public int getTargetOffset() { if (offsetTarget != -1) return offsetTarget; return target.getOffsetIncoming(); } public int getWidth() { return width; } /** * Swaps the source and target nodes. If any positional data has been * calculated, it is inverted as well to reflect the new direction. * * @since 2.1.2 */ public void invert() { source.outgoing.remove(this); target.incoming.remove(this); Node oldTarget = target; target = source; source = oldTarget; int temp = offsetSource; offsetSource = offsetTarget; offsetTarget = temp; target.incoming.add(this); source.outgoing.add(this); if (points != null) points.reverse(); if (vNodes != null) { NodeList newVNodes = new NodeList(); for (int j = vNodes.size() - 1; j >= 0; j--) { newVNodes.add(vNodes.getNode(j)); } vNodes = newVNodes; } if (start != null) { Point pt = start; start = end; end = pt; } } /** * Returns true if the edge was a feedback edge. The layout * algorithm may invert one or more edges to remove all cycles from the * input. The set of edges that are inverted are referred to as the * "feedback" set. * * @return true if the edge is feedback * @since 3.2 */ public boolean isFeedback() { return isFeedback; } /** * For internal use only. Returns the node opposite the given node on this * edge. * * @param end * one end * @return the other end */ public Node opposite(Node end) { if (source == end) return target; return source; } /** * Sets the delta value. * * @param delta * the new delta value * @since 3.2 */ public void setDelta(int delta) { this.delta = delta; } /** * Sets the padding for this edge. * * @param padding * the padding * @since 3.2 */ public void setPadding(int padding) { this.padding = padding; } void setPoints(PointList points) { this.points = points; start = points.getFirstPoint(); end = points.getLastPoint(); } /** * Sets the source node and adds this edge to the new source's outgoing * edges. If the source node is previously set, removes this edge from the * old source's outgoing edges. * * @param node * the new source * @since 3.2 */ public void setSource(Node node) { if (source == node) return; if (source != null) source.outgoing.remove(this); source = node; if (source != null) source.outgoing.add(this); } public void setSourceOffset(int offset) { this.offsetSource = offset; } /** * Sets the target node and adds this edge to the new target's incoming * edges. If the target node is previously set, removes this edge from the * old target's incoming edges. * * @param node * the new target * @since 3.2 */ public void setTarget(Node node) { if (target == node) return; if (target != null) target.incoming.remove(this); target = node; if (target != null) target.incoming.add(this); } public void setTargetOffset(int offset) { this.offsetTarget = offset; } /** * Sets the width of the edge. * * @param width * the new width * @since 3.2 */ public void setWidth(int width) { this.width = width; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/EdgeList.java000066400000000000000000000046441166301720600271440ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import java.util.ArrayList; /** * A list of Edges. * * @author hudsonr * @since 2.1.2 */ public class EdgeList extends ArrayList { /** * Returns the edge for the given index. * * @param index * the index of the requested edge * @return the edge at the given index */ public Edge getEdge(int index) { return (Edge) super.get(index); } /** * For intrenal use only. * * @param i * and index * @return a value */ public int getSourceIndex(int i) { return getEdge(i).source.index; } /** * For internal use only. * * @param i * an index * @return a value */ public int getTargetIndex(int i) { return getEdge(i).target.index; } /** * For internal use only. * * @return the minimum slack for this edge list */ public int getSlack() { int slack = Integer.MAX_VALUE; for (int i = 0; i < this.size(); i++) slack = Math.min(slack, getEdge(i).getSlack()); return slack; } /** * For internal use only. * * @return the total weight of all edges */ public int getWeight() { int w = 0; for (int i = 0; i < this.size(); i++) w += getEdge(i).weight; return w; } /** * For internal use only * * @return true if completely flagged */ public boolean isCompletelyFlagged() { for (int i = 0; i < size(); i++) { if (!getEdge(i).flag) return false; } return true; } /** * For internal use only. Resets all flags. * * @param resetTree * internal */ public void resetFlags(boolean resetTree) { for (int i = 0; i < size(); i++) { getEdge(i).flag = false; if (resetTree) getEdge(i).tree = false; } } /** * For internal use only. * * @param value * value */ public void setFlags(boolean value) { for (int i = 0; i < size(); i++) getEdge(i).flag = value; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/GraphUtilities.java000066400000000000000000000113751166301720600304000ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; /** * Some utility methods for graphs. * * @author Eric Bordeau * @since 2.1.2 */ class GraphUtilities { static Subgraph getCommonAncestor(Node left, Node right) { Subgraph parent; if (right instanceof Subgraph) parent = (Subgraph) right; else parent = right.getParent(); while (parent != null) { if (parent.isNested(left)) return parent; parent = parent.getParent(); } return null; } /** * Returns true if the given graph contains at least one cycle. * * @param graph * the graph to test * @return whether the graph is cyclic */ public static boolean isCyclic(DirectedGraph graph) { return isCyclic(new NodeList(graph.nodes)); } /** * Recursively removes leaf nodes from the list until there are no nodes * remaining (acyclic) or there are no leaf nodes but the list is not empty * (cyclic), then returns the result. * * @param nodes * the list of nodes to test * @return whether the graph is cyclic */ public static boolean isCyclic(NodeList nodes) { if (nodes.isEmpty()) return false; int size = nodes.size(); // remove all the leaf nodes from the graph for (int i = 0; i < nodes.size(); i++) { Node node = nodes.getNode(i); if (node.outgoing == null || node.outgoing.isEmpty()) { // this is a // leaf node nodes.remove(node); for (int j = 0; j < node.incoming.size(); j++) { Edge e = node.incoming.getEdge(j); e.source.outgoing.remove(e); } } } // if no nodes were removed, that means there are no leaf nodes and the // graph is cyclic if (nodes.size() == size) return true; // leaf nodes were removed, so recursively call this method with the new // list return isCyclic(nodes); } /** * Counts the number of edge crossings in a DirectedGraph * * @param graph * the graph whose crossed edges are counted * @return the number of edge crossings in the graph */ public static int numberOfCrossingsInGraph(DirectedGraph graph) { int crossings = 0; for (int i = 0; i < graph.ranks.size(); i++) { Rank rank = graph.ranks.getRank(i); crossings += numberOfCrossingsInRank(rank); } return crossings; } /** * Counts the number of edge crossings in a Rank * * @param rank * the rank whose crossed edges are counted * @return the number of edge crossings in the rank */ public static int numberOfCrossingsInRank(Rank rank) { int crossings = 0; for (int i = 0; i < rank.size() - 1; i++) { Node currentNode = rank.getNode(i); Node nextNode; for (int j = i + 1; j < rank.size(); j++) { nextNode = rank.getNode(j); EdgeList currentOutgoing = currentNode.outgoing; EdgeList nextOutgoing = nextNode.outgoing; for (int k = 0; k < currentOutgoing.size(); k++) { Edge currentEdge = currentOutgoing.getEdge(k); for (int l = 0; l < nextOutgoing.size(); l++) { if (nextOutgoing.getEdge(l).getIndexForRank( currentNode.rank + 1) < currentEdge .getIndexForRank(currentNode.rank + 1)) crossings++; } } } } return crossings; } private static NodeList search(Node node, NodeList list) { if (node.flag) return list; node.flag = true; list.add(node); for (int i = 0; i < node.outgoing.size(); i++) search(node.outgoing.getEdge(i).target, list); return list; } /** * Returns true if adding an edge between the 2 given nodes * will introduce a cycle in the containing graph. * * @param source * the potential source node * @param target * the potential target node * @return whether an edge between the 2 given nodes will introduce a cycle */ public static boolean willCauseCycle(Node source, Node target) { NodeList nodes = search(target, new NodeList()); nodes.resetFlags(); return nodes.contains(source); } static boolean isConstrained(Node left, Node right) { Subgraph common = left.getParent(); while (common != null && !common.isNested(right)) { left = left.getParent(); common = left.getParent(); } while (right.getParent() != common) right = right.getParent(); return (left.rowOrder != -1 && right.rowOrder != -1) && left.rowOrder != right.rowOrder; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/GraphVisitor.java000066400000000000000000000017211166301720600300560ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; /** * Performs some action on a Graph. * * @author Randy Hudson * @since 2.1.2 */ abstract class GraphVisitor { /** * Act on the given directed graph. * * @param g * the graph */ void visit(DirectedGraph g) { } /** * Called in reverse order of visit. * * @since 3.1 * @param g * the graph to act upon */ void revisit(DirectedGraph g) { } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/HorizontalPlacement.java000066400000000000000000000251121166301720600314170ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; /** * Assigns the X and width values for nodes in a directed graph. * * @author Randy Hudson * @since 2.1.2 */ class HorizontalPlacement extends SpanningTreeVisitor { class ClusterSet { int freedom = Integer.MAX_VALUE; boolean isRight; public List members = new ArrayList(); int pullWeight = 0; int rawPull = 0; boolean addCluster(NodeCluster seed) { members.add(seed); seed.isSetMember = true; rawPull += seed.weightedTotal; pullWeight += seed.weightedDivisor; if (isRight) { freedom = Math.min(freedom, seed.rightNonzero); if (freedom == 0 || rawPull <= 0) return true; addIncomingClusters(seed); if (addOutgoingClusters(seed)) return true; } else { freedom = Math.min(freedom, seed.leftNonzero); if (freedom == 0 || rawPull >= 0) return true; addOutgoingClusters(seed); if (addIncomingClusters(seed)) return true; } return false; } boolean addIncomingClusters(NodeCluster seed) { for (int i = 0; i < seed.leftCount; i++) { NodeCluster neighbor = seed.leftNeighbors[i]; if (neighbor.isSetMember) continue; CollapsedEdges edges = seed.leftLinks[i]; if (!edges.isTight()) continue; if ((!isRight || neighbor.getPull() > 0) && addCluster(neighbor)) return true; } return false; } boolean addOutgoingClusters(NodeCluster seed) { for (int i = 0; i < seed.rightCount; i++) { NodeCluster neighbor = seed.rightNeighbors[i]; if (neighbor.isSetMember) continue; CollapsedEdges edges = seed.rightLinks[i]; if (!edges.isTight()) continue; if ((isRight || neighbor.getPull() < 0) && addCluster(neighbor)) return true; } return false; } boolean build(NodeCluster seed) { isRight = seed.weightedTotal > 0; if (!addCluster(seed)) { int delta = rawPull / pullWeight; if (delta < 0) delta = Math.max(delta, -freedom); else delta = Math.min(delta, freedom); if (delta != 0) { for (int i = 0; i < members.size(); i++) { NodeCluster c = (NodeCluster) members.get(i); c.adjustRank(delta, dirtyClusters); } refreshDirtyClusters(); reset(); return true; } } reset(); return false; } void reset() { rawPull = pullWeight = 0; for (int i = 0; i < members.size(); i++) ((NodeCluster) members.get(i)).isSetMember = false; members.clear(); freedom = Integer.MAX_VALUE; } } static int step; private List allClusters; private Map clusterMap = new HashMap(); ClusterSet clusterset = new ClusterSet(); Collection dirtyClusters = new HashSet(); DirectedGraph graph; Map map = new HashMap(); DirectedGraph prime; Node graphRight; Node graphLeft; /** * Inset the corresponding parts for the given 2 nodes along an edge E. The * weight value is a value by which to scale the edges specified weighting * factor. * * @param u * the source * @param v * the target * @param e * the edge along which u and v exist * @param weight * a scaling for the weight */ void addEdge(Node u, Node v, Edge e, int weight) { Node ne = new Node(new NodePair(u, v)); prime.nodes.add(ne); ne.y = (u.y + u.height + v.y) / 2; Node uPrime = get(u); Node vPrime = get(v); int uOffset = e.getSourceOffset(); int vOffset = e.getTargetOffset(); Edge eu = new Edge(ne, uPrime, 0, e.weight * weight); Edge ev = new Edge(ne, vPrime, 0, e.weight * weight); int dw = uOffset - vOffset; if (dw < 0) eu.delta = -dw; else ev.delta = dw; prime.edges.add(eu); prime.edges.add(ev); } /** * Adds all of the incoming edges to the graph. * * @param n * the original node * @param nPrime * its corresponding node in the auxilary graph */ void addEdges(Node n) { for (int i = 0; i < n.incoming.size(); i++) { Edge e = n.incoming.getEdge(i); addEdge(e.source, n, e, 1); } } void applyGPrime() { Node node; for (int n = 0; n < prime.nodes.size(); n++) { node = prime.nodes.getNode(n); if (node.data instanceof Node) ((Node) node.data).x = node.rank; } } private void balanceClusters() { findAllClusters(); step = 0; boolean somethingMoved = false; for (int i = 0; i < allClusters.size();) { NodeCluster c = (NodeCluster) allClusters.get(i); int delta = c.getPull(); if (delta < 0) { if (c.leftFreedom > 0) { c.adjustRank(Math.max(delta, -c.leftFreedom), dirtyClusters); refreshDirtyClusters(); moveClusterForward(i, c); somethingMoved = true; step++; } else if (clusterset.build(c)) { step++; moveClusterForward(i, c); somethingMoved = true; } } else if (delta > 0) { if (c.rightFreedom > 0) { c.adjustRank(Math.min(delta, c.rightFreedom), dirtyClusters); refreshDirtyClusters(); moveClusterForward(i, c); somethingMoved = true; step++; } else if (clusterset.build(c)) { step++; moveClusterForward(i, c); somethingMoved = true; } } i++; if (i == allClusters.size() && somethingMoved) { i = 0; somethingMoved = false; } } } // boolean balanceClusterSets() { // for (int i = 0; i < allClusters.size(); i++) { // NodeCluster c = (NodeCluster)allClusters.get(i); // if (c.weightedTotal < 0 && c.leftFreedom == 0) { // if (clusterset.build(c)) { // moveClusterForward(i, c); // return true; // } // } else if (c.weightedTotal > 0 && c.rightFreedom == 0) { // if (clusterset.build(c)) { // moveClusterForward(i, c); // return true; // } // } // } // return false; // } void buildGPrime() { RankList ranks = graph.ranks; buildRankSeparators(ranks); Rank rank; Node n; for (int r = 1; r < ranks.size(); r++) { rank = ranks.getRank(r); for (int i = 0; i < rank.count(); i++) { n = rank.getNode(i); addEdges(n); } } } void buildRankSeparators(RankList ranks) { Rank rank; Node n, nPrime, prevNPrime; Edge e; for (int r = 0; r < ranks.size(); r++) { rank = ranks.getRank(r); prevNPrime = null; for (int i = 0; i < rank.count(); i++) { n = rank.getNode(i); nPrime = new Node(n); if (i == 0) { e = new Edge(graphLeft, nPrime, 0, 0); prime.edges.add(e); e.delta = graph.getPadding(n).left + graph.getMargin().left; } else { e = new Edge(prevNPrime, nPrime); e.weight = 0; prime.edges.add(e); rowSeparation(e); } prevNPrime = nPrime; prime.nodes.add(nPrime); map(n, nPrime); if (i == rank.count() - 1) { e = new Edge(nPrime, graphRight, 0, 0); e.delta = n.width + graph.getPadding(n).right + graph.getMargin().right; prime.edges.add(e); } } } } private void calculateCellLocations() { graph.cellLocations = new int[graph.ranks.size() + 1][]; for (int row = 0; row < graph.ranks.size(); row++) { Rank rank = graph.ranks.getRank(row); int locations[] = graph.cellLocations[row] = new int[rank.size() + 1]; int cell; Node node = null; for (cell = 0; cell < rank.size(); cell++) { node = rank.getNode(cell); locations[cell] = node.x - graph.getPadding(node).left; } locations[cell] = node.x + node.width + graph.getPadding(node).right; } } private void findAllClusters() { Node root = prime.nodes.getNode(0); NodeCluster cluster = new NodeCluster(); allClusters = new ArrayList(); allClusters.add(cluster); growCluster(root, cluster); for (int i = 0; i < prime.edges.size(); i++) { Edge e = prime.edges.getEdge(i); NodeCluster sourceCluster = (NodeCluster) clusterMap.get(e.source); NodeCluster targetCluster = (NodeCluster) clusterMap.get(e.target); // Ignore cluster internal edges if (targetCluster == sourceCluster) continue; CollapsedEdges link = sourceCluster.getRightNeighbor(targetCluster); if (link == null) { link = new CollapsedEdges(e); sourceCluster.addRightNeighbor(targetCluster, link); targetCluster.addLeftNeighbor(sourceCluster, link); } else { prime.removeEdge(link.processEdge(e)); i--; } } for (int i = 0; i < allClusters.size(); i++) ((NodeCluster) allClusters.get(i)).initValues(); } Node get(Node key) { return (Node) map.get(key); } void growCluster(Node root, NodeCluster cluster) { cluster.add(root); clusterMap.put(root, cluster); EdgeList treeChildren = getSpanningTreeChildren(root); for (int i = 0; i < treeChildren.size(); i++) { Edge e = treeChildren.getEdge(i); if (e.cut != 0) growCluster(getTreeTail(e), cluster); else { NodeCluster newCluster = new NodeCluster(); allClusters.add(newCluster); growCluster(getTreeTail(e), newCluster); } } } void map(Node key, Node value) { map.put(key, value); } private void moveClusterForward(int i, NodeCluster c) { if (i == 0) return; int swapIndex = i / 2; Object temp = allClusters.get(swapIndex); allClusters.set(swapIndex, c); allClusters.set(i, temp); } void refreshDirtyClusters() { for (Iterator iter = dirtyClusters.iterator(); iter.hasNext();) ((NodeCluster) iter.next()).refreshValues(); dirtyClusters.clear(); } void rowSeparation(Edge e) { Node source = (Node) e.source.data; Node target = (Node) e.target.data; e.delta = source.width + graph.getPadding(source).right + graph.getPadding(target).left; } public void visit(DirectedGraph g) { graph = g; prime = new DirectedGraph(); prime.nodes.add(graphLeft = new Node(null)); prime.nodes.add(graphRight = new Node(null)); if (g.tensorStrength != 0) prime.edges.add(new Edge(graphLeft, graphRight, g.tensorSize, g.tensorStrength)); buildGPrime(); new InitialRankSolver().visit(prime); new TightSpanningTreeSolver().visit(prime); RankAssignmentSolver solver = new RankAssignmentSolver(); solver.visit(prime); graph.size.width = graphRight.rank; balanceClusters(); prime.nodes.adjustRank(-graphLeft.rank); applyGPrime(); calculateCellLocations(); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/InitialRankSolver.java000066400000000000000000000061701166301720600310400ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import java.util.ArrayList; import java.util.List; import java.util.Stack; /** * Assigns a valid rank assignment to all nodes based on their edges. The * assignment is not optimal in that it does not provide the minimum global * length of edge lengths. * * @author Randy Hudson * @since 2.1.2 */ class InitialRankSolver extends GraphVisitor { protected DirectedGraph graph; protected EdgeList candidates = new EdgeList(); protected NodeList members = new NodeList(); public void visit(DirectedGraph graph) { this.graph = graph; graph.edges.resetFlags(false); graph.nodes.resetFlags(); solve(); } protected void solve() { if (graph.nodes.size() == 0) return; NodeList unranked = new NodeList(graph.nodes); NodeList rankMe = new NodeList(); Node node; int i; while (!unranked.isEmpty()) { rankMe.clear(); for (i = 0; i < unranked.size();) { node = unranked.getNode(i); if (node.incoming.isCompletelyFlagged()) { rankMe.add(node); unranked.remove(i); } else i++; } if (rankMe.size() == 0) throw new RuntimeException("Cycle detected in graph"); //$NON-NLS-1$ for (i = 0; i < rankMe.size(); i++) { node = rankMe.getNode(i); assignMinimumRank(node); node.outgoing.setFlags(true); } } connectForest(); } private void connectForest() { List forest = new ArrayList(); Stack stack = new Stack(); NodeList tree; graph.nodes.resetFlags(); for (int i = 0; i < graph.nodes.size(); i++) { Node neighbor, n = graph.nodes.getNode(i); if (n.flag) continue; tree = new NodeList(); stack.push(n); while (!stack.isEmpty()) { n = (Node) stack.pop(); n.flag = true; tree.add(n); for (int s = 0; s < n.incoming.size(); s++) { neighbor = n.incoming.getEdge(s).source; if (!neighbor.flag) stack.push(neighbor); } for (int s = 0; s < n.outgoing.size(); s++) { neighbor = n.outgoing.getEdge(s).target; if (!neighbor.flag) stack.push(neighbor); } } forest.add(tree); } if (forest.size() > 1) { // connect the forest graph.forestRoot = new Node("the forest root"); //$NON-NLS-1$ graph.nodes.add(graph.forestRoot); for (int i = 0; i < forest.size(); i++) { tree = (NodeList) forest.get(i); graph.edges.add(new Edge(graph.forestRoot, tree.getNode(0), 0, 0)); } } } private void assignMinimumRank(Node node) { int rank = 0; Edge e; for (int i1 = 0; i1 < node.incoming.size(); i1++) { e = node.incoming.getEdge(i1); rank = Math.max(rank, e.delta + e.source.rank); } node.rank = rank; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/InvertEdges.java000066400000000000000000000017311166301720600276550ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; /** * Inverts any edges which are marked as backwards or "feedback" edges. * * @author Daniel Lee * @since 2.1.2 */ class InvertEdges extends GraphVisitor { /** * * @see GraphVisitor#visit(org.eclipse.draw2d.graph.DirectedGraph) */ public void visit(DirectedGraph g) { for (int i = 0; i < g.edges.size(); i++) { Edge e = g.edges.getEdge(i); if (e.isFeedback) e.invert(); } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/LocalOptimizer.java000066400000000000000000000063631166301720600304010ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; /** * This graph visitor examines all adjacent pairs of nodes and determines if * swapping the two nodes provides improved graph aesthetics. * * @author Daniel Lee * @since 2.1.2 */ class LocalOptimizer extends GraphVisitor { boolean shouldSwap(Node current, Node next) { if (GraphUtilities.isConstrained(current, next)) return false; int crossCount = 0; int invertedCrossCount = 0; EdgeList currentEdges = current.incoming; EdgeList nextEdges = next.incoming; int rank = current.rank - 1; int iCurrent, iNext; for (int i = 0; i < currentEdges.size(); i++) { Edge currentEdge = currentEdges.getEdge(i); iCurrent = currentEdge.getIndexForRank(rank); for (int j = 0; j < nextEdges.size(); j++) { iNext = nextEdges.getEdge(j).getIndexForRank(rank); if (iNext < iCurrent) crossCount++; else if (iNext > iCurrent) invertedCrossCount++; else { // edges go to the same location int offsetDiff = nextEdges.getEdge(j).getSourceOffset() - currentEdge.getSourceOffset(); if (offsetDiff < 0) crossCount++; else if (offsetDiff > 0) invertedCrossCount++; } } } currentEdges = current.outgoing; nextEdges = next.outgoing; rank = current.rank + 1; for (int i = 0; i < currentEdges.size(); i++) { Edge currentEdge = currentEdges.getEdge(i); iCurrent = currentEdge.getIndexForRank(rank); for (int j = 0; j < nextEdges.size(); j++) { iNext = nextEdges.getEdge(j).getIndexForRank(rank); if (iNext < iCurrent) crossCount++; else if (iNext > iCurrent) invertedCrossCount++; else { // edges go to the same location int offsetDiff = nextEdges.getEdge(j).getTargetOffset() - currentEdge.getTargetOffset(); if (offsetDiff < 0) crossCount++; else if (offsetDiff > 0) invertedCrossCount++; } } } if (invertedCrossCount < crossCount) return true; return false; } private void swapNodes(Node current, Node next, Rank rank) { int index = rank.indexOf(current); rank.set(index + 1, current); rank.set(index, next); index = current.index; current.index = next.index; next.index = index; } /** * @see GraphVisitor#visit(org.eclipse.draw2d.graph.DirectedGraph) */ public void visit(DirectedGraph g) { boolean flag; do { flag = false; for (int r = 0; r < g.ranks.size(); r++) { Rank rank = g.ranks.getRank(r); for (int n = 0; n < rank.count() - 1; n++) { Node currentNode = rank.getNode(n); Node nextNode = rank.getNode(n + 1); if (shouldSwap(currentNode, nextNode)) { swapNodes(currentNode, nextNode, rank); flag = true; n = Math.max(0, n - 2); } } } } while (flag); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/MinCross.java000066400000000000000000000031761166301720600272000ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; /** * Sweeps up and down the ranks rearranging them so as to reduce edge crossings. * * @author Randy Hudson * @since 2.1.2 */ class MinCross extends GraphVisitor { static final int MAX = 45; private DirectedGraph g; private RankSorter sorter = new RankSorter(); public MinCross() { } /** * @since 3.1 */ public MinCross(RankSorter sorter) { setRankSorter(sorter); } public void setRankSorter(RankSorter sorter) { this.sorter = sorter; } void solve() { Rank rank; for (int loop = 0; loop < MAX; loop++) { for (int row = 1; row < g.ranks.size(); row++) { rank = g.ranks.getRank(row); sorter.sortRankIncoming(g, rank, row, (double) loop / MAX); } if (loop == MAX - 1) continue; for (int row = g.ranks.size() - 2; row >= 0; row--) { rank = g.ranks.getRank(row); sorter.sortRankOutgoing(g, rank, row, (double) loop / MAX); } } } /** * @see GraphVisitor#visit(org.eclipse.draw2d.graph.DirectedGraph) */ public void visit(DirectedGraph g) { sorter.init(g); this.g = g; solve(); sorter.optimize(g); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/NestingTree.java000066400000000000000000000073521166301720600276720ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2005, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; class NestingTree { List contents = new ArrayList(); boolean isLeaf = true; int size; double sortValue; Node subgraph; private static void addToNestingTree(Map map, Node child) { Subgraph subgraph = child.getParent(); NestingTree parent = (NestingTree) map.get(subgraph); if (parent == null) { parent = new NestingTree(); parent.subgraph = subgraph; map.put(subgraph, parent); if (subgraph != null) addToNestingTree(map, parent); } parent.contents.add(child); } private static void addToNestingTree(Map map, NestingTree branch) { Subgraph subgraph = branch.subgraph.getParent(); NestingTree parent = (NestingTree) map.get(subgraph); if (parent == null) { parent = new NestingTree(); parent.subgraph = subgraph; map.put(subgraph, parent); if (subgraph != null) addToNestingTree(map, parent); } parent.contents.add(branch); } static NestingTree buildNestingTreeForRank(Rank rank) { Map nestingMap = new HashMap(); for (int j = 0; j < rank.count(); j++) { Node node = rank.getNode(j); addToNestingTree(nestingMap, node); } return (NestingTree) nestingMap.get(null); } void calculateSortValues() { int total = 0; for (int i = 0; i < contents.size(); i++) { Object o = contents.get(i); if (o instanceof NestingTree) { isLeaf = false; NestingTree e = (NestingTree) o; e.calculateSortValues(); total += (int) (e.sortValue * e.size); size += e.size; } else { Node n = (Node) o; n.sortValue = n.index; total += n.index; size++; } } sortValue = (double) total / size; } void getSortValueFromSubgraph() { if (subgraph != null) sortValue = subgraph.sortValue; for (int i = 0; i < contents.size(); i++) { Object o = contents.get(i); if (o instanceof NestingTree) ((NestingTree) o).getSortValueFromSubgraph(); } } void recursiveSort(boolean sortLeaves) { if (isLeaf && !sortLeaves) return; boolean change = false; // Use modified bubble sort for almost-sorted lists. do { change = false; for (int i = 0; i < contents.size() - 1; i++) change |= swap(i); if (!change) break; change = false; for (int i = contents.size() - 2; i >= 0; i--) change |= swap(i); } while (change); for (int i = 0; i < contents.size(); i++) { Object o = contents.get(i); if (o instanceof NestingTree) ((NestingTree) o).recursiveSort(sortLeaves); } } void repopulateRank(Rank r) { for (int i = 0; i < contents.size(); i++) { Object o = contents.get(i); if (o instanceof Node) r.add(o); else ((NestingTree) o).repopulateRank(r); } } boolean swap(int index) { Object left = contents.get(index); Object right = contents.get(index + 1); double iL = (left instanceof Node) ? ((Node) left).sortValue : ((NestingTree) left).sortValue; double iR = (right instanceof Node) ? ((Node) right).sortValue : ((NestingTree) right).sortValue; if (iL <= iR) return false; contents.set(index, right); contents.set(index + 1, left); return true; } public String toString() { return "Nesting:" + subgraph; //$NON-NLS-1$ } }eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/Node.java000066400000000000000000000207431166301720600263270ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import java.util.Iterator; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Insets; /** * A node in a DirectedGraph. A node has 0 or more incoming and outgoing * {@link Edge}s. A node is given a width and height by the client. When a * layout places the node in the graph, it will determine the node's x and y * location. It may also modify the node's height. * * A node represents both the input and the output for a * layout algorithm. The following fields are used as input to a graph layout: *
      *
    • {@link #width} - the node's width. *
    • {@link #height} - the node's height. *
    • {@link #outgoing} - the node's outgoing edges. *
    • {@link #incoming} - the node's incoming edges. *
    • padding - the amount of space to be left around the outside of the node. *
    • {@link #incomingOffset} - the default attachment point for incoming * edges. *
    • {@link #outgoingOffset} - the default attachment point for outgoing * edges. *
    • parent - the parent subgraph containing this node. *
    *

    * The following fields are calculated by a graph layout and comprise the * output: *

      *
    • {@link #x} - the node's x location *
    • {@link #y} - the node's y location *
    • {@link #height} - the node's height may be stretched to match the height * of other nodes *
    * * @author Randy Hudson * @since 2.1.2 */ public class Node { Node left, right; Object workingData[] = new Object[3]; int workingInts[] = new int[4]; /** * Clients may use this field to mark the Node with an arbitrary data * object. */ public Object data; // used by various graph visitors boolean flag; /** * The height of this node. This value should be set prior to laying out the * directed graph. Depending on the layout rules, a node's height may be * expanded to match the height of other nodes around it. */ public int height = 40; /** * @deprecated use {@link #setRowConstraint(int)} and * {@link #getRowConstraint()} */ public int rowOrder = -1; /** * The edges for which this node is the target. */ public EdgeList incoming = new EdgeList(); /** * The default attachment point for incoming edges. -1 * indicates that the node's horizontal center should be used. */ public int incomingOffset = -1; // A non-decreasing number given to consecutive nodes in a Rank. int index; // Used in Compound graphs to quickly determine whether a node is inside a // subgraph. int nestingIndex = -1; /** * The edges for which this node is the source. */ public EdgeList outgoing = new EdgeList(); Insets padding; private Subgraph parent; int rank; /** * @deprecated for internal use only */ public double sortValue; /** * The node's outgoing offset attachment point. */ public int outgoingOffset = -1; /** * The node's width. The default value is 50. */ public int width = 50; /** * The node's x coordinate. */ public int x; /** * The node's y coordinate. */ public int y; /** * Constructs a new node. */ public Node() { } /** * Constructs a node with the given data object * * @param data * an arbitrary data object */ public Node(Object data) { this(data, null); } /** * Constructs a node inside the given subgraph. * * @param parent * the parent subgraph */ public Node(Subgraph parent) { this(null, parent); } /** * Constructs a node with the given data object and parent subgraph. This * node is added to the set of members for the parent subgraph * * @param data * an arbitrary data object * @param parent * the parent subgraph or null */ public Node(Object data, Subgraph parent) { this.data = data; this.parent = parent; if (parent != null) parent.addMember(this); } /** * Returns the incoming attachment point. This is the distance from the left * edge to the default incoming attachment point for edges. Each incoming * edge may have it's own attachment setting which takes priority over this * default one. * * @return the incoming offset */ public int getOffsetIncoming() { if (incomingOffset == -1) return width / 2; return incomingOffset; } /** * Returns the outgoing attachment point. This is the distance from the left * edge to the default outgoing attachment point for edges. Each outgoing * edge may have it's own attachment setting which takes priority over this * default one. * * @return the outgoing offset */ public int getOffsetOutgoing() { if (outgoingOffset == -1) return width / 2; return outgoingOffset; } /** * Returns the padding for this node or null if the default * padding for the graph should be used. * * @return the padding or null */ public Insets getPadding() { return padding; } /** * Returns the parent Subgraph or null if there is no parent. * Subgraphs are only for use in {@link CompoundDirectedGraphLayout}. * * @return the parent or null */ public Subgraph getParent() { return parent; } /** * For internal use only. Returns true if the given node is * equal to this node. This method is implemented for consitency with * Subgraph. * * @param node * the node in question * @return true if nested */ boolean isNested(Node node) { return node == this; } /** * Sets the padding. null indicates that the default padding * should be used. * * @param padding * an insets or null */ public void setPadding(Insets padding) { this.padding = padding; } /** * Sets the parent subgraph. This method should not be called directly. The * constructor will set the parent accordingly. * * @param parent * the parent */ public void setParent(Subgraph parent) { this.parent = parent; } /** * Sets the row sorting constraint for this node. By default, a node's * constraint is -1. If two nodes have different values both >= * 0, the node with the smaller constraint will be placed to the left of the * other node. In all other cases no relative placement is guaranteed. * * @param value * the row constraint * @since 3.2 */ public void setRowConstraint(int value) { this.rowOrder = value; } /** * Returns the row constraint for this node. * * @return the row constraint * @since 3.2 */ public int getRowConstraint() { return rowOrder; } /** * Sets the size of this node to the given dimension. * * @param size * the new size * @since 3.2 */ public void setSize(Dimension size) { width = size.width; height = size.height; } /** * @see Object#toString() */ public String toString() { return "N(" + data + ")"; //$NON-NLS-1$ //$NON-NLS-2$ } Iterator iteratorNeighbors() { return new Iterator() { int offset; EdgeList list = outgoing; public Object next() { Edge edge = list.getEdge(offset++); if (offset < list.size()) return edge.opposite(Node.this); if (list == outgoing) { list = incoming; offset = 0; } else list = null; return edge.opposite(Node.this); } public boolean hasNext() { if (list == null) return false; if (offset < list.size()) return true; if (list == outgoing) { list = incoming; offset = 0; } return offset < list.size(); } public void remove() { throw new RuntimeException("Remove not supported"); //$NON-NLS-1$ } }; } /** * Returns a reference to a node located left from this one * * @return Node on the left from this one * @since 3.4 */ public Node getLeft() { return left; } /** * Returns a reference to a node located right from this one * * @return Node on the right from this one * @since 3.4 */ public Node getRight() { return right; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/NodeCluster.java000066400000000000000000000143621166301720600276710ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2005, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import java.util.Collection; /** * A group of nodes which are interlocked and cannot be separately placed. * * @since 3.1 */ class NodeCluster extends NodeList { int hashCode = new Object().hashCode(); boolean isSetMember; boolean isDirty; boolean leftDirty; boolean rightDirty; int leftFreedom; int rightFreedom; int leftNonzero; int rightNonzero; int leftCount = 0; int rightCount = 0; CollapsedEdges leftLinks[] = new CollapsedEdges[10]; CollapsedEdges rightLinks[] = new CollapsedEdges[10]; NodeCluster leftNeighbors[] = new NodeCluster[10]; NodeCluster rightNeighbors[] = new NodeCluster[10]; int effectivePull; int weightedTotal; int weightedDivisor; int unweightedTotal; int unweightedDivisor; void addLeftNeighbor(NodeCluster neighbor, CollapsedEdges link) { // Need to grow array in the following case if (leftNeighbors.length == leftCount) { int newSize = leftNeighbors.length * 2; NodeCluster newNeighbors[] = new NodeCluster[newSize]; CollapsedEdges newLinks[] = new CollapsedEdges[newSize]; System.arraycopy(leftNeighbors, 0, newNeighbors, 0, leftNeighbors.length); System.arraycopy(leftLinks, 0, newLinks, 0, leftLinks.length); leftNeighbors = newNeighbors; leftLinks = newLinks; } leftNeighbors[leftCount] = neighbor; leftLinks[leftCount++] = link; } void addRightNeighbor(NodeCluster neighbor, CollapsedEdges link) { if (rightNeighbors.length == rightCount) { int newSize = rightNeighbors.length * 2; NodeCluster newNeighbors[] = new NodeCluster[newSize]; CollapsedEdges newLinks[] = new CollapsedEdges[newSize]; System.arraycopy(rightNeighbors, 0, newNeighbors, 0, rightNeighbors.length); System.arraycopy(rightLinks, 0, newLinks, 0, rightLinks.length); rightNeighbors = newNeighbors; rightLinks = newLinks; } rightNeighbors[rightCount] = neighbor; rightLinks[rightCount++] = link; } public void adjustRank(int delta, Collection affected) { adjustRank(delta); NodeCluster neighbor; CollapsedEdges edges; for (int i = 0; i < leftCount; i++) { neighbor = leftNeighbors[i]; if (neighbor.isSetMember) continue; edges = leftLinks[i]; neighbor.weightedTotal += delta * edges.collapsedWeight; neighbor.unweightedTotal += delta * edges.collapsedCount; weightedTotal -= delta * edges.collapsedWeight; unweightedTotal -= delta * edges.collapsedCount; neighbor.rightDirty = leftDirty = true; if (!neighbor.isDirty) { neighbor.isDirty = true; affected.add(neighbor); } } for (int i = 0; i < rightCount; i++) { neighbor = rightNeighbors[i]; if (neighbor.isSetMember) continue; edges = rightLinks[i]; neighbor.weightedTotal += delta * edges.collapsedWeight; neighbor.unweightedTotal += delta * edges.collapsedCount; weightedTotal -= delta * edges.collapsedWeight; unweightedTotal -= delta * edges.collapsedCount; neighbor.leftDirty = rightDirty = true; if (!neighbor.isDirty) { neighbor.isDirty = true; affected.add(neighbor); } } isDirty = true; affected.add(this); } public boolean equals(Object o) { return o == this; } CollapsedEdges getLeftNeighbor(NodeCluster neighbor) { for (int i = 0; i < leftCount; i++) { if (leftNeighbors[i] == neighbor) return leftLinks[i]; } return null; } int getPull() { return effectivePull; } CollapsedEdges getRightNeighbor(NodeCluster neighbor) { for (int i = 0; i < rightCount; i++) { if (rightNeighbors[i] == neighbor) return rightLinks[i]; } return null; } public int hashCode() { return hashCode; } /** * Initializes pull and freedom values. */ void initValues() { weightedTotal = 0; weightedDivisor = 0; unweightedTotal = 0; int slack; leftNonzero = rightNonzero = leftFreedom = rightFreedom = Integer.MAX_VALUE; for (int i = 0; i < leftCount; i++) { CollapsedEdges edges = leftLinks[i]; weightedTotal -= edges.getWeightedPull(); unweightedTotal -= edges.tightestEdge.getSlack(); unweightedDivisor += edges.collapsedCount; weightedDivisor += edges.collapsedWeight; slack = edges.tightestEdge.getSlack(); leftFreedom = Math.min(slack, leftFreedom); if (slack > 0) leftNonzero = Math.min(slack, leftNonzero); } for (int i = 0; i < rightCount; i++) { CollapsedEdges edges = rightLinks[i]; weightedTotal += edges.getWeightedPull(); unweightedDivisor += edges.collapsedCount; unweightedTotal += edges.tightestEdge.getSlack(); weightedDivisor += edges.collapsedWeight; slack = edges.tightestEdge.getSlack(); rightFreedom = Math.min(slack, rightFreedom); if (slack > 0) rightNonzero = Math.min(slack, rightNonzero); } updateEffectivePull(); } /** * Refreshes the left and right freedom. */ void refreshValues() { int slack; isDirty = false; if (leftDirty) { leftDirty = false; leftNonzero = leftFreedom = Integer.MAX_VALUE; for (int i = 0; i < leftCount; i++) { CollapsedEdges edges = leftLinks[i]; slack = edges.tightestEdge.getSlack(); leftFreedom = Math.min(slack, leftFreedom); if (slack > 0) leftNonzero = Math.min(slack, leftNonzero); } } if (rightDirty) { rightDirty = false; rightNonzero = rightFreedom = Integer.MAX_VALUE; for (int i = 0; i < rightCount; i++) { CollapsedEdges edges = rightLinks[i]; slack = edges.tightestEdge.getSlack(); rightFreedom = Math.min(slack, rightFreedom); if (slack > 0) rightNonzero = Math.min(slack, rightNonzero); } } updateEffectivePull(); } private void updateEffectivePull() { if (weightedDivisor != 0) effectivePull = weightedTotal / weightedDivisor; else if (unweightedDivisor != 0) effectivePull = unweightedTotal / unweightedDivisor; else effectivePull = 0; } }eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/NodeList.java000066400000000000000000000034071166301720600271610ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import java.util.ArrayList; /** * A list containing nodes. * * @author hudsonr * @since 2.1.2 */ public class NodeList extends ArrayList { /** * Constructs an empty NodeList. */ public NodeList() { } /** * Constructs a NodeList with the elements from the specified list. * * @param list * the list whose elements are to be added to this list */ public NodeList(NodeList list) { super(list); } void adjustRank(int delta) { if (delta == 0) return; for (int i = 0; i < size(); i++) getNode(i).rank += delta; } void resetSortValues() { for (int i = 0; i < size(); i++) getNode(i).sortValue = 0.0; } void resetIndices() { for (int i = 0; i < size(); i++) getNode(i).index = 0; } void normalizeRanks() { int minRank = Integer.MAX_VALUE; for (int i = 0; i < size(); i++) minRank = Math.min(minRank, getNode(i).rank); adjustRank(-minRank); } /** * Returns the Node at the given index. * * @param index * the index * @return the node at a given index */ public Node getNode(int index) { return (Node) super.get(index); } void resetFlags() { for (int i = 0; i < size(); i++) { getNode(i).flag = false; } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/NodePair.java000066400000000000000000000022121166301720600271320ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; /** * @author hudsonr * @since 2.1 */ class NodePair { public Node n1; public Node n2; public NodePair() { } public NodePair(Node n1, Node n2) { this.n1 = n1; this.n2 = n2; } public boolean equals(Object obj) { if (obj instanceof NodePair) { NodePair np = (NodePair) obj; return np.n1 == n1 && np.n2 == n2; } return false; } public int hashCode() { return n1.hashCode() ^ n2.hashCode(); } /** * @see java.lang.Object#toString() */ public String toString() { return "[" + n1 + ", " + n2 + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/Obstacle.java000066400000000000000000000066311166301720600271760ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import org.eclipse.draw2d.PositionConstants; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; /** * An obstacle representation for the ShortestPathRouting. This is a subclass of * Rectangle. * * This class is for internal use only. * * @author Whitney Sorenson * @since 3.0 */ class Obstacle extends Rectangle { boolean exclude; Vertex topLeft, topRight, bottomLeft, bottomRight, center; private ShortestPathRouter router; /** * Creates a new obstacle from the given rectangle bounds. * * @param rect * the bounds */ Obstacle(Rectangle rect, ShortestPathRouter router) { init(rect); this.router = router; } /** * Returns true if the given point is contained but not on the * boundary of this obstacle. * * @param p * a point * @return true if properly contained */ public boolean containsProper(Point p) { return p.x > this.x && p.x < this.x + this.width - 1 && p.y > this.y && p.y < this.y + this.height - 1; } public int getSpacing() { return router.getSpacing(); } private void growVertex(Vertex vertex) { if (vertex.totalCount > 0) vertex.grow(); } /** * Grows all vertices on this obstacle. */ void growVertices() { growVertex(topLeft); growVertex(topRight); growVertex(bottomLeft); growVertex(bottomRight); } /** * Initializes this obstacle to the values of the given rectangle * * @param rect * bounds of this obstacle */ void init(Rectangle rect) { this.x = rect.x; this.y = rect.y; this.width = rect.width; this.height = rect.height; exclude = false; topLeft = new Vertex(x, y, this); topLeft.positionOnObstacle = PositionConstants.NORTH_WEST; topRight = new Vertex(x + width - 1, y, this); topRight.positionOnObstacle = PositionConstants.NORTH_EAST; bottomLeft = new Vertex(x, y + height - 1, this); bottomLeft.positionOnObstacle = PositionConstants.SOUTH_WEST; bottomRight = new Vertex(x + width - 1, y + height - 1, this); bottomRight.positionOnObstacle = PositionConstants.SOUTH_EAST; center = new Vertex(getCenter(), this); } /** * Requests a full reset on all four vertices of this obstacle. */ void reset() { topLeft.fullReset(); bottomLeft.fullReset(); bottomRight.fullReset(); topRight.fullReset(); } private void shrinkVertex(Vertex vertex) { if (vertex.totalCount > 0) vertex.shrink(); } /** * Shrinks all four vertices of this obstacle. */ void shrinkVertices() { shrinkVertex(topLeft); shrinkVertex(topRight); shrinkVertex(bottomLeft); shrinkVertex(bottomRight); } /** * @see org.eclipse.draw2d.geometry.Rectangle#toString() */ public String toString() { return "Obstacle(" + x + ", " + y + ", " + //$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$ width + ", " + height + ")";//$NON-NLS-2$//$NON-NLS-1$ } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/Path.java000066400000000000000000000607121166301720600263360ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; import org.eclipse.draw2d.PositionConstants; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.PointList; /** * A Path representation for the ShortestPathRouting. A Path has a start and end * point and may have bendpoints. The output of a path is accessed via the * method getPoints(). * * This class is for internal use only. * * @author Whitney Sorenson * @since 3.0 */ public class Path { /** * A Stack of segments. */ private static class SegmentStack extends ArrayList { Segment pop() { return (Segment) remove(size() - 1); } Obstacle popObstacle() { return (Obstacle) remove(size() - 1); } void push(Object obj) { add(obj); } } private static final Point CURRENT = new Point(); private static final double EPSILON = 1.04; private static final Point NEXT = new Point(); private static final double OVAL_CONSTANT = 1.13; /** * The bendpoint constraints. The path must go through these bendpoints. */ PointList bendpoints; /** * An arbitrary data field which can be used to map a Path back to some * client object. */ public Object data; List excludedObstacles; List grownSegments; /** * this field is for internal use only. It is true whenever a property has * been changed which requires the solver to resolve this path. */ public boolean isDirty = true; boolean isInverted = false; boolean isMarked = false; PointList points; /** * The previous cost ratio of the path. The cost ratio is the actual path * length divided by the length from the start to the end. */ private double prevCostRatio; List segments; private SegmentStack stack; Vertex start, end; private Path subPath; double threshold; Set visibleObstacles; Set visibleVertices; /** * Constructs a new path. * * @since 3.0 */ public Path() { segments = new ArrayList(); grownSegments = new ArrayList(); points = new PointList(); visibleVertices = new HashSet(); stack = new SegmentStack(); visibleObstacles = new HashSet(); excludedObstacles = new ArrayList(); } /** * Constructs a new path with the given data. * * @since 3.0 * @param data * an arbitrary data field */ public Path(Object data) { this(); this.data = data; } /** * Constructs a new path with the given data, start and end point. * * @param start * the start point for this path * @param end * the end point for this path */ public Path(Point start, Point end) { this(new Vertex(start, null), new Vertex(end, null)); } /** * Creates a path between the given vertices. * * @param start * start vertex * @param end * end vertex */ Path(Vertex start, Vertex end) { this(); this.start = start; this.end = end; } /** * Attempts to add all segments between the given obstacles to the * visibility graph. * * @param source * the source obstacle * @param target * the target obstacle */ private void addAllSegmentsBetween(Obstacle source, Obstacle target) { addConnectingSegment(new Segment(source.bottomLeft, target.bottomLeft), source, target, false, false); addConnectingSegment( new Segment(source.bottomRight, target.bottomRight), source, target, true, true); addConnectingSegment(new Segment(source.topLeft, target.topLeft), source, target, true, true); addConnectingSegment(new Segment(source.topRight, target.topRight), source, target, false, false); if (source.bottom() == target.bottom()) { addConnectingSegment(new Segment(source.bottomLeft, target.bottomRight), source, target, false, true); addConnectingSegment(new Segment(source.bottomRight, target.bottomLeft), source, target, true, false); } if (source.y == target.y) { addConnectingSegment(new Segment(source.topLeft, target.topRight), source, target, true, false); addConnectingSegment(new Segment(source.topRight, target.topLeft), source, target, false, true); } if (source.x == target.x) { addConnectingSegment( new Segment(source.bottomLeft, target.topLeft), source, target, false, true); addConnectingSegment( new Segment(source.topLeft, target.bottomLeft), source, target, true, false); } if (source.right() == target.right()) { addConnectingSegment(new Segment(source.bottomRight, target.topRight), source, target, true, false); addConnectingSegment(new Segment(source.topRight, target.bottomRight), source, target, false, true); } } /** * Attempts to add a segment between the given obstacles to the visibility * graph. This method is specifically written for the case where the two * obstacles intersect and contains a boolean as to whether to check the * diagonal that includes the top right point of the other obstacle. * * @param segment * the segment to check * @param o1 * the first obstacle * @param o2 * the second obstacle * @param checkTopRight1 * whether or not to check the diagonal containing top right * point */ private void addConnectingSegment(Segment segment, Obstacle o1, Obstacle o2, boolean checkTopRight1, boolean checkTopRight2) { if (threshold != 0 && (segment.end.getDistance(end) + segment.end.getDistance(start) > threshold || segment.start .getDistance(end) + segment.start.getDistance(start) > threshold)) return; if (o2.containsProper(segment.start) || o1.containsProper(segment.end)) return; if (checkTopRight1 && segment.intersects(o1.x, o1.bottom() - 1, o1.right() - 1, o1.y)) return; if (checkTopRight2 && segment.intersects(o2.x, o2.bottom() - 1, o2.right() - 1, o2.y)) return; if (!checkTopRight1 && segment.intersects(o1.x, o1.y, o1.right() - 1, o1.bottom() - 1)) return; if (!checkTopRight2 && segment.intersects(o2.x, o2.y, o2.right() - 1, o2.bottom() - 1)) return; stack.push(o1); stack.push(o2); stack.push(segment); } /** * Adds an obstacle to the visibility graph and generates new segments * * @param newObs * the new obstacle, should not be in the graph already */ private void addObstacle(Obstacle newObs) { visibleObstacles.add(newObs); Iterator oItr = new HashSet(visibleObstacles).iterator(); while (oItr.hasNext()) { Obstacle currObs = (Obstacle) oItr.next(); if (newObs != currObs) addSegmentsFor(newObs, currObs); } addPerimiterSegments(newObs); addSegmentsFor(start, newObs); addSegmentsFor(end, newObs); } /** * Adds the segments along the perimiter of an obstacle to the visiblity * graph queue. * * @param obs * the obstacle */ private void addPerimiterSegments(Obstacle obs) { Segment seg = new Segment(obs.topLeft, obs.topRight); stack.push(obs); stack.push(null); stack.push(seg); seg = new Segment(obs.topRight, obs.bottomRight); stack.push(obs); stack.push(null); stack.push(seg); seg = new Segment(obs.bottomRight, obs.bottomLeft); stack.push(obs); stack.push(null); stack.push(seg); seg = new Segment(obs.bottomLeft, obs.topLeft); stack.push(obs); stack.push(null); stack.push(seg); } /** * Attempts to add a segment to the visibility graph. First checks to see if * the segment is outside the threshold oval. Then it compares the segment * against all obstacles. If it is clean, the segment is finally added to * the graph. * * @param segment * the segment * @param exclude1 * an obstacle to exclude from the search * @param exclude2 * another obstacle to exclude from the search * @param allObstacles * the list of all obstacles */ private void addSegment(Segment segment, Obstacle exclude1, Obstacle exclude2, List allObstacles) { if (threshold != 0 && (segment.end.getDistance(end) + segment.end.getDistance(start) > threshold || segment.start .getDistance(end) + segment.start.getDistance(start) > threshold)) return; for (int i = 0; i < allObstacles.size(); i++) { Obstacle obs = (Obstacle) allObstacles.get(i); if (obs == exclude1 || obs == exclude2 || obs.exclude) continue; if (segment.intersects(obs.x, obs.y, obs.right() - 1, obs.bottom() - 1) || segment.intersects(obs.x, obs.bottom() - 1, obs.right() - 1, obs.y) || obs.containsProper(segment.start) || obs.containsProper(segment.end)) { if (!visibleObstacles.contains(obs)) addObstacle(obs); return; } } linkVertices(segment); } /** * Adds the segments between the given obstacles. * * @param source * source obstacle * @param target * target obstacle */ private void addSegmentsFor(Obstacle source, Obstacle target) { if (source.intersects(target)) addAllSegmentsBetween(source, target); else if (target.bottom() - 1 < source.y) addSegmentsTargetAboveSource(source, target); else if (source.bottom() - 1 < target.y) addSegmentsTargetAboveSource(target, source); else if (target.right() - 1 < source.x) addSegmentsTargetBesideSource(source, target); else addSegmentsTargetBesideSource(target, source); } /** * Adds the segments between the given obstacles. * * @param source * source obstacle * @param target * target obstacle */ private void addSegmentsFor(Vertex vertex, Obstacle obs) { Segment seg = null; Segment seg2 = null; switch (obs.getPosition(vertex)) { case PositionConstants.SOUTH_WEST: case PositionConstants.NORTH_EAST: seg = new Segment(vertex, obs.topLeft); seg2 = new Segment(vertex, obs.bottomRight); break; case PositionConstants.SOUTH_EAST: case PositionConstants.NORTH_WEST: seg = new Segment(vertex, obs.topRight); seg2 = new Segment(vertex, obs.bottomLeft); break; case PositionConstants.NORTH: seg = new Segment(vertex, obs.topLeft); seg2 = new Segment(vertex, obs.topRight); break; case PositionConstants.EAST: seg = new Segment(vertex, obs.bottomRight); seg2 = new Segment(vertex, obs.topRight); break; case PositionConstants.SOUTH: seg = new Segment(vertex, obs.bottomRight); seg2 = new Segment(vertex, obs.bottomLeft); break; case PositionConstants.WEST: seg = new Segment(vertex, obs.topLeft); seg2 = new Segment(vertex, obs.bottomLeft); break; default: if (vertex.x == obs.x) { seg = new Segment(vertex, obs.topLeft); seg2 = new Segment(vertex, obs.bottomLeft); } else if (vertex.y == obs.y) { seg = new Segment(vertex, obs.topLeft); seg2 = new Segment(vertex, obs.topRight); } else if (vertex.y == obs.bottom() - 1) { seg = new Segment(vertex, obs.bottomLeft); seg2 = new Segment(vertex, obs.bottomRight); } else if (vertex.x == obs.right() - 1) { seg = new Segment(vertex, obs.topRight); seg2 = new Segment(vertex, obs.bottomRight); } else { throw new RuntimeException("Unexpected vertex conditions"); //$NON-NLS-1$ } } stack.push(obs); stack.push(null); stack.push(seg); stack.push(obs); stack.push(null); stack.push(seg2); } private void addSegmentsTargetAboveSource(Obstacle source, Obstacle target) { // target located above source Segment seg = null; Segment seg2 = null; if (target.x > source.x) { seg = new Segment(source.topLeft, target.topLeft); if (target.x < source.right() - 1) seg2 = new Segment(source.topRight, target.bottomLeft); else seg2 = new Segment(source.bottomRight, target.topLeft); } else if (source.x == target.x) { seg = new Segment(source.topLeft, target.bottomLeft); seg2 = new Segment(source.topRight, target.bottomLeft); } else { seg = new Segment(source.bottomLeft, target.bottomLeft); seg2 = new Segment(source.topRight, target.bottomLeft); } stack.push(source); stack.push(target); stack.push(seg); stack.push(source); stack.push(target); stack.push(seg2); seg = null; seg2 = null; if (target.right() < source.right()) { seg = new Segment(source.topRight, target.topRight); if (target.right() - 1 > source.x) seg2 = new Segment(source.topLeft, target.bottomRight); else seg2 = new Segment(source.bottomLeft, target.topRight); } else if (source.right() == target.right()) { seg = new Segment(source.topRight, target.bottomRight); seg2 = new Segment(source.topLeft, target.bottomRight); } else { seg = new Segment(source.bottomRight, target.bottomRight); seg2 = new Segment(source.topLeft, target.bottomRight); } stack.push(source); stack.push(target); stack.push(seg); stack.push(source); stack.push(target); stack.push(seg2); } private void addSegmentsTargetBesideSource(Obstacle source, Obstacle target) { // target located above source Segment seg = null; Segment seg2 = null; if (target.y > source.y) { seg = new Segment(source.topLeft, target.topLeft); if (target.y < source.bottom() - 1) seg2 = new Segment(source.bottomLeft, target.topRight); else seg2 = new Segment(source.bottomRight, target.topLeft); } else if (source.y == target.y) { // degenerate case seg = new Segment(source.topLeft, target.topRight); seg2 = new Segment(source.bottomLeft, target.topRight); } else { seg = new Segment(source.topRight, target.topRight); seg2 = new Segment(source.bottomLeft, target.topRight); } stack.push(source); stack.push(target); stack.push(seg); stack.push(source); stack.push(target); stack.push(seg2); seg = null; seg2 = null; if (target.bottom() < source.bottom()) { seg = new Segment(source.bottomLeft, target.bottomLeft); if (target.bottom() - 1 > source.y) seg2 = new Segment(source.topLeft, target.bottomRight); else seg2 = new Segment(source.topRight, target.bottomLeft); } else if (source.bottom() == target.bottom()) { seg = new Segment(source.bottomLeft, target.bottomRight); seg2 = new Segment(source.topLeft, target.bottomRight); } else { seg = new Segment(source.bottomRight, target.bottomRight); seg2 = new Segment(source.topLeft, target.bottomRight); } stack.push(source); stack.push(target); stack.push(seg); stack.push(source); stack.push(target); stack.push(seg2); } /** * */ void cleanup() { // segments.clear(); visibleVertices.clear(); } /** * Begins the creation of the visibility graph with the first segment * * @param allObstacles * list of all obstacles */ private void createVisibilityGraph(List allObstacles) { stack.push(null); stack.push(null); stack.push(new Segment(start, end)); while (!stack.isEmpty()) addSegment(stack.pop(), stack.popObstacle(), stack.popObstacle(), allObstacles); } /** * Once the visibility graph is constructed, this is called to label the * graph and determine the shortest path. Returns false if no path can be * found. * * @return true if a path can be found. */ private boolean determineShortestPath() { if (!labelGraph()) return false; Vertex vertex = end; prevCostRatio = end.cost / start.getDistance(end); Vertex nextVertex; while (!vertex.equals(start)) { nextVertex = vertex.label; if (nextVertex == null) return false; Segment s = new Segment(nextVertex, vertex); segments.add(s); vertex = nextVertex; } Collections.reverse(segments); return true; } /** * Resets all necessary fields for a solve. */ void fullReset() { visibleVertices.clear(); segments.clear(); if (prevCostRatio == 0) { double distance = start.getDistance(end); threshold = distance * OVAL_CONSTANT; } else threshold = prevCostRatio * EPSILON * start.getDistance(end); visibleObstacles.clear(); resetPartial(); } /** * Creates the visibility graph and returns whether or not a shortest path * could be determined. * * @param allObstacles * the list of all obstacles * @return true if a shortest path was found */ boolean generateShortestPath(List allObstacles) { createVisibilityGraph(allObstacles); if (visibleVertices.size() == 0) return false; return determineShortestPath(); } /** * Returns the list of constrained points through which this path must pass * or null. * * @see #setBendPoints(PointList) * @return list of bend points */ public PointList getBendPoints() { return bendpoints; } /** * Returns the end point for this path * * @return end point for this path */ public Point getEndPoint() { return end; } /** * Returns the solution to this path. * * @return the points for this path. */ public PointList getPoints() { return points; } /** * Returns the start point for this path * * @return start point for this path */ public Point getStartPoint() { return start; } /** * Returns a subpath for this path at the given segment * * @param currentSegment * the segment at which the subpath should be created * @return the new path */ Path getSubPath(Segment currentSegment) { // ready new path Path newPath = new Path(currentSegment.start, end); newPath.grownSegments = new ArrayList(grownSegments.subList( grownSegments.indexOf(currentSegment), grownSegments.size())); // fix old path grownSegments = new ArrayList(grownSegments.subList(0, grownSegments.indexOf(currentSegment) + 1)); end = currentSegment.end; subPath = newPath; return newPath; } /** * Resets the vertices that this path has traveled prior to this segment. * This is called when the path has become inverted and needs to rectify any * labeling mistakes it made before it knew it was inverted. * * @param currentSegment * the segment at which the path found it was inverted */ void invertPriorVertices(Segment currentSegment) { int stop = grownSegments.indexOf(currentSegment); for (int i = 0; i < stop; i++) { Vertex vertex = ((Segment) grownSegments.get(i)).end; if (vertex.type == Vertex.INNIE) vertex.type = Vertex.OUTIE; else vertex.type = Vertex.INNIE; } } /** * Returns true if this obstacle is in the visibility graph * * @param obs * the obstacle * @return true if obstacle is in the visibility graph */ boolean isObstacleVisible(Obstacle obs) { return visibleObstacles.contains(obs); } /** * Labels the visibility graph to assist in finding the shortest path * * @return false if there was a gap in the visibility graph */ private boolean labelGraph() { int numPermanentNodes = 1; Vertex vertex = start; Vertex neighborVertex = null; vertex.isPermanent = true; double newCost; while (numPermanentNodes != visibleVertices.size()) { List neighbors = vertex.neighbors; if (neighbors == null) return false; // label neighbors if they have a new shortest path for (int i = 0; i < neighbors.size(); i++) { neighborVertex = (Vertex) neighbors.get(i); if (!neighborVertex.isPermanent) { newCost = vertex.cost + vertex.getDistance(neighborVertex); if (neighborVertex.label == null) { neighborVertex.label = vertex; neighborVertex.cost = newCost; } else if (neighborVertex.cost > newCost) { neighborVertex.label = vertex; neighborVertex.cost = newCost; } } } // find the next none-permanent, labeled vertex with smallest cost double smallestCost = 0; Vertex tempVertex = null; Iterator v = visibleVertices.iterator(); while (v.hasNext()) { tempVertex = (Vertex) v.next(); if (!tempVertex.isPermanent && tempVertex.label != null && (tempVertex.cost < smallestCost || smallestCost == 0)) { smallestCost = tempVertex.cost; vertex = tempVertex; } } // set the new vertex to permanent. vertex.isPermanent = true; numPermanentNodes++; } return true; } /** * Links two vertices together in the visibility graph * * @param segment * the segment to add */ private void linkVertices(Segment segment) { if (segment.start.neighbors == null) segment.start.neighbors = new ArrayList(); if (segment.end.neighbors == null) segment.end.neighbors = new ArrayList(); if (!segment.start.neighbors.contains(segment.end)) { segment.start.neighbors.add(segment.end); segment.end.neighbors.add(segment.start); } visibleVertices.add(segment.start); visibleVertices.add(segment.end); } /** * Called to reconnect a subpath back onto this path. Does a depth-first * search to reconnect all paths. Should be called after sorting. */ void reconnectSubPaths() { if (subPath != null) { subPath.reconnectSubPaths(); Segment changedSegment = (Segment) subPath.grownSegments.remove(0); Segment oldSegment = (Segment) grownSegments.get(grownSegments .size() - 1); oldSegment.end = changedSegment.end; grownSegments.addAll(subPath.grownSegments); subPath.points.removePoint(0); points.removePoint(points.size() - 1); points.addAll(subPath.points); visibleObstacles.addAll(subPath.visibleObstacles); end = subPath.end; subPath = null; } } /** * Refreshes the exclude field on the obstacles in the list. Excludes all * obstacles that contain the start or end point for this path. * * @param allObstacles * list of all obstacles */ void refreshExcludedObstacles(List allObstacles) { excludedObstacles.clear(); for (int i = 0; i < allObstacles.size(); i++) { Obstacle o = (Obstacle) allObstacles.get(i); o.exclude = false; if (o.contains(start)) { if (o.containsProper(start)) o.exclude = true; else { /* * $TODO Check for corners. If the path begins exactly at * the corner of an obstacle, the exclude should also be * true. * * Or, change segment intersection so that two segments that * share an endpoint do not intersect. */ } } if (o.contains(end)) { if (o.containsProper(end)) o.exclude = true; else { // check for corners. See above statement. } } if (o.exclude && !excludedObstacles.contains(o)) excludedObstacles.add(o); } } /** * Resets the fields for everything in the solve after the visibility graph * steps. */ void resetPartial() { isMarked = false; isInverted = false; subPath = null; isDirty = false; grownSegments.clear(); points.removeAllPoints(); } /** * Sets the list of bend points to the given list and dirties the path. * * @param bendPoints * the list of bend points */ public void setBendPoints(PointList bendPoints) { this.bendpoints = bendPoints; isDirty = true; } /** * Sets the end point for this path to the given point. * * @param end * the new end point for this path */ public void setEndPoint(Point end) { if (end.equals(this.end)) return; this.end = new Vertex(end, null); isDirty = true; } /** * Sets the start point for this path to the given point. * * @param start * the new start point for this path */ public void setStartPoint(Point start) { if (start.equals(this.start)) return; this.start = new Vertex(start, null); isDirty = true; } /** * Returns true if the path is clean and intersects the given * obstacle. Also dirties the path in the process. * * @since 3.0 * @param obs * the obstacle * @return true if a clean path touches the obstacle */ boolean testAndSet(Obstacle obs) { if (isDirty) return false; // This will never actually happen because obstacles are not stored by // identity if (excludedObstacles.contains(obs)) return false; Segment seg1 = new Segment(obs.topLeft, obs.bottomRight); Segment seg2 = new Segment(obs.topRight, obs.bottomLeft); for (int s = 0; s < points.size() - 1; s++) { points.getPoint(CURRENT, s); points.getPoint(NEXT, s + 1); if (seg1.intersects(CURRENT, NEXT) || seg2.intersects(CURRENT, NEXT) || obs.contains(CURRENT) || obs.contains(NEXT)) { isDirty = true; return true; } } return false; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/PopulateRanks.java000066400000000000000000000044211166301720600302250ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import java.util.Stack; /** * This class takes a DirectedGraph with an optimal rank assignment and a * spanning tree, and populates the ranks of the DirectedGraph. Virtual nodes * are inserted for edges that span 1 or more ranks. *

    * Ranks are populated using a pre-order depth-first traversal of the spanning * tree. For each node, all edges requiring virtual nodes are added to the * ranks. * * @author Randy Hudson * @since 2.1.2 */ class PopulateRanks extends GraphVisitor { private Stack changes = new Stack(); /** * @see GraphVisitor#visit(DirectedGraph) */ public void visit(DirectedGraph g) { if (g.forestRoot != null) { for (int i = g.forestRoot.outgoing.size() - 1; i >= 0; i--) g.removeEdge(g.forestRoot.outgoing.getEdge(i)); g.removeNode(g.forestRoot); } g.ranks = new RankList(); for (int i = 0; i < g.nodes.size(); i++) { Node node = g.nodes.getNode(i); g.ranks.getRank(node.rank).add(node); } for (int i = 0; i < g.nodes.size(); i++) { Node node = g.nodes.getNode(i); for (int j = 0; j < node.outgoing.size();) { Edge e = node.outgoing.getEdge(j); if (e.getLength() > 1) changes.push(new VirtualNodeCreation(e, g)); else j++; } } } /** * @see GraphVisitor#revisit(DirectedGraph) */ public void revisit(DirectedGraph g) { for (int r = 0; r < g.ranks.size(); r++) { Rank rank = g.ranks.getRank(r); Node prev = null, cur; for (int n = 0; n < rank.size(); n++) { cur = rank.getNode(n); cur.left = prev; if (prev != null) { prev.right = cur; } prev = cur; } } for (int i = 0; i < changes.size(); i++) { RevertableChange change = (RevertableChange) changes.get(i); change.revert(); } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/Rank.java000066400000000000000000000034471166301720600263370ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; /** * For Internal Use only. * * @author hudsonr * @since 2.1.2 */ public class Rank extends NodeList { int bottomPadding; int height; int location; final int hash = new Object().hashCode(); int topPadding; int total; void add(Node n) { super.add(n); } void assignIndices() { total = 0; Node node; int mag; for (int i = 0; i < size(); i++) { node = getNode(i); mag = Math.max(1, node.incoming.size() + node.outgoing.size()); mag = Math.min(mag, 5); if (node instanceof SubgraphBoundary) mag = 4; total += mag; node.index = total; total += mag; } } /** * Returns the number of nodes in this rank. * * @return the number of nodes */ public int count() { return super.size(); } /** * @see Object#equals(Object) */ public boolean equals(Object o) { return o == this; } /** * @see Object#hashCode() Overridden for speed based on equality. */ public int hashCode() { return hash; } void setDimensions(int location, int rowHeight) { this.height = rowHeight; this.location = location; for (int i = 0; i < size(); i++) { Node n = getNode(i); n.y = location; n.height = rowHeight; } } /** * @deprecated Do not call */ public void sort() { } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/RankAssignmentSolver.java000066400000000000000000000173661166301720600315700ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import java.util.Iterator; import java.util.Stack; /** * Assigns the final rank assignment for a DirectedGraph with an initial * feasible spanning tree. * * @author Randy Hudson * @since 2.1.2 */ class RankAssignmentSolver extends SpanningTreeVisitor { DirectedGraph graph; EdgeList spanningTree; boolean searchDirection; int depthFirstCutValue(Edge edge, int count) { Node n = getTreeTail(edge); setTreeMin(n, count); int cutvalue = 0; int multiplier = (edge.target == n) ? 1 : -1; EdgeList list; list = n.outgoing; Edge e; for (int i = 0; i < list.size(); i++) { e = list.getEdge(i); if (e.tree && e != edge) { count = depthFirstCutValue(e, count); cutvalue += (e.cut - e.weight) * multiplier; } else { cutvalue -= e.weight * multiplier; } } list = n.incoming; for (int i = 0; i < list.size(); i++) { e = list.getEdge(i); if (e.tree && e != edge) { count = depthFirstCutValue(e, count); cutvalue -= (e.cut - e.weight) * multiplier; } else { cutvalue += e.weight * multiplier; } } edge.cut = cutvalue; if (cutvalue < 0) spanningTree.add(edge); setTreeMax(n, count); return count + 1; } /** * returns the Edge which should be entered. * * @param branch * @return Edge */ Edge enter(Node branch) { Node n; Edge result = null; int minSlack = Integer.MAX_VALUE; boolean incoming = getParentEdge(branch).target != branch; // searchDirection = !searchDirection; for (int i = 0; i < graph.nodes.size(); i++) { if (searchDirection) n = graph.nodes.getNode(i); else n = graph.nodes.getNode(graph.nodes.size() - 1 - i); if (subtreeContains(branch, n)) { EdgeList edges; if (incoming) edges = n.incoming; else edges = n.outgoing; for (int j = 0; j < edges.size(); j++) { Edge e = edges.getEdge(j); if (!subtreeContains(branch, e.opposite(n)) && !e.tree && e.getSlack() < minSlack) { result = e; minSlack = e.getSlack(); } } } } return result; } int getTreeMax(Node n) { return n.workingInts[1]; } int getTreeMin(Node n) { return n.workingInts[0]; } void initCutValues() { Node root = graph.nodes.getNode(0); spanningTree = new EdgeList(); Edge e; setTreeMin(root, 1); setTreeMax(root, 1); for (int i = 0; i < root.outgoing.size(); i++) { e = root.outgoing.getEdge(i); if (!getSpanningTreeChildren(root).contains(e)) continue; setTreeMax(root, depthFirstCutValue(e, getTreeMax(root))); } for (int i = 0; i < root.incoming.size(); i++) { e = root.incoming.getEdge(i); if (!getSpanningTreeChildren(root).contains(e)) continue; setTreeMax(root, depthFirstCutValue(e, getTreeMax(root))); } } Edge leave() { Edge result = null; Edge e; int minCut = 0; int weight = -1; for (int i = 0; i < spanningTree.size(); i++) { e = spanningTree.getEdge(i); if (e.cut < minCut) { result = e; minCut = result.cut; weight = result.weight; } else if (e.cut == minCut && e.weight > weight) { result = e; weight = result.weight; } } return result; } void networkSimplexLoop() { Edge leave, enter; int count = 0; while ((leave = leave()) != null && count < 900) { count++; Node leaveTail = getTreeTail(leave); Node leaveHead = getTreeHead(leave); enter = enter(leaveTail); if (enter == null) break; // Break the "leave" edge from the spanning tree getSpanningTreeChildren(leaveHead).remove(leave); setParentEdge(leaveTail, null); leave.tree = false; spanningTree.remove(leave); Node enterTail = enter.source; if (!subtreeContains(leaveTail, enterTail)) // Oops, wrong end of the edge enterTail = enter.target; Node enterHead = enter.opposite(enterTail); // Prepare enterTail by making it the root of its sub-tree updateSubgraph(enterTail); // Add "enter" edge to the spanning tree getSpanningTreeChildren(enterHead).add(enter); setParentEdge(enterTail, enter); enter.tree = true; repairCutValues(enter); Node commonAncestor = enterHead; while (!subtreeContains(commonAncestor, leaveHead)) { repairCutValues(getParentEdge(commonAncestor)); commonAncestor = getTreeParent(commonAncestor); } while (leaveHead != commonAncestor) { repairCutValues(getParentEdge(leaveHead)); leaveHead = getTreeParent(leaveHead); } updateMinMax(commonAncestor, getTreeMin(commonAncestor)); tightenEdge(enter); } } void repairCutValues(Edge edge) { spanningTree.remove(edge); Node n = getTreeTail(edge); int cutvalue = 0; int multiplier = (edge.target == n) ? 1 : -1; EdgeList list; list = n.outgoing; Edge e; for (int i = 0; i < list.size(); i++) { e = list.getEdge(i); if (e.tree && e != edge) cutvalue += (e.cut - e.weight) * multiplier; else cutvalue -= e.weight * multiplier; } list = n.incoming; for (int i = 0; i < list.size(); i++) { e = list.getEdge(i); if (e.tree && e != edge) cutvalue -= (e.cut - e.weight) * multiplier; else cutvalue += e.weight * multiplier; } edge.cut = cutvalue; if (cutvalue < 0) spanningTree.add(edge); } void setTreeMax(Node n, int value) { n.workingInts[1] = value; } void setTreeMin(Node n, int value) { n.workingInts[0] = value; } boolean subtreeContains(Node parent, Node child) { return parent.workingInts[0] <= child.workingInts[1] && child.workingInts[1] <= parent.workingInts[1]; } void tightenEdge(Edge edge) { Node tail = getTreeTail(edge); int delta = edge.getSlack(); if (tail == edge.target) delta = -delta; Node n; for (int i = 0; i < graph.nodes.size(); i++) { n = graph.nodes.getNode(i); if (subtreeContains(tail, n)) n.rank += delta; } } int updateMinMax(Node root, int count) { setTreeMin(root, count); EdgeList edges = getSpanningTreeChildren(root); for (int i = 0; i < edges.size(); i++) count = updateMinMax(getTreeTail(edges.getEdge(i)), count); setTreeMax(root, count); return count + 1; } void updateSubgraph(Node root) { Edge flip = getParentEdge(root); if (flip != null) { Node rootParent = getTreeParent(root); getSpanningTreeChildren(rootParent).remove(flip); updateSubgraph(rootParent); setParentEdge(root, null); setParentEdge(rootParent, flip); repairCutValues(flip); getSpanningTreeChildren(root).add(flip); } } public void visit(DirectedGraph graph) { this.graph = graph; initCutValues(); networkSimplexLoop(); if (graph.forestRoot == null) graph.nodes.normalizeRanks(); else normalizeForest(); } private void normalizeForest() { NodeList tree = new NodeList(); graph.nodes.resetFlags(); graph.forestRoot.flag = true; EdgeList rootEdges = graph.forestRoot.outgoing; Stack stack = new Stack(); for (int i = 0; i < rootEdges.size(); i++) { Node node = rootEdges.getEdge(i).target; node.flag = true; stack.push(node); while (!stack.isEmpty()) { node = (Node) stack.pop(); tree.add(node); Iterator neighbors = node.iteratorNeighbors(); while (neighbors.hasNext()) { Node neighbor = (Node) neighbors.next(); if (!neighbor.flag) { neighbor.flag = true; stack.push(neighbor); } } } tree.normalizeRanks(); tree.clear(); } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/RankList.java000066400000000000000000000021631166301720600271650ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import java.util.ArrayList; /** * For internal use only. A list of lists. * * @author hudsonr * @since 2.1.2 */ public final class RankList { ArrayList ranks = new ArrayList(); /** * Returns the specified rank. * * @param rank * the row * @return the rank */ public Rank getRank(int rank) { while (ranks.size() <= rank) ranks.add(new Rank()); return (Rank) ranks.get(rank); } /** * Returns the total number or ranks. * * @return the total number of ranks */ public int size() { return ranks.size(); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/RankSorter.java000066400000000000000000000136201166301720600275300ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import java.util.Collections; import java.util.Comparator; import java.util.Random; /** * Sorts Ranks during the up and down sweeps of the MinCross visitor. * * @author Randy Hudson * @since 2.1.2 */ class RankSorter { Random flipflop = new Random(3); Node node; double rankSize, prevRankSize, nextRankSize; int currentRow; Rank rank; double progress; DirectedGraph g; protected void assignIncomingSortValues() { rankSize = rank.total; prevRankSize = g.ranks.getRank(currentRow - 1).total; if (currentRow < g.ranks.size() - 1) nextRankSize = g.ranks.getRank(currentRow + 1).total; for (int n = 0; n < rank.count(); n++) { node = rank.getNode(n); sortValueIncoming(); } } protected void assignOutgoingSortValues() { rankSize = rank.total; prevRankSize = g.ranks.getRank(currentRow + 1).total; if (currentRow > 1) nextRankSize = g.ranks.getRank(currentRow - 1).total; for (int n = 0; n < rank.count(); n++) { node = rank.getNode(n); sortValueOutgoing(); } } double evaluateNodeIncoming() { boolean change = false; EdgeList incoming = node.incoming; do { change = false; for (int i = 0; i < incoming.size() - 1; i++) { if (incoming.getSourceIndex(i) > incoming.getSourceIndex(i + 1)) { Edge e = incoming.getEdge(i); incoming.set(i, incoming.get(i + 1)); incoming.set(i + 1, e); change = true; } } } while (change); int n = incoming.size(); if (n == 0) { return node.index * prevRankSize / rankSize; } if (n % 2 == 1) return incoming.getSourceIndex(n / 2); int l = incoming.getSourceIndex(n / 2 - 1); int r = incoming.getSourceIndex(n / 2); if (progress >= 0.8 && n > 2) { int dl = l - incoming.getSourceIndex(0); int dr = incoming.getSourceIndex(n - 1) - r; if (dl < dr) return l; if (dl > dr) return r; } if (progress > 0.25 && progress < 0.75) { if (flipflop.nextBoolean()) return (l + l + r) / 3.0; else return (r + r + l) / 3.0; } return (l + r) / 2.0; } double evaluateNodeOutgoing() { boolean change = false; EdgeList outgoing = node.outgoing; do { change = false; for (int i = 0; i < outgoing.size() - 1; i++) { if (outgoing.getTargetIndex(i) > outgoing.getTargetIndex(i + 1)) { Edge e = outgoing.getEdge(i); outgoing.set(i, outgoing.get(i + 1)); outgoing.set(i + 1, e); change = true; } } } while (change); int n = outgoing.size(); if (n == 0) return node.index * prevRankSize / rankSize; if (n % 2 == 1) return outgoing.getTargetIndex(n / 2); int l = outgoing.getTargetIndex(n / 2 - 1); int r = outgoing.getTargetIndex(n / 2); if (progress >= 0.8 && n > 2) { int dl = l - outgoing.getTargetIndex(0); int dr = outgoing.getTargetIndex(n - 1) - r; if (dl < dr) return l; if (dl > dr) return r; } if (progress > 0.25 && progress < 0.75) { if (flipflop.nextBoolean()) return (l + l + r) / 3.0; else return (r + r + l) / 3.0; } return (l + r) / 2.0; } public void sortRankIncoming(DirectedGraph g, Rank rank, int row, double progress) { this.currentRow = row; this.rank = rank; this.progress = progress; assignIncomingSortValues(); sort(); postSort(); } public void init(DirectedGraph g) { this.g = g; for (int i = 0; i < g.ranks.size(); i++) { rank = g.ranks.getRank(i); // Sort the ranks based on their constraints. Constraints are // preserved throughout. Collections.sort(rank, new Comparator() { public int compare(Object left, Object right) { return ((Node) left).rowOrder - ((Node) right).rowOrder; } }); postSort(); } } void optimize(DirectedGraph g) { } protected void postSort() { rank.assignIndices(); } void sort() { boolean change; do { change = false; for (int i = 0; i < rank.size() - 1; i++) change |= swap(i); if (!change) break; change = false; for (int i = rank.size() - 2; i >= 0; i--) change |= swap(i); } while (change); } boolean swap(int i) { Node left = rank.getNode(i); Node right = rank.getNode(i + 1); if (GraphUtilities.isConstrained(left, right)) return false; if (left.sortValue <= right.sortValue) return false; rank.set(i, right); rank.set(i + 1, left); return true; } public void sortRankOutgoing(DirectedGraph g, Rank rank, int row, double progress) { this.currentRow = row; this.rank = rank; this.progress = progress; assignOutgoingSortValues(); sort(); postSort(); } void sortValueIncoming() { node.sortValue = evaluateNodeIncoming(); // $TODO restore this optimization // if (progress == 0.0 && !(node instanceof VirtualNode)) // node.sortValue = -1; double value = evaluateNodeOutgoing(); if (value < 0) value = node.index * nextRankSize / rankSize; node.sortValue += value * progress; // if (progress < 0.7 && node.sortValue != -1) // node.sortValue += Math.random() * rankSize / (5 + 8 * progress); } void sortValueOutgoing() { node.sortValue = evaluateNodeOutgoing(); // $TODO restore this optimization // if (progress == 0.0 && !(node instanceof VirtualNode)) // node.sortValue = -1; double value = evaluateNodeIncoming(); if (value < 0) value = node.index * nextRankSize / rankSize; node.sortValue += value * progress; // if (progress < 0.7 && node.sortValue != -1) // node.sortValue += Math.random() * rankSize / (5 + 8 * progress); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/RevertableChange.java000066400000000000000000000012101166301720600306270ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; /** * @since 3.1 */ class RevertableChange { void revert() { } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/RouteEdges.java000066400000000000000000000054631166301720600275120ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import org.eclipse.draw2d.geometry.Insets; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.PointList; import org.eclipse.draw2d.geometry.Rectangle; /** * @author Randy Hudson */ class RouteEdges extends GraphVisitor { /** * @see GraphVisitor#visit(DirectedGraph) */ public void revisit(DirectedGraph g) { for (int i = 0; i < g.edges.size(); i++) { Edge edge = (Edge) g.edges.get(i); edge.start = new Point(edge.getSourceOffset() + edge.source.x, edge.source.y + edge.source.height); if (edge.source instanceof SubgraphBoundary) { SubgraphBoundary boundary = (SubgraphBoundary) edge.source; if (boundary.getParent().head == boundary) edge.start.y = boundary.getParent().y + boundary.getParent().insets.top; } edge.end = new Point(edge.getTargetOffset() + edge.target.x, edge.target.y); if (edge.vNodes != null) routeLongEdge(edge, g); else { PointList list = new PointList(); list.addPoint(edge.start); list.addPoint(edge.end); edge.setPoints(list); } } } static void routeLongEdge(Edge edge, DirectedGraph g) { ShortestPathRouter router = new ShortestPathRouter(); Path path = new Path(edge.start, edge.end); router.addPath(path); Rectangle o; Insets padding; for (int i = 0; i < edge.vNodes.size(); i++) { VirtualNode node = (VirtualNode) edge.vNodes.get(i); Node neighbor; if (node.left != null) { neighbor = node.left; o = new Rectangle(neighbor.x, neighbor.y, neighbor.width, neighbor.height); padding = g.getPadding(neighbor); o.width += padding.right + padding.left; o.width += (edge.getPadding() * 2); o.x -= (padding.left + edge.getPadding()); o.union(o.getLocation().translate(-100000, 2)); router.addObstacle(o); } if (node.right != null) { neighbor = node.right; o = new Rectangle(neighbor.x, neighbor.y, neighbor.width, neighbor.height); padding = g.getPadding(neighbor); o.width += padding.right + padding.left; o.width += (edge.getPadding() * 2); o.x -= (padding.left + edge.getPadding()); o.union(o.getLocation().translate(100000, 2)); router.addObstacle(o); } } router.setSpacing(0); router.solve(); edge.setPoints(path.getPoints()); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/Segment.java000066400000000000000000000064101166301720600270370ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import org.eclipse.draw2d.geometry.Geometry; import org.eclipse.draw2d.geometry.Point; /** * A Segment representation for the ShortestPathRouting. A segment is a line * between two vertices. * * This class is for internal use only * * @author Whitney Sorenson * @since 3.0 */ class Segment { Vertex start, end; /** * Creates a segment between the given start and end points. * * @param start * the start vertex * @param end * the end vertex */ Segment(Vertex start, Vertex end) { this.start = start; this.end = end; } /** * Returns the cosine of the made between this segment and the given segment * * @param otherSegment * the other segment * @return cosine value (not arc-cos) */ double cosine(Segment otherSegment) { double cos = (((start.x - end.x) * (otherSegment.end.x - otherSegment.start.x)) + ((start.y - end.y) * (otherSegment.end.y - otherSegment.start.y))) / (getLength() * otherSegment.getLength()); double sin = (((start.x - end.x) * (otherSegment.end.y - otherSegment.start.y)) - ((start.y - end.y) * (otherSegment.end.x - otherSegment.start.x))); if (sin < 0.0) return (1 + cos); return -(1 + cos); } /** * Returns the cross product of this segment and the given segment * * @param otherSegment * the other segment * @return the cross product */ long crossProduct(Segment otherSegment) { return (((start.x - end.x) * (otherSegment.end.y - end.y)) - ((start.y - end.y) * (otherSegment.end.x - end.x))); } private double getLength() { return (end.getDistance(start)); } /** * Returns a number that represents the sign of the slope of this segment. * It does not return the actual slope. * * @return number representing sign of the slope */ double getSlope() { if (end.x - start.x >= 0) return (end.y - start.y); else return -(end.y - start.y); } /** * Returns true if the given segment intersects this segment. * * @param sx * start x * @param sy * start y * @param tx * end x * @param ty * end y * @return true if the segments intersect */ boolean intersects(int sx, int sy, int tx, int ty) { return Geometry.linesIntersect(start.x, start.y, end.x, end.y, sx, sy, tx, ty); } /** * Return true if the segment represented by the points intersects this * segment. * * @param s * start point * @param t * end point * @return true if the segments intersect */ boolean intersects(Point s, Point t) { return intersects(s.x, s.y, t.x, t.y); } /** * @see java.lang.Object#toString() */ public String toString() { return start + "---" + end; //$NON-NLS-1$ } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/ShortestPathRouter.java000066400000000000000000000616641166301720600313020ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import org.eclipse.draw2d.PositionConstants; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.PointList; import org.eclipse.draw2d.geometry.Rectangle; /** * Bends a collection of {@link Path Paths} around rectangular obstacles. This * class maintains a list of paths and obstacles. Updates can be made to the * paths and/or obstacles, and then an incremental solve can be invoked. *

    * The algorithm will attempt to find the shortest non-intersecting path between * each path's start and end points. Once all paths have been found, they will * be offset based on how many paths bend around the same corner of each * obstacle. *

    * The worst-case performance of this algorithm is p * s * n^2, where p is the * number of paths, n is the number of obstacles, and s is the average number of * segments in each path's final solution. *

    * This class is not intended to be subclassed. * * @author Whitney Sorenson * @author Randy Hudson * @since 3.0 */ public class ShortestPathRouter { /** * A stack of Paths. */ static class PathStack extends ArrayList { Path pop() { return (Path) remove(size() - 1); } void push(Path path) { add(path); } } /** * The number of times to grow obstacles and test for intersections. This is * a tradeoff between performance and quality of output. */ private static final int NUM_GROW_PASSES = 2; private int spacing = 4; private boolean growPassChangedObstacles; private List orderedPaths; private Map pathsToChildPaths; private PathStack stack; private List subPaths; private List userObstacles; private List userPaths; private List workingPaths; /** * Creates a new shortest path routing. */ public ShortestPathRouter() { userPaths = new ArrayList(); workingPaths = new ArrayList(); pathsToChildPaths = new HashMap(); userObstacles = new ArrayList(); } /** * Adds an obstacle with the given bounds to the obstacles. * * @param rect * the bounds of this obstacle * @return true if the added obstacle has dirtied one or more * paths */ public boolean addObstacle(Rectangle rect) { return internalAddObstacle(new Obstacle(rect, this)); } /** * Adds a path to the routing. * * @param path * the path to add. */ public void addPath(Path path) { userPaths.add(path); workingPaths.add(path); } /** * Fills the point lists of the Paths to the correct bent points. */ private void bendPaths() { for (int i = 0; i < orderedPaths.size(); i++) { Path path = (Path) orderedPaths.get(i); Segment segment = null; path.points.addPoint(new Point(path.start.x, path.start.y)); for (int v = 0; v < path.grownSegments.size(); v++) { segment = (Segment) path.grownSegments.get(v); Vertex vertex = segment.end; if (vertex != null && v < path.grownSegments.size() - 1) { if (vertex.type == Vertex.INNIE) { vertex.count++; path.points.addPoint(vertex.bend(vertex.count)); } else { path.points.addPoint(vertex.bend(vertex.totalCount)); vertex.totalCount--; } } } path.points.addPoint(new Point(path.end.x, path.end.y)); } } /** * Checks a vertex to see if its offset should shrink * * @param vertex * the vertex to check */ private void checkVertexForIntersections(Vertex vertex) { if (vertex.nearestObstacle != 0 || vertex.nearestObstacleChecked) return; int sideLength, x, y; sideLength = 2 * (vertex.totalCount * getSpacing()) + 1; if ((vertex.positionOnObstacle & PositionConstants.NORTH) > 0) y = vertex.y - sideLength; else y = vertex.y; if ((vertex.positionOnObstacle & PositionConstants.EAST) > 0) x = vertex.x; else x = vertex.x - sideLength; Rectangle r = new Rectangle(x, y, sideLength, sideLength); int xDist, yDist; for (int o = 0; o < userObstacles.size(); o++) { Obstacle obs = (Obstacle) userObstacles.get(o); if (obs != vertex.obs && r.intersects(obs)) { int pos = obs.getPosition(vertex); if (pos == 0) continue; if ((pos & PositionConstants.NORTH) > 0) // use top yDist = obs.y - vertex.y; else // use bottom yDist = vertex.y - obs.bottom() + 1; if ((pos & PositionConstants.EAST) > 0) // use right xDist = vertex.x - obs.right() + 1; else // use left xDist = obs.x - vertex.x; if (Math.max(xDist, yDist) < vertex.nearestObstacle || vertex.nearestObstacle == 0) { vertex.nearestObstacle = Math.max(xDist, yDist); vertex.updateOffset(); } } } vertex.nearestObstacleChecked = true; } /** * Checks all vertices along paths for intersections */ private void checkVertexIntersections() { for (int i = 0; i < workingPaths.size(); i++) { Path path = (Path) workingPaths.get(i); for (int s = 0; s < path.segments.size() - 1; s++) { Vertex vertex = ((Segment) path.segments.get(s)).end; checkVertexForIntersections(vertex); } } } /** * Frees up fields which aren't needed between invocations. */ private void cleanup() { for (int i = 0; i < workingPaths.size(); i++) { Path path = (Path) workingPaths.get(i); path.cleanup(); } } /** * Counts how many paths are on given vertices in order to increment their * total count. */ private void countVertices() { for (int i = 0; i < workingPaths.size(); i++) { Path path = (Path) workingPaths.get(i); for (int v = 0; v < path.segments.size() - 1; v++) ((Segment) path.segments.get(v)).end.totalCount++; } } /** * Dirties the paths that are on the given vertex * * @param vertex * the vertex that has the paths */ private boolean dirtyPathsOn(Vertex vertex) { List paths = vertex.paths; if (paths != null && paths.size() != 0) { for (int i = 0; i < paths.size(); i++) ((Path) paths.get(i)).isDirty = true; return true; } return false; } /** * Resyncs the parent paths with any new child paths that are necessary * because bendpoints have been added to the parent path. * * private void generateChildPaths() { for (int i = 0; i < userPaths.size(); * i++) { Path path = (Path)userPaths.get(i); PointList bendPoints = * path.bendpoints; if (bendPoints != null && bendPoints.size() != 0) { List * childPaths = new ArrayList(bendPoints.size() + 1); Path child = null; * Vertex prevVertex = path.start; Vertex currVertex = null; * * for (int b = 0; b < bendPoints.size(); b++) { Point bp = * (Point)bendPoints.getPoint(b); currVertex = new Vertex(bp, null); child = * new Path(prevVertex, currVertex); childPaths.add(child); * workingPaths.add(child); prevVertex = currVertex; } * * child = new Path(prevVertex, path.end); childPaths.add(child); * workingPaths.add(child); pathsToChildPaths.put(path, childPaths); } else * workingPaths.add(path); } //End FOR } */ /** * Returns the closest vertex to the given segment. * * @param v1 * the first vertex * @param v2 * the second vertex * @param segment * the segment * @return v1, or v2 whichever is closest to the segment */ private Vertex getNearestVertex(Vertex v1, Vertex v2, Segment segment) { if (segment.start.getDistance(v1) + segment.end.getDistance(v1) > segment.start .getDistance(v2) + segment.end.getDistance(v2)) return v2; else return v1; } /** * Returns the spacing maintained between paths. * * @return the default path spacing * @see #setSpacing(int) * @since 3.2 */ public int getSpacing() { return spacing; } /** * Returns the subpath for a split on the given path at the given segment. * * @param path * the path * @param segment * the segment * @return the new subpath */ private Path getSubpathForSplit(Path path, Segment segment) { Path newPath = path.getSubPath(segment); workingPaths.add(newPath); subPaths.add(newPath); return newPath; } /** * Grows all obstacles in in routing and tests for new intersections */ private void growObstacles() { growPassChangedObstacles = false; for (int i = 0; i < NUM_GROW_PASSES; i++) { if (i == 0 || growPassChangedObstacles) growObstaclesPass(); } } /** * Performs a single pass of the grow obstacles step, this can be repeated * as desired. Grows obstacles, then tests paths against the grown * obstacles. */ private void growObstaclesPass() { // grow obstacles for (int i = 0; i < userObstacles.size(); i++) ((Obstacle) userObstacles.get(i)).growVertices(); // go through paths and test segments for (int i = 0; i < workingPaths.size(); i++) { Path path = (Path) workingPaths.get(i); for (int e = 0; e < path.excludedObstacles.size(); e++) ((Obstacle) path.excludedObstacles.get(e)).exclude = true; if (path.grownSegments.size() == 0) { for (int s = 0; s < path.segments.size(); s++) testOffsetSegmentForIntersections( (Segment) path.segments.get(s), -1, path); } else { int counter = 0; List currentSegments = new ArrayList(path.grownSegments); for (int s = 0; s < currentSegments.size(); s++) counter += testOffsetSegmentForIntersections( (Segment) currentSegments.get(s), s + counter, path); } for (int e = 0; e < path.excludedObstacles.size(); e++) ((Obstacle) path.excludedObstacles.get(e)).exclude = false; } // revert obstacles for (int i = 0; i < userObstacles.size(); i++) ((Obstacle) userObstacles.get(i)).shrinkVertices(); } /** * Adds an obstacle to the routing * * @param obs * the obstacle */ private boolean internalAddObstacle(Obstacle obs) { userObstacles.add(obs); return testAndDirtyPaths(obs); } /** * Removes an obstacle from the routing. * * @param rect * the bounds of the obstacle * @return the obstacle removed */ private boolean internalRemoveObstacle(Rectangle rect) { Obstacle obs = null; int index = -1; for (int i = 0; i < userObstacles.size(); i++) { obs = (Obstacle) userObstacles.get(i); if (obs.equals(rect)) { index = i; break; } } userObstacles.remove(index); boolean result = false; result |= dirtyPathsOn(obs.bottomLeft); result |= dirtyPathsOn(obs.topLeft); result |= dirtyPathsOn(obs.bottomRight); result |= dirtyPathsOn(obs.topRight); for (int p = 0; p < workingPaths.size(); p++) { Path path = (Path) workingPaths.get(p); if (path.isDirty) continue; if (path.isObstacleVisible(obs)) path.isDirty = result = true; } return result; } /** * Labels the given path's vertices as innies, or outies, as well as * determining if this path is inverted. * * @param path * the path */ private void labelPath(Path path) { Segment segment = null; Segment nextSegment = null; Vertex vertex = null; boolean agree = false; for (int v = 0; v < path.grownSegments.size() - 1; v++) { segment = (Segment) path.grownSegments.get(v); nextSegment = (Segment) path.grownSegments.get(v + 1); vertex = segment.end; long crossProduct = segment.crossProduct(new Segment(vertex, vertex.obs.center)); if (vertex.type == Vertex.NOT_SET) { labelVertex(segment, crossProduct, path); } else if (!path.isInverted && ((crossProduct > 0 && vertex.type == Vertex.OUTIE) || (crossProduct < 0 && vertex.type == Vertex.INNIE))) { if (agree) { // split detected. stack.push(getSubpathForSplit(path, segment)); return; } else { path.isInverted = true; path.invertPriorVertices(segment); } } else if (path.isInverted && ((crossProduct < 0 && vertex.type == Vertex.OUTIE) || (crossProduct > 0 && vertex.type == Vertex.INNIE))) { // split detected. stack.push(getSubpathForSplit(path, segment)); return; } else agree = true; if (vertex.paths != null) { for (int i = 0; i < vertex.paths.size(); i++) { Path nextPath = (Path) vertex.paths.get(i); if (!nextPath.isMarked) { nextPath.isMarked = true; stack.push(nextPath); } } } vertex.addPath(path, segment, nextSegment); } } /** * Labels all path's vertices in the routing. */ private void labelPaths() { Path path = null; for (int i = 0; i < workingPaths.size(); i++) { path = (Path) workingPaths.get(i); stack.push(path); } while (!stack.isEmpty()) { path = stack.pop(); if (!path.isMarked) { path.isMarked = true; labelPath(path); } } // revert is marked so we can use it again in ordering. for (int i = 0; i < workingPaths.size(); i++) { path = (Path) workingPaths.get(i); path.isMarked = false; } } /** * Labels the vertex at the end of the semgent based on the cross product. * * @param segment * the segment to this vertex * @param crossProduct * the cross product of this segment and a segment to the * obstacles center * @param path * the path */ private void labelVertex(Segment segment, long crossProduct, Path path) { // assumes vertex in question is segment.end if (crossProduct > 0) { if (path.isInverted) segment.end.type = Vertex.OUTIE; else segment.end.type = Vertex.INNIE; } else if (crossProduct < 0) { if (path.isInverted) segment.end.type = Vertex.INNIE; else segment.end.type = Vertex.OUTIE; } else if (segment.start.type != Vertex.NOT_SET) segment.end.type = segment.start.type; else segment.end.type = Vertex.INNIE; } /** * Orders the path by comparing its angle at shared vertices with other * paths. * * @param path * the path */ private void orderPath(Path path) { if (path.isMarked) return; path.isMarked = true; Segment segment = null; Vertex vertex = null; for (int v = 0; v < path.grownSegments.size() - 1; v++) { segment = (Segment) path.grownSegments.get(v); vertex = segment.end; double thisAngle = ((Double) vertex.cachedCosines.get(path)) .doubleValue(); if (path.isInverted) thisAngle = -thisAngle; for (int i = 0; i < vertex.paths.size(); i++) { Path vPath = (Path) vertex.paths.get(i); if (!vPath.isMarked) { double otherAngle = ((Double) vertex.cachedCosines .get(vPath)).doubleValue(); if (vPath.isInverted) otherAngle = -otherAngle; if (otherAngle < thisAngle) orderPath(vPath); } } } orderedPaths.add(path); } /** * Orders all paths in the graph. */ private void orderPaths() { for (int i = 0; i < workingPaths.size(); i++) { Path path = (Path) workingPaths.get(i); orderPath(path); } } /** * Populates the parent paths with all the child paths that were created to * represent bendpoints. */ private void recombineChildrenPaths() { // only populate those paths with children paths. Iterator keyItr = pathsToChildPaths.keySet().iterator(); while (keyItr.hasNext()) { Path path = (Path) keyItr.next(); path.fullReset(); List childPaths = (List) pathsToChildPaths.get(path); Path childPath = null; for (int i = 0; i < childPaths.size(); i++) { childPath = (Path) childPaths.get(i); path.points.addAll(childPath.getPoints()); // path will overlap path.points.removePoint(path.points.size() - 1); // path.grownSegments.addAll(childPath.grownSegments); path.segments.addAll(childPath.segments); path.visibleObstacles.addAll(childPath.visibleObstacles); } // add last point. path.points.addPoint(childPath.points.getLastPoint()); } } /** * Reconnects all subpaths. */ private void recombineSubpaths() { for (int p = 0; p < orderedPaths.size(); p++) { Path path = (Path) orderedPaths.get(p); path.reconnectSubPaths(); } orderedPaths.removeAll(subPaths); workingPaths.removeAll(subPaths); subPaths = null; } /** * Removes the obstacle with the rectangle's bounds from the routing. * * @param rect * the bounds of the obstacle to remove * @return true if the removal has dirtied one or more paths */ public boolean removeObstacle(Rectangle rect) { return internalRemoveObstacle(rect); } /** * Removes the given path from the routing. * * @param path * the path to remove. * @return true if the removal may have affected one of the * remaining paths */ public boolean removePath(Path path) { userPaths.remove(path); List children = (List) pathsToChildPaths.get(path); if (children == null) workingPaths.remove(path); else workingPaths.removeAll(children); return true; } /** * Resets exclude field on all obstacles */ private void resetObstacleExclusions() { for (int i = 0; i < userObstacles.size(); i++) ((Obstacle) userObstacles.get(i)).exclude = false; } /** * Resets all vertices found on paths and obstacles. */ private void resetVertices() { for (int i = 0; i < userObstacles.size(); i++) { Obstacle obs = (Obstacle) userObstacles.get(i); obs.reset(); } for (int i = 0; i < workingPaths.size(); i++) { Path path = (Path) workingPaths.get(i); path.start.fullReset(); path.end.fullReset(); } } /** * Sets the default spacing between paths. The spacing is the minimum * distance that path should be offset from other paths or obstacles. The * default value is 4. When this value can not be satisfied, paths will be * squeezed together uniformly. * * @param spacing * the path spacing * @since 3.2 */ public void setSpacing(int spacing) { this.spacing = spacing; } /** * Updates the points in the paths in order to represent the current * solution with the given paths and obstacles. * * @return returns the list of paths which were updated. */ public List solve() { solveDirtyPaths(); countVertices(); checkVertexIntersections(); growObstacles(); subPaths = new ArrayList(); stack = new PathStack(); labelPaths(); stack = null; orderedPaths = new ArrayList(); orderPaths(); bendPaths(); recombineSubpaths(); orderedPaths = null; subPaths = null; recombineChildrenPaths(); cleanup(); return Collections.unmodifiableList(userPaths); } /** * Solves paths that are dirty. * * @return number of dirty paths */ private int solveDirtyPaths() { int numSolved = 0; for (int i = 0; i < userPaths.size(); i++) { Path path = (Path) userPaths.get(i); if (!path.isDirty) continue; List children = (List) pathsToChildPaths.get(path); int prevCount = 1, newCount = 1; if (children == null) children = Collections.EMPTY_LIST; else prevCount = children.size(); if (path.getBendPoints() != null) newCount = path.getBendPoints().size() + 1; if (prevCount != newCount) children = regenerateChildPaths(path, children, prevCount, newCount); refreshChildrenEndpoints(path, children); } for (int i = 0; i < workingPaths.size(); i++) { Path path = (Path) workingPaths.get(i); path.refreshExcludedObstacles(userObstacles); if (!path.isDirty) { path.resetPartial(); continue; } numSolved++; path.fullReset(); boolean pathFoundCheck = path.generateShortestPath(userObstacles); if (!pathFoundCheck || path.end.cost > path.threshold) { // path not found, or path found was too long resetVertices(); path.fullReset(); path.threshold = 0; pathFoundCheck = path.generateShortestPath(userObstacles); } resetVertices(); } resetObstacleExclusions(); if (numSolved == 0) resetVertices(); return numSolved; } /** * @since 3.0 * @param path * @param children */ private void refreshChildrenEndpoints(Path path, List children) { Point previous = path.getStartPoint(); Point next; PointList bendpoints = path.getBendPoints(); Path child; for (int i = 0; i < children.size(); i++) { if (i < bendpoints.size()) next = bendpoints.getPoint(i); else next = path.getEndPoint(); child = (Path) children.get(i); child.setStartPoint(previous); child.setEndPoint(next); previous = next; } } /** * @since 3.0 * @param path * @param children */ private List regenerateChildPaths(Path path, List children, int currentSize, int newSize) { // Path used to be simple but now is compound, children is EMPTY. if (currentSize == 1) { workingPaths.remove(path); currentSize = 0; children = new ArrayList(newSize); pathsToChildPaths.put(path, children); } else // Path is becoming simple but was compound. children becomes empty. if (newSize == 1) { workingPaths.removeAll(children); workingPaths.add(path); pathsToChildPaths.remove(path); return Collections.EMPTY_LIST; } // Add new working paths until the sizes are the same while (currentSize < newSize) { Path child = new Path(); workingPaths.add(child); children.add(child); currentSize++; } while (currentSize > newSize) { Path child = (Path) children.remove(children.size() - 1); workingPaths.remove(child); currentSize--; } return children; } /** * Tests a segment that has been offset for new intersections * * @param segment * the segment * @param index * the index of the segment along the path * @param path * the path * @return 1 if new segments have been inserted */ private int testOffsetSegmentForIntersections(Segment segment, int index, Path path) { for (int i = 0; i < userObstacles.size(); i++) { Obstacle obs = (Obstacle) userObstacles.get(i); if (segment.end.obs == obs || segment.start.obs == obs || obs.exclude) continue; Vertex vertex = null; int offset = getSpacing(); if (segment.getSlope() < 0) { if (segment.intersects(obs.topLeft.x - offset, obs.topLeft.y - offset, obs.bottomRight.x + offset, obs.bottomRight.y + offset)) vertex = getNearestVertex(obs.topLeft, obs.bottomRight, segment); else if (segment.intersects(obs.bottomLeft.x - offset, obs.bottomLeft.y + offset, obs.topRight.x + offset, obs.topRight.y - offset)) vertex = getNearestVertex(obs.bottomLeft, obs.topRight, segment); } else { if (segment.intersects(obs.bottomLeft.x - offset, obs.bottomLeft.y + offset, obs.topRight.x + offset, obs.topRight.y - offset)) vertex = getNearestVertex(obs.bottomLeft, obs.topRight, segment); else if (segment.intersects(obs.topLeft.x - offset, obs.topLeft.y - offset, obs.bottomRight.x + offset, obs.bottomRight.y + offset)) vertex = getNearestVertex(obs.topLeft, obs.bottomRight, segment); } if (vertex != null) { Rectangle vRect = vertex.getDeformedRectangle(offset); if (segment.end.obs != null) { Rectangle endRect = segment.end .getDeformedRectangle(offset); if (vRect.intersects(endRect)) continue; } if (segment.start.obs != null) { Rectangle startRect = segment.start .getDeformedRectangle(offset); if (vRect.intersects(startRect)) continue; } Segment newSegmentStart = new Segment(segment.start, vertex); Segment newSegmentEnd = new Segment(vertex, segment.end); vertex.totalCount++; vertex.nearestObstacleChecked = false; vertex.shrink(); checkVertexForIntersections(vertex); vertex.grow(); if (vertex.nearestObstacle != 0) vertex.updateOffset(); growPassChangedObstacles = true; if (index != -1) { path.grownSegments.remove(segment); path.grownSegments.add(index, newSegmentStart); path.grownSegments.add(index + 1, newSegmentEnd); } else { path.grownSegments.add(newSegmentStart); path.grownSegments.add(newSegmentEnd); } return 1; } } if (index == -1) path.grownSegments.add(segment); return 0; } /** * Tests all paths against the given obstacle * * @param obs * the obstacle */ private boolean testAndDirtyPaths(Obstacle obs) { boolean result = false; for (int i = 0; i < workingPaths.size(); i++) { Path path = (Path) workingPaths.get(i); result |= path.testAndSet(obs); } return result; } /** * Updates the position of an existing obstacle. * * @param oldBounds * the old bounds(used to find the obstacle) * @param newBounds * the new bounds * @return true if the change the current results to become * stale */ public boolean updateObstacle(Rectangle oldBounds, Rectangle newBounds) { boolean result = internalRemoveObstacle(oldBounds); result |= addObstacle(newBounds); return result; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/SortSubgraphs.java000066400000000000000000000144121166301720600302440ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; /** * Performs a topological sort from left to right of the subgraphs in a compound * directed graph. This ensures that subgraphs do not intertwine. * * @author Randy Hudson * @since 2.1.2 */ class SortSubgraphs extends GraphVisitor { CompoundDirectedGraph g; NestingTree nestingTrees[]; Set orderingGraphEdges = new HashSet(); Set orderingGraphNodes = new HashSet(); NodePair pair = new NodePair(); private void breakSubgraphCycles() { // The stack of nodes which have no unmarked incoming edges List noLefts = new ArrayList(); int index = 1; // Identify all initial nodes for removal for (Iterator iter = orderingGraphNodes.iterator(); iter.hasNext();) { Node node = (Node) iter.next(); if (node.x == 0) sortedInsert(noLefts, node); } Node cycleRoot; do { // Remove all leftmost nodes, updating the nodes to their right while (noLefts.size() > 0) { Node node = (Node) noLefts.remove(noLefts.size() - 1); node.sortValue = index++; orderingGraphNodes.remove(node); // System.out.println("removed:" + node); NodeList rightOf = rightOf(node); if (rightOf == null) continue; for (int i = 0; i < rightOf.size(); i++) { Node right = rightOf.getNode(i); right.x--; if (right.x == 0) sortedInsert(noLefts, right); } } cycleRoot = null; double min = Double.MAX_VALUE; for (Iterator iter = orderingGraphNodes.iterator(); iter.hasNext();) { Node node = (Node) iter.next(); if (node.sortValue < min) { cycleRoot = node; min = node.sortValue; } } if (cycleRoot != null) { // break the cycle; sortedInsert(noLefts, cycleRoot); // System.out.println("breaking cycle with:" + cycleRoot); // Display.getCurrent().beep(); cycleRoot.x = -1; // prevent x from ever reaching 0 } // else if (OGmembers.size() > 0) //System.out.println("FAILED TO FIND CYCLE ROOT"); //$NON-NLS-1$ } while (cycleRoot != null); } private void buildSubgraphOrderingGraph() { RankList ranks = g.ranks; nestingTrees = new NestingTree[ranks.size()]; for (int r = 0; r < ranks.size(); r++) { NestingTree entry = NestingTree.buildNestingTreeForRank(ranks .getRank(r)); nestingTrees[r] = entry; entry.calculateSortValues(); entry.recursiveSort(false); } for (int i = 0; i < nestingTrees.length; i++) { NestingTree entry = nestingTrees[i]; buildSubgraphOrderingGraph(entry); } } private void buildSubgraphOrderingGraph(NestingTree entry) { NodePair pair = new NodePair(); if (entry.isLeaf) return; for (int i = 0; i < entry.contents.size(); i++) { Object right = entry.contents.get(i); if (right instanceof Node) pair.n2 = (Node) right; else { pair.n2 = ((NestingTree) right).subgraph; buildSubgraphOrderingGraph((NestingTree) right); } if (pair.n1 != null && !orderingGraphEdges.contains(pair)) { orderingGraphEdges.add(pair); leftToRight(pair.n1, pair.n2); orderingGraphNodes.add(pair.n1); orderingGraphNodes.add(pair.n2); pair.n2.x++; // Using x field to count predecessors. pair = new NodePair(pair.n2, null); } else { pair.n1 = pair.n2; } } } /** * Calculates the average position P for each node and subgraph. The average * position is stored in the sortValue for each node or subgraph. * * Runs in approximately linear time with respect to the number of nodes, * including virtual nodes. */ private void calculateSortValues() { RankList ranks = g.ranks; g.subgraphs.resetSortValues(); g.subgraphs.resetIndices(); /* * For subgraphs, the sum of all positions is kept, along with the * number of contributions, which is tracked in the subgraph's index * field. */ for (int r = 0; r < ranks.size(); r++) { Rank rank = ranks.getRank(r); for (int j = 0; j < rank.count(); j++) { Node node = rank.getNode(j); node.sortValue = node.index; Subgraph parent = node.getParent(); while (parent != null) { parent.sortValue += node.sortValue; parent.index++; parent = parent.getParent(); } } } /* * For each subgraph, divide the sum of the positions by the number of * contributions, to give the average position. */ for (int i = 0; i < g.subgraphs.size(); i++) { Subgraph subgraph = (Subgraph) g.subgraphs.get(i); subgraph.sortValue /= subgraph.index; } } private void repopulateRanks() { for (int i = 0; i < nestingTrees.length; i++) { Rank rank = g.ranks.getRank(i); rank.clear(); nestingTrees[i].repopulateRank(rank); } } private NodeList rightOf(Node left) { return (NodeList) left.workingData[0]; } private void leftToRight(Node left, Node right) { rightOf(left).add(right); } void sortedInsert(List list, Node node) { int insert = 0; while (insert < list.size() && ((Node) list.get(insert)).sortValue > node.sortValue) insert++; list.add(insert, node); } private void topologicalSort() { for (int i = 0; i < nestingTrees.length; i++) { nestingTrees[i].getSortValueFromSubgraph(); nestingTrees[i].recursiveSort(false); } } void init() { for (int r = 0; r < g.ranks.size(); r++) { Rank rank = g.ranks.getRank(r); for (int i = 0; i < rank.count(); i++) { Node n = (Node) rank.get(i); n.workingData[0] = new NodeList(); } } for (int i = 0; i < g.subgraphs.size(); i++) { Subgraph s = (Subgraph) g.subgraphs.get(i); s.workingData[0] = new NodeList(); } } public void visit(DirectedGraph dg) { g = (CompoundDirectedGraph) dg; init(); buildSubgraphOrderingGraph(); calculateSortValues(); breakSubgraphCycles(); topologicalSort(); repopulateRanks(); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/SpanningTreeVisitor.java000066400000000000000000000026311166301720600314130ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; /** * A base class for visitors which operate on the graphs spanning tree used to * induce rank assignments. * * @author Randy Hudson * @since 2.1.2 */ abstract class SpanningTreeVisitor extends GraphVisitor { Edge getParentEdge(Node node) { return (Edge) node.workingData[1]; } EdgeList getSpanningTreeChildren(Node node) { return (EdgeList) node.workingData[0]; } protected Node getTreeHead(Edge edge) { if (getParentEdge(edge.source) == edge) return edge.target; return edge.source; } Node getTreeParent(Node node) { Edge e = getParentEdge(node); if (e == null) return null; return e.opposite(node); } protected Node getTreeTail(Edge edge) { if (getParentEdge(edge.source) == edge) return edge.source; return edge.target; } void setParentEdge(Node node, Edge edge) { node.workingData[1] = edge; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/Subgraph.java000066400000000000000000000063111166301720600272100ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import org.eclipse.draw2d.geometry.Insets; /** * A Node which may contain other nodes. A Subgraph is a compound or container * node. It may have incoming and outgoing edges just like a node. Subgraphs are * used in {@link CompoundDirectedGraph}s. A proper layout of a compound graph * ensures that all of a subgraph's children are placed inside its rectangular * region. Nodes which do not belong to the subgraph must be placed outside that * region. *

    * A Subgraph may contain another Subgraph. *

    * A Subgraph has additional geometric properties which describe the containing * box. They are: *

      *
    • {@link #insets} - the size of the subgraph's border. A subgraph is * typically rendered as a thin rectangular box. Sometimes this box is labeled * or decorated. The insets can be used to reserve space for this purpose. *
    • {@link #innerPadding} - the amount of empty space that must be preserved * just inside the subgraph's border. This is the minimum space between the * border, and the children node's contained inside the subgraph. *
    * * @author hudsonr * @since 2.1.2 */ public class Subgraph extends Node { /** * The children of this subgraph. Nodes may not belong to more than one * subgraph. */ public NodeList members = new NodeList(); Node head; Node tail; Node left; Node right; int nestingTreeMin; /** * The space required for this subgraph's border. The default value is * undefined. */ public Insets insets = new Insets(1); /** * The minimum space between this subgraph's border and it's children. */ public Insets innerPadding = NO_INSETS; private static final Insets NO_INSETS = new Insets(); /** * Constructs a new subgraph with the given data object. * * @see Node#Node(Object) * @param data * an arbitrary data object */ public Subgraph(Object data) { this(data, null); } /** * Constructs a new subgraph with the given data object and parent subgraph. * * @see Node#Node(Object, Subgraph) * @param data * an arbitrary data object * @param parent * the parent */ public Subgraph(Object data, Subgraph parent) { super(data, parent); } /** * Adds the given node to this subgraph. * * @param n * the node to add */ public void addMember(Node n) { members.add(n); } /** * Returns true if the given node is contained inside the * branch represented by this subgraph. * * @param n * the node in question * @return true if nested */ boolean isNested(Node n) { return n.nestingIndex >= nestingTreeMin && n.nestingIndex <= nestingIndex; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/SubgraphBoundary.java000066400000000000000000000046071166301720600307220ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import org.eclipse.draw2d.geometry.Insets; /** * For INTERNAL use only. * * @author hudsonr * @since 2.1.2 */ class SubgraphBoundary extends Node { /** * constant indicating TOP. */ public static final int TOP = 0; /** * constant indicating LEFT. */ public static final int LEFT = 1; /** * constant indicating BOTTOM. */ public static final int BOTTOM = 2; /** * constant indicating RIGHT. */ public static final int RIGHT = 3; /** * Constructs a new boundary. * * @param s * the subgraph * @param p * the padding * @param side * which side */ public SubgraphBoundary(Subgraph s, Insets p, int side) { super(null, s); this.width = s.width; this.height = s.height; this.padding = new Insets(); switch (side) { case LEFT: width = s.insets.left; y = s.y; padding.left = p.left; padding.right = s.innerPadding.left; padding.top = padding.bottom = 0; setParent(s.getParent()); data = "left(" + s + ")"; //$NON-NLS-1$ //$NON-NLS-2$ break; case RIGHT: width = s.insets.right; y = s.y; padding.right = p.right; padding.left = s.innerPadding.right; padding.top = padding.bottom = 0; setParent(s.getParent()); data = "right(" + s + ")"; //$NON-NLS-1$ //$NON-NLS-2$ break; case TOP: height = s.insets.top; // $TODO width of head/tail should be 0 width = 5; padding.top = p.top; padding.bottom = s.innerPadding.top; padding.left = padding.right = 0; data = "top(" + s + ")"; //$NON-NLS-1$ //$NON-NLS-2$ break; case BOTTOM: height = s.insets.bottom; // $TODO width of head/tail should be 0 width = 5; padding.top = s.innerPadding.bottom; padding.bottom = p.bottom; padding.left = padding.right = 0; data = "bottom(" + s + ")"; //$NON-NLS-1$ //$NON-NLS-2$ break; } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/TightSpanningTreeSolver.java000066400000000000000000000074461166301720600322370ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; /** * Finds a tight spanning tree from the graphs edges which induce a valid rank * assignment. This process requires that the nodes be initially given a * feasible ranking. * * @author Randy Hudson * @since 2.1.2 */ class TightSpanningTreeSolver extends SpanningTreeVisitor { protected DirectedGraph graph; protected CandidateList candidates = new CandidateList(); static final class CandidateList { private Edge edges[] = new Edge[10]; private int size; public void add(Edge edge) { if (size == edges.length - 1) { Edge newEdges[] = new Edge[edges.length * 2]; System.arraycopy(edges, 0, newEdges, 0, edges.length); edges = newEdges; } edges[size++] = edge; } public Edge getEdge(int index) { return edges[index]; } public void remove(Edge edge) { for (int i = 0; i < size; i++) { if (edges[i] == edge) { edges[i] = edges[size - 1]; size--; return; } } throw new RuntimeException("Remove called on invalid Edge"); //$NON-NLS-1$ } public int size() { return size; } } protected NodeList members = new NodeList(); public void visit(DirectedGraph graph) { this.graph = graph; init(); solve(); } Node addEdge(Edge edge) { int delta = edge.getSlack(); edge.tree = true; Node node; if (edge.target.flag) { delta = -delta; node = edge.source; setParentEdge(node, edge); getSpanningTreeChildren(edge.target).add(edge); } else { node = edge.target; setParentEdge(node, edge); getSpanningTreeChildren(edge.source).add(edge); } members.adjustRank(delta); addNode(node); return node; } private boolean isNodeReachable(Node node) { return node.flag; } private void setNodeReachable(Node node) { node.flag = true; } private boolean isCandidate(Edge e) { return e.flag; } private void setCandidate(Edge e) { e.flag = true; } void addNode(Node node) { setNodeReachable(node); EdgeList list = node.incoming; Edge e; for (int i = 0; i < list.size(); i++) { e = list.getEdge(i); if (!isNodeReachable(e.source)) { if (!isCandidate(e)) { setCandidate(e); candidates.add(e); } } else candidates.remove(e); } list = node.outgoing; for (int i = 0; i < list.size(); i++) { e = list.getEdge(i); if (!isNodeReachable(e.target)) { if (!isCandidate(e)) { setCandidate(e); candidates.add(e); } } else candidates.remove(e); } members.add(node); } void init() { graph.edges.resetFlags(true); graph.nodes.resetFlags(); for (int i = 0; i < graph.nodes.size(); i++) { Node node = (Node) graph.nodes.get(i); node.workingData[0] = new EdgeList(); } } protected void solve() { Node root = graph.nodes.getNode(0); setParentEdge(root, null); addNode(root); while (members.size() < graph.nodes.size()) { if (candidates.size() == 0) throw new RuntimeException("graph is not fully connected");//$NON-NLS-1$ int minSlack = Integer.MAX_VALUE, slack; Edge minEdge = null, edge; for (int i = 0; i < candidates.size() && minSlack > 0; i++) { edge = candidates.getEdge(i); slack = edge.getSlack(); if (slack < minSlack) { minSlack = slack; minEdge = edge; } } addEdge(minEdge); } graph.nodes.normalizeRanks(); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/TransposeMetrics.java000066400000000000000000000041721166301720600307450ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2005, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import java.util.List; import org.eclipse.draw2d.PositionConstants; import org.eclipse.draw2d.geometry.Transposer; class TransposeMetrics extends GraphVisitor { Transposer t = new Transposer(); public void visit(DirectedGraph g) { if (g.getDirection() == PositionConstants.SOUTH) return; t.setEnabled(true); int temp; g.setDefaultPadding(t.t(g.getDefaultPadding())); for (int i = 0; i < g.nodes.size(); i++) { Node node = g.nodes.getNode(i); temp = node.width; node.width = node.height; node.height = temp; if (node.getPadding() != null) node.setPadding(t.t(node.getPadding())); } } public void revisit(DirectedGraph g) { if (g.getDirection() == PositionConstants.SOUTH) return; int temp; g.setDefaultPadding(t.t(g.getDefaultPadding())); for (int i = 0; i < g.nodes.size(); i++) { Node node = (Node) g.nodes.get(i); temp = node.width; node.width = node.height; node.height = temp; temp = node.y; node.y = node.x; node.x = temp; if (node.getPadding() != null) node.setPadding(t.t(node.getPadding())); } for (int i = 0; i < g.edges.size(); i++) { Edge edge = g.edges.getEdge(i); edge.start.transpose(); edge.end.transpose(); edge.getPoints().transpose(); List bends = edge.vNodes; if (bends == null) continue; for (int b = 0; b < bends.size(); b++) { VirtualNode vnode = (VirtualNode) bends.get(b); temp = vnode.y; vnode.y = vnode.x; vnode.x = temp; temp = vnode.width; vnode.width = vnode.height; vnode.height = temp; } } g.size.transpose(); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/Vertex.java000066400000000000000000000124601166301720600267140ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.eclipse.draw2d.PositionConstants; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; /** * A vertex representation for the ShortestPathRouting. Vertices are either one * of four corners on an Obstacle(Rectangle), or one of the two end * points of a Path. * * This class is not intended to be subclassed. * * @author Whitney Sorenson * @since 3.0 */ class Vertex extends Point { // constants for the vertex type static final int NOT_SET = 0; static final int INNIE = 1; static final int OUTIE = 2; // for shortest path List neighbors; boolean isPermanent = false; Vertex label; double cost = 0; // for routing int nearestObstacle = 0; double offset = 0; int type = NOT_SET; int count = 0; int totalCount = 0; Obstacle obs; List paths; boolean nearestObstacleChecked = false; Map cachedCosines; int positionOnObstacle = -1; private int origX, origY; /** * Creates a new Vertex with the given x, y position and on the given * obstacle. * * @param x * x point * @param y * y point * @param obs * obstacle - can be null */ Vertex(int x, int y, Obstacle obs) { super(x, y); origX = x; origY = y; this.obs = obs; } /** * Creates a new Vertex with the given point position and on the given * obstacle. * * @param p * the point * @param obs * obstacle - can be null */ Vertex(Point p, Obstacle obs) { this(p.x, p.y, obs); } /** * Adds a path to this vertex, calculates angle between two segments and * caches it. * * @param path * the path * @param start * the segment to this vertex * @param end * the segment away from this vertex */ void addPath(Path path, Segment start, Segment end) { if (paths == null) { paths = new ArrayList(); cachedCosines = new HashMap(); } if (!paths.contains(path)) paths.add(path); cachedCosines.put(path, new Double(start.cosine(end))); } /** * Creates a point that represents this vertex offset by the given amount * times the offset. * * @param modifier * the offset * @return a Point that has been bent around this vertex */ Point bend(int modifier) { Point point = new Point(x, y); if ((positionOnObstacle & PositionConstants.NORTH) > 0) point.y -= modifier * offset; else point.y += modifier * offset; if ((positionOnObstacle & PositionConstants.EAST) > 0) point.x += modifier * offset; else point.x -= modifier * offset; return point; } /** * Resets all fields on this Vertex. */ void fullReset() { totalCount = 0; type = NOT_SET; count = 0; cost = 0; offset = getSpacing(); nearestObstacle = 0; label = null; nearestObstacleChecked = false; isPermanent = false; if (neighbors != null) neighbors.clear(); if (cachedCosines != null) cachedCosines.clear(); if (paths != null) paths.clear(); } /** * Returns a Rectangle that represents the region around this vertex that * paths will be traveling in. * * @param extraOffset * a buffer to add to the region. * @return the rectangle */ Rectangle getDeformedRectangle(int extraOffset) { Rectangle rect = new Rectangle(0, 0, 0, 0); if ((positionOnObstacle & PositionConstants.NORTH) > 0) { rect.y = y - extraOffset; rect.height = origY - y + extraOffset; } else { rect.y = origY; rect.height = y - origY + extraOffset; } if ((positionOnObstacle & PositionConstants.EAST) > 0) { rect.x = origX; rect.width = x - origX + extraOffset; } else { rect.x = x - extraOffset; rect.width = origX - x + extraOffset; } return rect; } private int getSpacing() { if (obs == null) return 0; return obs.getSpacing(); } /** * Grows this vertex by its offset to its maximum size. */ void grow() { int modifier; if (nearestObstacle == 0) modifier = totalCount * getSpacing(); else modifier = (nearestObstacle / 2) - 1; if ((positionOnObstacle & PositionConstants.NORTH) > 0) y -= modifier; else y += modifier; if ((positionOnObstacle & PositionConstants.EAST) > 0) x += modifier; else x -= modifier; } /** * Shrinks this vertex to its original size. */ void shrink() { x = origX; y = origY; } /** * Updates the offset of this vertex based on its shortest distance. */ void updateOffset() { if (nearestObstacle != 0) offset = ((nearestObstacle / 2) - 1) / totalCount; } /** * @see org.eclipse.draw2d.geometry.Point#toString() */ public String toString() { return "V(" + origX + ", " + origY + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/VerticalPlacement.java000066400000000000000000000031711166301720600310400ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import org.eclipse.draw2d.geometry.Insets; /** * Assigns the Y and Height values to the nodes in the graph. All nodes in the * same row are given the same height. * * @author Randy Hudson * @since 2.1.2 */ class VerticalPlacement extends GraphVisitor { void visit(DirectedGraph g) { Insets pad; int currentY = g.getMargin().top; int row, rowHeight; g.rankLocations = new int[g.ranks.size() + 1]; for (row = 0; row < g.ranks.size(); row++) { g.rankLocations[row] = currentY; Rank rank = g.ranks.getRank(row); rowHeight = 0; rank.topPadding = rank.bottomPadding = 0; for (int n = 0; n < rank.size(); n++) { Node node = rank.getNode(n); pad = g.getPadding(node); rowHeight = Math.max(node.height, rowHeight); rank.topPadding = Math.max(pad.top, rank.topPadding); rank.bottomPadding = Math.max(pad.bottom, rank.bottomPadding); } currentY += rank.topPadding; rank.setDimensions(currentY, rowHeight); currentY += rank.height + rank.bottomPadding; } g.rankLocations[row] = currentY; g.size.height = currentY; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/VirtualNode.java000066400000000000000000000044041166301720600276720ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import org.eclipse.draw2d.geometry.Insets; /** * @deprecated virtual nodes of an edge should be cast to Node. * @author Randy Hudson * @since 2.1.2 */ public class VirtualNode extends Node { /** * The next node. */ public Node next; /** * The previous node. */ public Node prev; /** * Constructs a virtual node. * * @deprecated This class is for internal use only. * @param e * the edge * @param i * the row */ public VirtualNode(Edge e, int i) { super(e); incoming.add(e); outgoing.add(e); width = e.width; height = 0; rank = i; setPadding(new Insets(0, e.padding, 0, e.padding)); } /** * Constructor. * * @param o * object * @param parent * subgraph */ public VirtualNode(Object o, Subgraph parent) { super(o, parent); } /** * Returns the index of {@link #prev}. * * @return median */ public double medianIncoming() { return prev.index; } /** * Returns the index of {@link #next}. * * @return outgoing */ public double medianOutgoing() { return next.index; } /** * For internal use only. Returns the original edge weight multiplied by the * omega value for the this node and the node on the previous rank. * * @return the weighted weight, or omega */ public int omega() { Edge e = (Edge) data; if (e.source.rank + 1 < rank && rank < e.target.rank) return 8 * e.weight; return 2 * e.weight; } /** * @see java.lang.Object#toString() */ public String toString() { if (data instanceof Edge) return "VN[" + (((Edge) data).vNodes.indexOf(this) + 1) //$NON-NLS-1$ + "](" + data + ")"; //$NON-NLS-1$ //$NON-NLS-2$ return super.toString(); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/VirtualNodeCreation.java000066400000000000000000000056641166301720600313700ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.graph; import org.eclipse.draw2d.geometry.Insets; /** * Encapsulates the conversion of a long edge to multiple short edges and back. * * @since 3.1 */ class VirtualNodeCreation extends RevertableChange { private final Edge edge; private final DirectedGraph graph; private Node nodes[]; private Edge[] edges; private static final int INNER_EDGE_X = 2; private static final int LONG_EDGE_X = 8; /** * Breaks a single edge into multiple edges containing virtual nodes. * * @since 3.1 * @param edge * The edge to convert * @param graph * the graph containing the edge */ public VirtualNodeCreation(Edge edge, DirectedGraph graph) { this.edge = edge; this.graph = graph; int size = edge.target.rank - edge.source.rank - 1; int offset = edge.source.rank + 1; Node prevNode = edge.source; Node currentNode; Edge currentEdge; nodes = new Node[size]; edges = new Edge[size + 1]; Insets padding = new Insets(0, edge.padding, 0, edge.padding); Subgraph s = GraphUtilities.getCommonAncestor(edge.source, edge.target); for (int i = 0; i < size; i++) { nodes[i] = currentNode = new VirtualNode( "Virtual" + i + ':' + edge, s); //$NON-NLS-1$ currentNode.width = edge.width; if (s != null) { currentNode.nestingIndex = s.nestingIndex; } currentNode.height = 0; currentNode.setPadding(padding); currentNode.rank = offset + i; graph.ranks.getRank(offset + i).add(currentNode); currentEdge = new Edge(prevNode, currentNode, 1, edge.weight * LONG_EDGE_X); if (i == 0) { currentEdge.weight = edge.weight * INNER_EDGE_X; currentEdge.offsetSource = edge.offsetSource; } graph.edges.add(edges[i] = currentEdge); graph.nodes.add(currentNode); prevNode = currentNode; } currentEdge = new Edge(prevNode, edge.target, 1, edge.weight * INNER_EDGE_X); currentEdge.offsetTarget = edge.offsetTarget; graph.edges.add(edges[edges.length - 1] = currentEdge); graph.removeEdge(edge); } void revert() { edge.start = edges[0].start; edge.end = edges[edges.length - 1].end; edge.vNodes = new NodeList(); for (int i = 0; i < edges.length; i++) { graph.removeEdge(edges[i]); } for (int i = 0; i < nodes.length; i++) { edge.vNodes.add(nodes[i]); graph.removeNode(nodes[i]); } edge.source.outgoing.add(edge); edge.target.incoming.add(edge); graph.edges.add(edge); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/graph/package.html000066400000000000000000000002301166301720600270450ustar00rootroot00000000000000 Stand-alone algorithms related to Graph Drawing. eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/images/000077500000000000000000000000001166301720600247355ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/images/checkboxenabledoff.gif000066400000000000000000000015301166301720600312170ustar00rootroot00000000000000GIF89a BBB, =H`(\PB"J0ċ!^p#G d )cȑ'Mz(^ y1 ;eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/images/checkboxenabledon.gif000066400000000000000000000015521166301720600310650ustar00rootroot00000000000000GIF89a BBB, OH(\p"J0D Tx@F d1FKFiG!Q\Sœa ?Z ;eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/internal/000077500000000000000000000000001166301720600253045ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/internal/MultiValueMap.java000066400000000000000000000044421166301720600307000ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.internal; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; public class MultiValueMap { private HashMap map = new HashMap(); public ArrayList get(Object key) { Object value = map.get(key); if (value == null) return null; if (value instanceof ArrayList) return (ArrayList) value; ArrayList v = new ArrayList(1); v.add(value); return v; } public void put(Object key, Object value) { Object existingValues = map.get(key); if (existingValues == null) { map.put(key, value); return; } if (existingValues instanceof ArrayList) { ArrayList v = (ArrayList) existingValues; if (!v.contains(value)) v.add(value); return; } if (existingValues != value) { ArrayList v = new ArrayList(2); v.add(existingValues); v.add(value); map.put(key, v); } } public int remove(Object key, Object value) { Object existingValues = map.get(key); if (existingValues != null) { if (existingValues instanceof ArrayList) { ArrayList v = (ArrayList) existingValues; int result = v.indexOf(value); if (result == -1) return -1; v.remove(result); if (v.isEmpty()) map.remove(key); return result; } if (map.remove(key) != null) return 0; } return -1; } public Object removeValue(Object value) { Iterator iter = map.values().iterator(); Object current; while (iter.hasNext()) { current = iter.next(); if (value.equals(current)) { iter.remove(); return value; } else if (current instanceof List) { if (((List) current).remove(value)) { if (((List) current).isEmpty()) iter.remove(); return value; } } } return null; } public int size() { return map.size(); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/internal/package.html000066400000000000000000000004331166301720600275650ustar00rootroot00000000000000 This package contains some utilities for use with Draw2d. eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/package.html000066400000000000000000000002611166301720600257500ustar00rootroot00000000000000 Primary package containing general interfaces and implementation classes. eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/parts/000077500000000000000000000000001166301720600246215ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/parts/ScrollableThumbnail.java000066400000000000000000000207371166301720600314230ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.parts; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.graphics.PaletteData; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Display; import org.eclipse.draw2d.ColorConstants; import org.eclipse.draw2d.Figure; import org.eclipse.draw2d.FigureListener; import org.eclipse.draw2d.Graphics; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.KeyEvent; import org.eclipse.draw2d.KeyListener; import org.eclipse.draw2d.MouseEvent; import org.eclipse.draw2d.MouseListener; import org.eclipse.draw2d.MouseMotionListener; import org.eclipse.draw2d.Viewport; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; /** * A scaled image representation of a Figure. If the source Figure is not * completely visible, a SelectorFigure is placed over the thumbnail * representing the viewable area and can be dragged around to scroll the source * figure. */ public final class ScrollableThumbnail extends Thumbnail { private class ClickScrollerAndDragTransferrer extends MouseMotionListener.Stub implements MouseListener { private boolean dragTransfer; public void mouseDoubleClicked(MouseEvent me) { } public void mouseDragged(MouseEvent me) { if (dragTransfer) syncher.mouseDragged(me); } public void mousePressed(MouseEvent me) { if (!(ScrollableThumbnail.this.getClientArea().contains(me .getLocation()))) return; Dimension selectorCenter = selector.getBounds().getSize() .scale(0.5f); Point scrollPoint = me .getLocation() .getTranslated(getLocation().getNegated()) .translate(selectorCenter.negate()) .scale(1.0f / getViewportScaleX(), 1.0f / getViewportScaleY()) .translate(viewport.getHorizontalRangeModel().getMinimum(), viewport.getVerticalRangeModel().getMinimum()); viewport.setViewLocation(scrollPoint); syncher.mousePressed(me); dragTransfer = true; } public void mouseReleased(MouseEvent me) { syncher.mouseReleased(me); dragTransfer = false; } } private class ScrollSynchronizer extends MouseMotionListener.Stub implements MouseListener { private Point startLocation; private Point viewLocation; public void mouseDoubleClicked(MouseEvent me) { } public void mouseDragged(MouseEvent me) { if (startLocation != null) { Dimension d = me.getLocation().getDifference(startLocation); d.scale(1.0f / getViewportScaleX(), 1.0f / getViewportScaleY()); viewport.setViewLocation(viewLocation.getTranslated(d)); me.consume(); } } public void mousePressed(MouseEvent me) { startLocation = me.getLocation(); viewLocation = viewport.getViewLocation(); me.consume(); } public void mouseReleased(MouseEvent me) { } } private class SelectorFigure extends Figure { { Display display = Display.getCurrent(); PaletteData pData = new PaletteData(0xFF, 0xFF00, 0xFF0000); RGB rgb = ColorConstants.menuBackgroundSelected.getRGB(); int fillColor = pData.getPixel(rgb); ImageData iData = new ImageData(1, 1, 24, pData); iData.setPixel(0, 0, fillColor); iData.setAlpha(0, 0, 55); image = new Image(display, iData); } private Rectangle iBounds = new Rectangle(0, 0, 1, 1); private Image image; protected void dispose() { image.dispose(); } public void paintFigure(Graphics g) { Rectangle bounds = getBounds().getCopy(); // Avoid drawing images that are 0 in dimension if (bounds.width < 5 || bounds.height < 5) return; // Don't paint the selector figure if the entire source is visible. Dimension thumbnailSize = new Dimension(getThumbnailImage()); // expand to compensate for rounding errors in calculating bounds Dimension size = getSize().getExpanded(1, 1); if (size.contains(thumbnailSize)) return; bounds.height--; bounds.width--; g.drawImage(image, iBounds, bounds); g.setForegroundColor(ColorConstants.menuBackgroundSelected); g.drawRectangle(bounds); } } private FigureListener figureListener = new FigureListener() { public void figureMoved(IFigure source) { reconfigureSelectorBounds(); } }; private KeyListener keyListener = new KeyListener.Stub() { public void keyPressed(KeyEvent ke) { int moveX = viewport.getClientArea().width / 4; int moveY = viewport.getClientArea().height / 4; if (ke.keycode == SWT.HOME || (isMirrored() ? ke.keycode == SWT.ARROW_RIGHT : ke.keycode == SWT.ARROW_LEFT)) viewport.setViewLocation(viewport.getViewLocation().translate( -moveX, 0)); else if (ke.keycode == SWT.END || (isMirrored() ? ke.keycode == SWT.ARROW_LEFT : ke.keycode == SWT.ARROW_RIGHT)) viewport.setViewLocation(viewport.getViewLocation().translate( moveX, 0)); else if (ke.keycode == SWT.ARROW_UP || ke.keycode == SWT.PAGE_UP) viewport.setViewLocation(viewport.getViewLocation().translate( 0, -moveY)); else if (ke.keycode == SWT.ARROW_DOWN || ke.keycode == SWT.PAGE_DOWN) viewport.setViewLocation(viewport.getViewLocation().translate( 0, moveY)); } }; private PropertyChangeListener propListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { reconfigureSelectorBounds(); } }; private SelectorFigure selector; private ScrollSynchronizer syncher; private Viewport viewport; /** * Creates a new ScrollableThumbnail. */ public ScrollableThumbnail() { super(); initialize(); } /** * Creates a new ScrollableThumbnail that synchs with the given Viewport. * * @param port * The Viewport */ public ScrollableThumbnail(Viewport port) { super(); setViewport(port); initialize(); } /** * @see Thumbnail#deactivate() */ public void deactivate() { viewport.removePropertyChangeListener(Viewport.PROPERTY_VIEW_LOCATION, propListener); viewport.removeFigureListener(figureListener); remove(selector); selector.dispose(); super.deactivate(); } private double getViewportScaleX() { return (double) targetSize.width / viewport.getContents().getBounds().width; } private double getViewportScaleY() { return (double) targetSize.height / viewport.getContents().getBounds().height; } private void initialize() { selector = new SelectorFigure(); selector.addMouseListener(syncher = new ScrollSynchronizer()); selector.addMouseMotionListener(syncher); selector.setFocusTraversable(true); selector.addKeyListener(keyListener); add(selector); ClickScrollerAndDragTransferrer transferrer = new ClickScrollerAndDragTransferrer(); addMouseListener(transferrer); addMouseMotionListener(transferrer); } private void reconfigureSelectorBounds() { Rectangle rect = new Rectangle(); Point offset = viewport.getViewLocation(); offset.x -= viewport.getHorizontalRangeModel().getMinimum(); offset.y -= viewport.getVerticalRangeModel().getMinimum(); rect.setLocation(offset); rect.setSize(viewport.getClientArea().getSize()); rect.scale(getViewportScaleX(), getViewportScaleY()); rect.translate(getClientArea().getLocation()); selector.setBounds(rect); } /** * Reconfigures the SelectorFigure's bounds if the scales have changed. * * @param scaleX * The X scale * @param scaleY * The Y scale * @see org.eclipse.draw2d.parts.Thumbnail#setScales(float, float) */ protected void setScales(float scaleX, float scaleY) { if (scaleX == getScaleX() && scaleY == getScaleY()) return; super.setScales(scaleX, scaleY); reconfigureSelectorBounds(); } /** * Sets the Viewport that this ScrollableThumbnail will synch with. * * @param port * The Viewport */ public void setViewport(Viewport port) { port.addPropertyChangeListener(Viewport.PROPERTY_VIEW_LOCATION, propListener); port.addFigureListener(figureListener); viewport = port; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/parts/Thumbnail.java000066400000000000000000000341361166301720600274160ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.parts; import java.util.Iterator; import java.util.Map; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Display; import org.eclipse.draw2d.Figure; import org.eclipse.draw2d.Graphics; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.SWTGraphics; import org.eclipse.draw2d.ScaledGraphics; import org.eclipse.draw2d.UpdateListener; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Rectangle; /** * A Thumbnail is a Figure that displays an image of its source Figure at a * smaller size. The Thumbnail will maintain the aspect ratio of the source * Figure. * * @author Eric Bordeau */ public class Thumbnail extends Figure implements UpdateListener { /** * This updates the Thumbnail by breaking the thumbnail {@link Image} into * several tiles and updating each tile individually. */ class ThumbnailUpdater implements Runnable { static final int MAX_BUFFER_SIZE = 256; private int currentHTile, currentVTile; private int hTiles, vTiles; private boolean isActive = true; private boolean isRunning = false; private GC thumbnailGC; private ScaledGraphics thumbnailGraphics; private Dimension tileSize; /** * Stops the updater and disposes of any resources. */ public void deactivate() { setActive(false); stop(); if (thumbnailImage != null) { thumbnailImage.dispose(); thumbnailImage = null; thumbnailImageSize = null; } } /** * Returns the current horizontal tile index. * * @return current horizontal tile index. */ protected int getCurrentHTile() { return currentHTile; } /** * Returns the current vertical tile index. * * @return current vertical tile index. */ protected int getCurrentVTile() { return currentVTile; } /** * Returns true if this ThumbnailUpdater is active. An * inactive updater has disposed of its {@link Image}. The updater may * be active and not currently running. * * @return true if this ThumbnailUpdater is active */ public boolean isActive() { return isActive; } /** * Returns true if this is currently running and updating * at least one tile on the thumbnail {@link Image}. * * @return true if this is currently running */ public boolean isRunning() { return isRunning; } /** * Resets the number of vertical and horizontal tiles, as well as the * tile size and current tile index. */ public void resetTileValues() { hTiles = (int) Math.ceil((float) getSourceRectangle().width / (float) MAX_BUFFER_SIZE); vTiles = (int) Math.ceil((float) getSourceRectangle().height / (float) MAX_BUFFER_SIZE); tileSize = new Dimension( (int) Math.ceil((float) getSourceRectangle().width / (float) hTiles), (int) Math.ceil((float) getSourceRectangle().height / (float) vTiles)); currentHTile = 0; currentVTile = 0; } /** * Restarts the updater. */ public void restart() { stop(); start(); } /** * Updates the current tile on the Thumbnail. An area of the source * Figure is painted to an {@link Image}. That Image is then drawn on * the Thumbnail. Scaling of the source Image is done inside * {@link GC#drawImage(Image, int, int, int, int, int, int, int, int)} * since the source and target sizes are different. The current tile * indexes are incremented and if more updating is necesary, this * {@link Runnable} is called again in a * {@link Display#timerExec(int, Runnable)}. If no more updating is * required, {@link #stop()} is called. */ public void run() { if (!isActive() || !isRunning() || thumbnailGraphics == null) return; int v = getCurrentVTile(); int sy1 = v * tileSize.height; int sy2 = Math.min((v + 1) * tileSize.height, getSourceRectangle().height); int h = getCurrentHTile(); int sx1 = h * tileSize.width; int sx2 = Math.min((h + 1) * tileSize.width, getSourceRectangle().width); org.eclipse.draw2d.geometry.Point p = getSourceRectangle() .getLocation(); Rectangle rect = new Rectangle(sx1 + p.x, sy1 + p.y, sx2 - sx1, sy2 - sy1); thumbnailGraphics.pushState(); thumbnailGraphics.setClip(rect); thumbnailGraphics.fillRectangle(rect); sourceFigure.paint(thumbnailGraphics); thumbnailGraphics.popState(); if (getCurrentHTile() < (hTiles - 1)) setCurrentHTile(getCurrentHTile() + 1); else { setCurrentHTile(0); if (getCurrentVTile() < (vTiles - 1)) setCurrentVTile(getCurrentVTile() + 1); else setCurrentVTile(0); } if (getCurrentHTile() != 0 || getCurrentVTile() != 0) Display.getCurrent().asyncExec(this); else if (isDirty()) { setDirty(false); Display.getCurrent().asyncExec(this); repaint(); } else { stop(); repaint(); } } /** * Sets the active flag. * * @param value * The active value */ public void setActive(boolean value) { isActive = value; } /** * Sets the current horizontal tile index. * * @param count * current horizontal tile index */ protected void setCurrentHTile(int count) { currentHTile = count; } /** * Sets the current vertical tile index. * * @param count * current vertical tile index */ protected void setCurrentVTile(int count) { currentVTile = count; } /** * Starts this updater. This method initializes all the necessary * resources and puts this {@link Runnable} on the asynch queue. If this * updater is not active or is already running, this method just * returns. */ public void start() { if (!isActive() || isRunning()) return; isRunning = true; setDirty(false); resetTileValues(); if (!targetSize.equals(thumbnailImageSize)) { resetThumbnailImage(); } if (targetSize.isEmpty()) return; thumbnailGC = new GC(thumbnailImage, sourceFigure.isMirrored() ? SWT.RIGHT_TO_LEFT : SWT.NONE); thumbnailGraphics = new ScaledGraphics(new SWTGraphics(thumbnailGC)); thumbnailGraphics.scale(getScaleX()); thumbnailGraphics.translate(getSourceRectangle().getLocation() .negate()); Color color = sourceFigure.getForegroundColor(); if (color != null) thumbnailGraphics.setForegroundColor(color); color = sourceFigure.getBackgroundColor(); if (color != null) thumbnailGraphics.setBackgroundColor(color); thumbnailGraphics.setFont(sourceFigure.getFont()); setScales(targetSize.width / (float) getSourceRectangle().width, targetSize.height / (float) getSourceRectangle().height); Display.getCurrent().asyncExec(this); } /** * * @since 3.2 */ private void resetThumbnailImage() { if (thumbnailImage != null) thumbnailImage.dispose(); if (!targetSize.isEmpty()) { thumbnailImage = new Image(Display.getDefault(), targetSize.width, targetSize.height); thumbnailImageSize = new Dimension(targetSize); } else { thumbnailImage = null; thumbnailImageSize = new Dimension(0, 0); } } /** * Stops this updater. Also disposes of resources (except the thumbnail * image which is still needed for painting). */ public void stop() { isRunning = false; if (thumbnailGC != null) { thumbnailGC.dispose(); thumbnailGC = null; } if (thumbnailGraphics != null) { thumbnailGraphics.dispose(); thumbnailGraphics = null; } // Don't dispose of the thumbnail image since it is needed to paint // the // figure when the source is not dirty (i.e. showing/hiding the // dock). } } private boolean isDirty; private float scaleX; private float scaleY; private IFigure sourceFigure; Dimension targetSize = new Dimension(0, 0); private Image thumbnailImage; private Dimension thumbnailImageSize; private ThumbnailUpdater updater = new ThumbnailUpdater(); /** * Creates a new Thumbnail. The source Figure must be set separately if you * use this constructor. */ public Thumbnail() { super(); } /** * Creates a new Thumbnail with the given IFigure as its source figure. * * @param fig * The source figure */ public Thumbnail(IFigure fig) { this(); setSource(fig); } private Dimension adjustToAspectRatio(Dimension size, boolean adjustToMaxDimension) { Dimension sourceSize = getSourceRectangle().getSize(); Dimension borderSize = new Dimension(getInsets().getWidth(), getInsets().getHeight()); size.expand(borderSize.getNegated()); int width, height; if (adjustToMaxDimension) { width = Math.max(size.width, (int) (size.height * sourceSize.width / (float) sourceSize.height + 0.5)); height = Math.max(size.height, (int) (size.width * sourceSize.height / (float) sourceSize.width + 0.5)); } else { width = Math.min(size.width, (int) (size.height * sourceSize.width / (float) sourceSize.height + 0.5)); height = Math.min(size.height, (int) (size.width * sourceSize.height / (float) sourceSize.width + 0.5)); } size.width = width; size.height = height; return size.expand(borderSize); } /** * Deactivates this Thumbnail. */ public void deactivate() { sourceFigure.getUpdateManager().removeUpdateListener(this); updater.deactivate(); } /** * Returns the preferred size of this Thumbnail. The preferred size will be * calculated in a way that maintains the source Figure's aspect ratio. * * @param wHint * The width hint * @param hHint * The height hint * @return The preferred size */ public Dimension getPreferredSize(int wHint, int hHint) { if (prefSize == null) return adjustToAspectRatio(getBounds().getSize(), false); Dimension preferredSize = adjustToAspectRatio(prefSize.getCopy(), true); if (maxSize == null) return preferredSize; Dimension maximumSize = adjustToAspectRatio(maxSize.getCopy(), true); if (preferredSize.contains(maximumSize)) return maximumSize; else return preferredSize; } /** * Returns the scale factor on the X-axis. * * @return X scale */ protected float getScaleX() { return scaleX; } /** * Returns the scale factor on the Y-axis. * * @return Y scale */ protected float getScaleY() { return scaleY; } /** * Returns the source figure being used to generate a thumbnail. * * @return the source figure */ protected IFigure getSource() { return sourceFigure; } /** * Returns the rectangular region relative to the source figure which will * be the basis of the thumbnail. The value may be returned by reference and * should not be modified by the caller. * * @since 3.1 * @return the region of the source figure being used for the thumbnail */ protected Rectangle getSourceRectangle() { return sourceFigure.getBounds(); } /** * Returns the scaled Image of the source Figure. If the Image needs to be * updated, the ThumbnailUpdater will notified. * * @return The thumbnail image */ protected Image getThumbnailImage() { Dimension oldSize = targetSize; targetSize = getPreferredSize(); targetSize.expand(new Dimension(getInsets().getWidth(), getInsets() .getHeight()).negate()); setScales(targetSize.width / (float) getSourceRectangle().width, targetSize.height / (float) getSourceRectangle().height); if ((isDirty()) && !updater.isRunning()) updater.start(); else if (oldSize != null && !targetSize.equals(oldSize)) { revalidate(); updater.restart(); } return thumbnailImage; } /** * Returns true if the source figure has changed. * * @return true if the source figure has changed */ protected boolean isDirty() { return isDirty; } /** * @see org.eclipse.draw2d.UpdateListener#notifyPainting(Rectangle, Map) */ public void notifyPainting(Rectangle damage, Map dirtyRegions) { Iterator dirtyFigures = dirtyRegions.keySet().iterator(); while (dirtyFigures.hasNext()) { IFigure current = (IFigure) dirtyFigures.next(); while (current != null) { if (current == getSource()) { setDirty(true); repaint(); return; } current = current.getParent(); } } } /** * @see org.eclipse.draw2d.UpdateListener#notifyValidating() */ public void notifyValidating() { // setDirty(true); // revalidate(); } /** * @see org.eclipse.draw2d.Figure#paintFigure(Graphics) */ protected void paintFigure(Graphics graphics) { Image thumbnail = getThumbnailImage(); if (thumbnail == null) return; graphics.drawImage(thumbnail, getClientArea().getLocation()); } /** * Sets the dirty flag. * * @param value * The dirty value */ public void setDirty(boolean value) { isDirty = value; } /** * Sets the X and Y scales for the Thumbnail. These scales represent the * ratio between the source figure and the Thumbnail. * * @param x * The X scale * @param y * The Y scale */ protected void setScales(float x, float y) { scaleX = x; scaleY = y; } /** * Sets the source Figure. Also sets the scales and creates the necessary * update manager. * * @param fig * The source figure */ public void setSource(IFigure fig) { if (sourceFigure == fig) return; if (sourceFigure != null) sourceFigure.getUpdateManager().removeUpdateListener(this); sourceFigure = fig; if (sourceFigure != null) { setScales((float) getSize().width / (float) getSourceRectangle().width, (float) getSize().height / (float) getSourceRectangle().height); sourceFigure.getUpdateManager().addUpdateListener(this); repaint(); } } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/parts/package.html000066400000000000000000000002421166301720600271000ustar00rootroot00000000000000 This package contains some complex parts used with Draw2d. eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/000077500000000000000000000000001166301720600244545ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/AbstractFlowBorder.java000066400000000000000000000045061166301720600310550ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2005, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.text; import org.eclipse.draw2d.AbstractBorder; import org.eclipse.draw2d.Border; import org.eclipse.draw2d.Graphics; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.geometry.Insets; import org.eclipse.draw2d.geometry.Rectangle; /** * A basis for implementing {@link FlowBorder}. Subclassing this class will * possibly guarantee compatibility with future changes to the FlowBorder * interface. This class also returns default values for many of the required * methods as a convenience. * * @since 3.1 */ public abstract class AbstractFlowBorder extends AbstractBorder implements FlowBorder { /** * @see FlowBorder#getBottomMargin() */ public int getBottomMargin() { return 0; } /** * @see Border#getInsets(IFigure) */ public Insets getInsets(IFigure figure) { return IFigure.NO_INSETS; } /** * @see FlowBorder#getLeftMargin() */ public int getLeftMargin() { return 0; } /** * @see FlowBorder#getRightMargin() */ public int getRightMargin() { return 0; } /** * @see FlowBorder#getTopMargin() */ public int getTopMargin() { return 0; } /** * This method is not called on FlowBorders. For this reason it is * implemented here and made final so that clients override the * correct method. * * @param figure * the figure * @param graphics * the graphics * @param insets * the insets * @see FlowBorder#paint(FlowFigure, Graphics, Rectangle, int) */ public final void paint(IFigure figure, Graphics graphics, Insets insets) { } /** * Subclasses should override this method to paint each box's border. * * @see FlowBorder#paint(FlowFigure, Graphics, Rectangle, int) */ public void paint(FlowFigure figure, Graphics g, Rectangle where, int sides) { } }eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/BidiChars.java000066400000000000000000000022431166301720600271500ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.text; /** * @since 3.1 */ class BidiChars { /** * paragraph separator character */ static final char P_SEP = '\u2029'; /** * zero-width joiner character */ static final char ZWJ = '\u200d'; /** * left-to-right overwrite character */ static final char LRO = '\u202d'; /** * right-to-left overwrite character */ static final char RLO = '\u202e'; /** * object replacement character */ static final char OBJ = '\ufffc'; /** * left-to-right embedding character */ static final char LRE = '\u202a'; /** * right-to-left embedding character */ static final char RLE = '\u202b'; }eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/BidiInfo.java000066400000000000000000000020541166301720600270030ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.text; /** * This class is for INTERNAL use only. * * @since 3.1 */ public class BidiInfo { /** * Odd-sized array consisting of bidi levels, interleaved with the offsets * at which levels change. */ public int[] levelInfo; /** * Indicates if the ZWJ character needs to be prepended to text being * rendered. */ public boolean leadingJoiner; /** * Indicates if the ZRJ character needs to be appended to the text being * rendered.. */ public boolean trailingJoiner; } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/BidiProcessor.java000066400000000000000000000167511166301720600301000ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.text; import com.ibm.icu.text.Bidi; import java.util.ArrayList; import java.util.List; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.TextLayout; /** * A helper class for a BlockFlow that does Bidi evaluation of all the text in * that block. *

    * WARNING: This class is for INTERNAL use only. * * @author Pratik Shah * @since 3.1 */ public final class BidiProcessor { /** * A helper class to hold information about contributions made to this * processor. * * @author Pratik Shah * @since 3.1 */ private static class BidiEntry { int begin, end; FlowFigure fig; BidiEntry(FlowFigure fig, int offset, int length) { this.fig = fig; this.begin = offset; this.end = offset + length; } } /** * A singleton instance. */ public static final BidiProcessor INSTANCE = new BidiProcessor(); private StringBuffer bidiText; private List list = new ArrayList(); private int orientation = SWT.LEFT_TO_RIGHT; private BidiProcessor() { } /** * Records a String contribution for this bidi context. Contributions are * concatenated (in the order that they were contributed) to make the final * String which will determine the bidi info for all contributors. * * @param fig * the figure that is contributing the given text * @param str * the text contributed by the given figure * @see #addControlChar(char) */ public void add(FlowFigure fig, String str) { // We are currently tracking empty contributions ("") list.add(new BidiEntry(fig, bidiText.length(), str.length())); bidiText.append(str); } /** * Records a character contribution for this bidi context. Contributions are * concatenated (in the order that they were contributed) to make the final * String which will determine the bidi info for all contributors. * * @param fig * the figure that is contributing the given text * @param c * the character being added * @see #addControlChar(char) */ public void add(FlowFigure fig, char c) { list.add(new BidiEntry(fig, bidiText.length(), 1)); bidiText.append(c); } /** * This methods allows FlowFigures to contribute text that may effect the * bidi evaluation, but is not text that is visible on the screen. The bidi * level of such text is reported back to the contributing figure. * * @param c * the control character */ public void addControlChar(char c) { bidiText.append(c); } /** * Breaks the given int array into bidi levels for each figure based on * their contributed text, and assigns those levels to each figure. Also * determines if shaping needs to occur between figures and sets the * appendJoiner, prependJoiner accordingly. * * @param levels * the calculated levels of all the text in the block */ private void assignResults(int[] levels) { BidiEntry prevEntry = null, entry = null; BidiInfo prevInfo = null, info = null; int end = 2, start = 0; for (int i = 0; i < list.size(); i++) { entry = (BidiEntry) list.get(i); info = new BidiInfo(); while (levels[end] < entry.end) end += 2; int levelInfo[]; if (end == start) { levelInfo = new int[1]; if (prevInfo != null) levelInfo[0] = prevInfo.levelInfo[prevInfo.levelInfo.length - 1]; else levelInfo[0] = (orientation == SWT.LEFT_TO_RIGHT) ? 0 : 1; } else { levelInfo = new int[end - start - 1]; System.arraycopy(levels, start + 1, levelInfo, 0, levelInfo.length); } for (int j = 1; j < levelInfo.length; j += 2) levelInfo[j] -= entry.begin; info.levelInfo = levelInfo; // Compare current and previous for joiners, and commit previous // BidiInfo. if (prevEntry != null) { if (// if we started in the middle of a level run levels[start] < entry.begin // and the level run is odd && levels[start + 1] % 2 == 1 // and the first character of this figure is Arabic && isJoiner(entry.begin) // and the last character of the previous figure was // Arabic && isPrecedingJoiner(entry.begin)) prevInfo.trailingJoiner = info.leadingJoiner = true; prevEntry.fig.setBidiInfo(prevInfo); } prevEntry = entry; prevInfo = info; if (entry.end == levels[end]) start = end; else start = end - 2; } if (entry != null) entry.fig.setBidiInfo(info); } private boolean isJoiner(int begin) { return begin < bidiText.length() && isJoiningCharacter(bidiText.charAt(begin)); } /** * @param the * character to be evaluated * @return true if the given character is Arabic or ZWJ */ private boolean isJoiningCharacter(char c) { return Character.getDirectionality(c) == Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC || c == BidiChars.ZWJ; } private boolean isPrecedingJoiner(int begin) { return begin > 0 && isJoiningCharacter(bidiText.charAt(begin - 1)); } /** * Processes the contributed text, determines the Bidi levels, and assigns * them to the FlowFigures that made thet contributions. This class is for * INTERNAL use only. Shaping of visually contiguous Arabic characters that * are split in different figures is also handled. This method will do * nothing if the contributed text does not require Bidi evaluation. All * contributions are discarded at the end of this method. */ public void process() { try { if (bidiText.length() == 0) return; char[] chars = new char[bidiText.length()]; bidiText.getChars(0, bidiText.length(), chars, 0); if (orientation != SWT.RIGHT_TO_LEFT && !Bidi.requiresBidi(chars, 0, chars.length - 1)) return; int[] levels = new int[15]; TextLayout layout = FlowUtilities.getTextLayout(); layout.setOrientation(orientation); layout.setText(bidiText.toString()); int j = 0, offset, prevLevel = -1; for (offset = 0; offset < chars.length; offset++) { int newLevel = layout.getLevel(offset); if (newLevel != prevLevel) { if (j + 3 > levels.length) { int temp[] = levels; levels = new int[levels.length * 2 + 1]; System.arraycopy(temp, 0, levels, 0, temp.length); } levels[j++] = offset; levels[j++] = newLevel; prevLevel = newLevel; } } levels[j++] = offset; if (j != levels.length) { int[] newLevels = new int[j]; System.arraycopy(levels, 0, newLevels, 0, j); levels = newLevels; } assignResults(levels); // reset the orientation of the layout, in case it was set to RTL layout.setOrientation(SWT.LEFT_TO_RIGHT); } finally { // will cause the fields to be reset for the next string to be // processed bidiText = null; list.clear(); } } /** * Sets the paragraph embedding. The given orientation will be used on * TextLayout when determining the Bidi levels. * * @param newOrientation * SWT.LEFT_TO_RIGHT or SWT.RIGHT_TO_LEFT */ public void setOrientation(int newOrientation) { bidiText = new StringBuffer(); list.clear(); orientation = newOrientation; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/BlockBox.java000066400000000000000000000037751166301720600270360ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.text; import org.eclipse.draw2d.geometry.Rectangle; /** * A CompositeBox suitable for containing multiple LineBox fragments. * * @author hudsonr * @since 2.1 */ public class BlockBox extends CompositeBox { int height; private int y; BlockFlow owner; BlockBox(BlockFlow owner) { this.owner = owner; } /** * @see CompositeBox#add(FlowBox) */ public void add(FlowBox box) { width = Math.max(width, box.getWidth()); height = Math.max(height, box.getBaseline() + box.getDescent()); } /** * @see FlowBox#containsPoint(int, int) */ public boolean containsPoint(int x, int y) { return true; } /** * @see FlowBox#getAscent() */ public int getAscent() { return 0; } /** * @see FlowBox#getBaseline() */ public int getBaseline() { return y; } int getBottomMargin() { return owner.getBottomMargin(); } /** * @see FlowBox#getDescent() */ public int getDescent() { return height; } /** * @return Returns the height. */ public int getHeight() { return height; } LineRoot getLineRoot() { return null; } int getTopMargin() { return owner.getTopMargin(); } /** * Sets the height. * * @param h * The height */ public void setHeight(int h) { height = h; } /** * @see CompositeBox#setLineTop(int) */ public void setLineTop(int y) { this.y = y; } Rectangle toRectangle() { return new Rectangle(getX(), y, Math.max(getWidth(), recommendedWidth), height); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/BlockFlow.java000066400000000000000000000221361166301720600272050ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.text; import java.util.List; import org.eclipse.swt.SWT; import org.eclipse.draw2d.ColorConstants; import org.eclipse.draw2d.Graphics; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.PositionConstants; import org.eclipse.draw2d.geometry.Insets; import org.eclipse.draw2d.geometry.Rectangle; /** * A FlowFigure represented by a single {@link BlockBox} containing * one or more lines. A BlockFlow is a creator of LineBoxes, which its children * require during layout. A BlockFlow can be thought of as a foundation for a * paragraph. *

    * BlockFlows must be parented by a FlowFigure. {@link FlowPage} * can be used as a "root" block and can be parented by normal Figures. *

    * Only {@link FlowFigure}s can be added to a BlockFlow. *

    * WARNING: This class is not intended to be subclassed by clients. * * @author hudsonr * @since 2.1 */ public class BlockFlow extends FlowFigure { private final BlockBox blockBox; private int alignment = PositionConstants.NONE; private int orientation = SWT.NONE; private boolean bidiValid; /** * Constructs a new BlockFlow. */ public BlockFlow() { blockBox = createBlockBox(); } /** * BlockFlows contribute a paragraph separator so as to keep the Bidi state * of the text on either side of this block from affecting each other. Since * each block is like a different paragraph, it does not contribute any * actual text to its containing block. * * @see org.eclipse.draw2d.text.FlowFigure#contributeBidi(org.eclipse.draw2d.text.BidiProcessor) */ protected void contributeBidi(BidiProcessor proc) { proc.addControlChar(BidiChars.P_SEP); } BlockBox createBlockBox() { return new BlockBox(this); } /** * @see org.eclipse.draw2d.text.FlowFigure#createDefaultFlowLayout() */ protected FlowFigureLayout createDefaultFlowLayout() { return new BlockFlowLayout(this); } /** * Returns the BlockBox associated with this. * * @return This BlockFlow's BlockBox */ protected BlockBox getBlockBox() { return blockBox; } int getBottomMargin() { int margin = 0; if (getBorder() instanceof FlowBorder) { FlowBorder border = (FlowBorder) getBorder(); return border.getBottomMargin(); } List children = getChildren(); int childIndex = children.size() - 1; if (childIndex >= 0 && children.get(childIndex) instanceof BlockFlow) { margin = Math.max(margin, ((BlockFlow) children.get(childIndex)).getBottomMargin()); } return margin; } /** * Returns the effective horizontal alignment. This method will never return * {@link PositionConstants#NONE}. If the value is none, it will return the * inherited alignment. If no alignment was inherited, it will return the * default alignment ({@link PositionConstants#LEFT}). * * @return the effective alignment */ public int getHorizontalAligment() { if (alignment != PositionConstants.NONE) return alignment; IFigure parent = getParent(); while (parent != null && !(parent instanceof BlockFlow)) parent = parent.getParent(); if (parent != null) return ((BlockFlow) parent).getHorizontalAligment(); return PositionConstants.LEFT; } int getLeftMargin() { if (getBorder() instanceof FlowBorder) return ((FlowBorder) getBorder()).getLeftMargin(); return 0; } /** * Returns the orientation set on this block. * * @return LTR, RTL or NONE * @see #setOrientation(int) * @since 3.1 */ public int getLocalOrientation() { return orientation; } /** * Returns the horizontal alignment set on this block. * * @return LEFT, RIGHT, ALWAYS_LEFT, ALWAYS_RIGHT, NONE * @see #setHorizontalAligment(int) * @since 3.1 */ public int getLocalHorizontalAlignment() { return alignment; } /** * Returns this block's Bidi orientation. If none was set on this block, it * will inherit the one from its containing block. If there is no containing * block, it will return the default orientation (SWT.RIGHT_TO_LEFT if * mirrored; SWT.LEFT_TO_RIGHT otherwise). * * @return SWT.RIGHT_TO_LEFT or SWT.LEFT_TO_RIGHT * @see #setOrientation(int) * @since 3.1 */ public int getOrientation() { if (orientation != SWT.NONE) return orientation; IFigure parent = getParent(); while (parent != null && !(parent instanceof BlockFlow)) parent = parent.getParent(); if (parent != null) return ((BlockFlow) parent).getOrientation(); return isMirrored() ? SWT.RIGHT_TO_LEFT : SWT.LEFT_TO_RIGHT; } int getRightMargin() { if (getBorder() instanceof FlowBorder) return ((FlowBorder) getBorder()).getRightMargin(); return 0; } int getTopMargin() { int margin = 0; if (getBorder() instanceof FlowBorder) { FlowBorder border = (FlowBorder) getBorder(); return border.getTopMargin(); } List children = getChildren(); if (children.size() > 0 && children.get(0) instanceof BlockFlow) { margin = Math.max(margin, ((BlockFlow) children.get(0)).getTopMargin()); } return margin; } /** * @see org.eclipse.draw2d.Figure#paintBorder(org.eclipse.draw2d.Graphics) */ public void paintBorder(Graphics graphics) { if (getBorder() instanceof FlowBorder) { Rectangle where = getBlockBox().toRectangle(); where.crop(new Insets(getTopMargin(), getLeftMargin(), getBottomMargin(), getRightMargin())); ((FlowBorder) getBorder()).paint(this, graphics, where, SWT.LEAD | SWT.TRAIL); } else super.paintBorder(graphics); if (selectionStart != -1) { graphics.restoreState(); graphics.setXORMode(true); graphics.setBackgroundColor(ColorConstants.white); graphics.fillRectangle(getBounds()); } } /** * @see org.eclipse.draw2d.text.FlowFigure#postValidate() */ public void postValidate() { Rectangle newBounds = getBlockBox().toRectangle(); newBounds.crop(new Insets(getTopMargin(), getLeftMargin(), getBottomMargin(), getRightMargin())); setBounds(newBounds); } /** * @see FlowFigure#revalidate() */ public void revalidate() { BlockFlowLayout layout = (BlockFlowLayout) getLayoutManager(); layout.blockContentsChanged(); super.revalidate(); } /** * A Block will invalidate the Bidi state of all its children, so that it is * re-evaluated when this block is next validated. * * @see org.eclipse.draw2d.text.FlowFigure#revalidateBidi(org.eclipse.draw2d.IFigure) */ protected void revalidateBidi(IFigure origin) { if (bidiValid) { bidiValid = false; revalidate(); } } /** * Sets the horitontal aligment of the block. Valid values are: *

      *
    • {@link PositionConstants#NONE NONE} - (default) Alignment is * inherited from parent. If a parent is not found then LEFT is used.
    • *
    • {@link PositionConstants#LEFT} - Alignment is with leading edge
    • *
    • {@link PositionConstants#RIGHT} - Alignment is with trailing edge
    • *
    • {@link PositionConstants#CENTER}
    • *
    • {@link PositionConstants#ALWAYS_LEFT} - Left, irrespective of * orientation
    • *
    • {@link PositionConstants#ALWAYS_RIGHT} - Right, irrespective of * orientation
    • *
    * * @param value * the aligment * @see #getHorizontalAligment() */ public void setHorizontalAligment(int value) { value &= PositionConstants.LEFT | PositionConstants.CENTER | PositionConstants.RIGHT | PositionConstants.ALWAYS_LEFT | PositionConstants.ALWAYS_RIGHT; if (value == alignment) return; alignment = value; revalidate(); } /** * Sets the orientation for this block. Orientation can be one of: *
      *
    • {@link SWT#LEFT_TO_RIGHT} *
    • {@link SWT#RIGHT_TO_LEFT} *
    • {@link SWT#NONE} (default) *
    * NONE is used to indicate that orientation should be * inherited from the encompassing block. * * @param orientation * LTR, RTL or NONE * @see #getOrientation() * @since 3.1 */ public void setOrientation(int orientation) { orientation &= SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT; if (this.orientation == orientation) return; this.orientation = orientation; revalidateBidi(this); } /** * @see org.eclipse.draw2d.Figure#useLocalCoordinates() */ protected boolean useLocalCoordinates() { return true; } /** * Re-evaluate the Bidi state of all the fragments if it has been * invalidated. * * @see org.eclipse.draw2d.IFigure#validate() */ public void validate() { if (!bidiValid) { BidiProcessor.INSTANCE.setOrientation(getOrientation()); if (getOrientation() == SWT.LEFT_TO_RIGHT && isMirrored()) BidiProcessor.INSTANCE.addControlChar(BidiChars.LRE); super.contributeBidi(BidiProcessor.INSTANCE); BidiProcessor.INSTANCE.process(); bidiValid = true; } super.validate(); } }eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/BlockFlowLayout.java000066400000000000000000000143661166301720600304110ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.text; import java.util.List; import org.eclipse.swt.SWT; import org.eclipse.draw2d.Figure; import org.eclipse.draw2d.PositionConstants; import org.eclipse.draw2d.geometry.Insets; /** * The layout for {@link BlockFlow} figures. * *

    * WARNING: This class is not intended to be subclassed by clients. * * @author hudsonr * @since 2.1 */ public class BlockFlowLayout extends FlowContainerLayout { BlockBox blockBox; boolean blockInvalid = false; private boolean continueOnSameLine = false; private CompositeBox previousLine = null; /** * Creates a new BlockFlowLayout with the given BlockFlow. * * @param blockFlow * the BlockFlow */ public BlockFlowLayout(BlockFlow blockFlow) { super(blockFlow); } private void addBelowPreviousLine(CompositeBox line) { if (previousLine == null) line.setLineTop(line.getTopMargin()); else line.setLineTop(previousLine.getBaseline() + previousLine.getDescent() + Math.max(previousLine.getBottomMargin(), line.getTopMargin())); int alignment = getBlockFlow().getHorizontalAligment(); if (alignment == PositionConstants.LEFT || alignment == PositionConstants.RIGHT) { int orientation = getBlockFlow().getOrientation(); if (alignment == PositionConstants.LEFT) alignment = orientation == SWT.LEFT_TO_RIGHT ? PositionConstants.ALWAYS_LEFT : PositionConstants.ALWAYS_RIGHT; else alignment = orientation == SWT.LEFT_TO_RIGHT ? PositionConstants.ALWAYS_RIGHT : PositionConstants.ALWAYS_LEFT; } if (alignment != PositionConstants.CENTER && getBlockFlow().isMirrored()) alignment = (PositionConstants.ALWAYS_LEFT | PositionConstants.ALWAYS_RIGHT) & ~alignment; switch (alignment) { case PositionConstants.ALWAYS_RIGHT: line.setX(blockBox.getRecommendedWidth() - line.getWidth()); break; case PositionConstants.CENTER: line.setX((blockBox.getRecommendedWidth() - line.getWidth()) / 2); break; case PositionConstants.ALWAYS_LEFT: line.setX(0); break; default: throw new RuntimeException("Unexpected state"); //$NON-NLS-1$ } blockBox.add(line); previousLine = line; } /** * Align the line horizontally and then commit it. */ protected void addCurrentLine() { addBelowPreviousLine(currentLine); ((LineRoot) currentLine).commit(); } /** * @see FlowContext#addLine(CompositeBox) */ public void addLine(CompositeBox box) { endLine(); addBelowPreviousLine(box); } /** * Marks the blocks contents as changed. This means that children will be * invalidated during validation. * * @since 3.1 */ public void blockContentsChanged() { blockInvalid = true; } /** * @see FlowContainerLayout#cleanup() */ protected void cleanup() { super.cleanup(); previousLine = null; } /** * @see FlowContainerLayout#createNewLine() */ protected void createNewLine() { currentLine = new LineRoot(getBlockFlow().isMirrored()); currentLine.setRecommendedWidth(blockBox.getRecommendedWidth()); } /** * Called by flush(), adds the BlockBox associated with this BlockFlowLayout * to the current line and then ends the line. */ protected void endBlock() { if (blockInvalid) { Insets insets = getBlockFlow().getInsets(); blockBox.height += insets.getHeight(); blockBox.width += insets.getWidth(); } if (getContext() != null) getContext().addLine(blockBox); if (blockInvalid) { blockInvalid = false; List v = getFlowFigure().getChildren(); for (int i = 0; i < v.size(); i++) ((FlowFigure) v.get(i)).postValidate(); } } /** * @see FlowContext#endLine() */ public void endLine() { if (currentLine == null || !currentLine.isOccupied()) return; addCurrentLine(); currentLine = null; } /** * @see FlowContainerLayout#flush() */ protected void flush() { endLine(); endBlock(); } boolean forceChildInvalidation(Figure f) { return blockInvalid; } /** * Returns the BlockFlow associated with this BlockFlowLayout * * @return the BlockFlow */ protected final BlockFlow getBlockFlow() { return (BlockFlow) getFlowFigure(); } int getContextWidth() { return getContext().getRemainingLineWidth(); } /** * @see FlowContext#getContinueOnSameLine() */ public boolean getContinueOnSameLine() { return continueOnSameLine; } /** * @see FlowContext#getWidthLookahead(FlowFigure, int[]) */ public void getWidthLookahead(FlowFigure child, int result[]) { List children = getFlowFigure().getChildren(); int index = -1; if (child != null) index = children.indexOf(child); for (int i = index + 1; i < children.size(); i++) if (((FlowFigure) children.get(i)) .addLeadingWordRequirements(result)) return; } /** * @see FlowContainerLayout#preLayout() */ protected void preLayout() { setContinueOnSameLine(false); blockBox = getBlockFlow().getBlockBox(); setupBlock(); // Probably could setup current and previous line here, or just previous } /** * @see org.eclipse.draw2d.text.FlowContext#setContinueOnSameLine(boolean) */ public void setContinueOnSameLine(boolean value) { continueOnSameLine = value; } /** * sets up the single block that contains all of the lines. */ protected void setupBlock() { int recommended = getContextWidth(); if (recommended == Integer.MAX_VALUE) recommended = -1; BlockFlow bf = getBlockFlow(); if (recommended > 0) { int borderCorrection = bf.getInsets().getWidth() + bf.getLeftMargin() + bf.getRightMargin(); recommended = Math.max(0, recommended - borderCorrection); } if (recommended != blockBox.recommendedWidth) { blockInvalid = true; blockBox.setRecommendedWidth(recommended); } if (blockInvalid) { blockBox.height = 0; blockBox.setWidth(Math.max(0, recommended)); } } }eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/CaretInfo.java000066400000000000000000000067211166301720600271770ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.text; import org.eclipse.draw2d.geometry.Translatable; /** * Stores positional information about where a caret should be placed. This * structure currently only offers integer precision. Scaling operations will * result in rounding. * * @since 3.1 */ public class CaretInfo implements Translatable { private int ascent, lineAscent, descent, lineDescent, baseline, x; /** * Constructor for use by TextFlow. Constructs a new CaretInfo with the * figure's ascent and descent and line information. *

    * WARNING: This constructor should not be called by clients. It is * for use by {@link TextFlow}, and may change in future releases. * * @param x * the x location * @param y * the y location of the top of the caret * @param ascent * the ascent * @param descent * the descent * @param lineAscent * the ascent of the line on which the caret is placed * @param lineDescent * the descent of the line on which the caret is placed */ protected CaretInfo(int x, int y, int ascent, int descent, int lineAscent, int lineDescent) { this.x = x; this.baseline = y + ascent; this.ascent = ascent; this.descent = descent; this.lineAscent = lineAscent; this.lineDescent = lineDescent; } /** * Constructs a CaretInfo object by copying the values from another * instance. * * @param info * the reference * @since 3.2 */ protected CaretInfo(CaretInfo info) { this.ascent = info.ascent; this.baseline = info.baseline; this.descent = info.descent; this.lineAscent = info.lineAscent; this.lineDescent = info.lineDescent; this.x = info.x; } /** * Returns the y location of the baseline. * * @return the y coordinate of the baseline */ public int getBaseline() { return baseline; } /** * Returns the total height of the caret. The height is the sum of the * ascent and descent. * * @return the height */ public int getHeight() { return ascent + descent; } /** * @return the total height of the line on which the caret is placed */ public int getLineHeight() { return lineAscent + lineDescent; } /** * @return the y location of the line on which the caret is placed */ public int getLineY() { return baseline - lineAscent; } /** * Returns the x location of the caret. * * @return the x coordinate */ public int getX() { return x; } /** * Returns the y location of the caret. * * @return the y coordinate */ public int getY() { return baseline - ascent; } /** * @see Translatable#performScale(double) */ public void performScale(double factor) { x *= factor; baseline *= factor; descent *= factor; ascent *= factor; lineAscent *= factor; lineDescent *= factor; } /** * @see Translatable#performTranslate(int, int) */ public void performTranslate(int dx, int dy) { x += dx; baseline += dy; } }eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/CompositeBox.java000066400000000000000000000031611166301720600277330ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.text; /** * A FlowBox that can contain other FlowBoxes. The contained FlowBoxes are * called fragments. * * @author hudsonr * @since 2.1 */ public abstract class CompositeBox extends FlowBox { int recommendedWidth = -1; /** * Adds the given box and updates properties of this composite box. * * @param box * the child being added */ public abstract void add(FlowBox box); abstract int getBottomMargin(); /** * Returns the recommended width for this CompositeBox. * * @return the recommended width */ public int getRecommendedWidth() { return recommendedWidth; } abstract int getTopMargin(); /** * Sets the recommended width for this CompositeBox. * * @param w * the width */ public void setRecommendedWidth(int w) { recommendedWidth = w; } /** * Positions the box vertically by setting the y coordinate for the top of * the content of the line. For internal use only. * * @param top * the y coordinate * @since 3.1 */ public abstract void setLineTop(int top); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/ContentBox.java000066400000000000000000000034711166301720600274070ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.text; /** * FlowBoxes that are leaf nodes. * * @author Pratik Shah * @since 3.1 */ public abstract class ContentBox extends FlowBox { private int bidiLevel = -1; private LineRoot lineRoot; /** * @see FlowBox#getBaseline() */ public int getBaseline() { return lineRoot.getBaseline(); } /** * @return the Bidi level of this box, if one has been set; -1 otherwise * @see #setBidiLevel(int) */ public int getBidiLevel() { return bidiLevel; } /** * @see org.eclipse.draw2d.text.FlowBox#getLineRoot() */ LineRoot getLineRoot() { return lineRoot; } /** * Returns true if the bidi level for this box is specified, * and is not the default level (0). * * @see org.eclipse.draw2d.text.FlowBox#requiresBidi() */ public boolean requiresBidi() { return bidiLevel > 0; } /** * Sets the Bidi level of this fragment. It is used to rearrange fragments * as defined by the Unicode Bi-directional algorithm. Valid values are -1 * (meaning no Bidi level), or any non-negative integer less than 62. * * @param newLevel * the new BidiLevel * @see #getBidiLevel() */ public void setBidiLevel(int newLevel) { bidiLevel = newLevel; } void setLineRoot(LineRoot root) { this.lineRoot = root; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/FlowAdapter.java000066400000000000000000000103251166301720600275300ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2005, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.text; import java.util.Iterator; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Rectangle; /** * Adapts non-flow figures for use within a parent hierarchy requiring flow * figures. Normal draw2d figures can be added as children. If a normal * LayoutManager is set, the children will be positioned by that layout manager. * The size of this figure within the flow will be determined by its preferred * size. *

    * WARNING: This class is not intended to be subclassed by clients. * * @author Pratik Shah * @since 3.1 */ public class FlowAdapter extends FlowFigure { private FlowContext context; private FigureBox box = new FigureBox(); /** * This FlowFigure contributes an Object Replacement Character. * * @see FlowFigure#contributeBidi(BidiProcessor) */ protected void contributeBidi(BidiProcessor proc) { box.setBidiLevel(-1); // contributes a single object replacement char proc.add(this, BidiChars.OBJ); } /** * @return null * @see org.eclipse.draw2d.text.FlowFigure#createDefaultFlowLayout() */ protected FlowFigureLayout createDefaultFlowLayout() { return null; } /** * Sizes the content box to be big enough to display all figures. Wraps to * the next line if there is not enough room on the current one. * * @see org.eclipse.draw2d.Figure#layout() */ protected void layout() { int wHint = context.getRemainingLineWidth(); if (wHint == Integer.MAX_VALUE) wHint = -1; Dimension prefSize = getPreferredSize(wHint, -1); if (context.isCurrentLineOccupied() && prefSize.width > context.getRemainingLineWidth()) { context.endLine(); prefSize = getPreferredSize(context.getRemainingLineWidth(), -1); } box.setSize(prefSize); context.addToCurrentLine(box); } /** * Updates the bounds of this figure to match that of its content box, and * lays out this figure's children. * * @see FlowFigure#postValidate() */ public void postValidate() { setBounds(new Rectangle(box.getX(), box.getBaseline() - box.ascent, box.width, box.ascent)); super.layout(); for (Iterator itr = getChildren().iterator(); itr.hasNext();) ((IFigure) itr.next()).validate(); } /** * Sets the bidi level of the content box associated with this Figure * * @see FlowFigure#setBidiInfo(BidiInfo) */ public void setBidiInfo(BidiInfo info) { box.setBidiLevel(info.levelInfo[0]); } /** * @see org.eclipse.draw2d.IFigure#setBounds(org.eclipse.draw2d.geometry.Rectangle) */ public void setBounds(Rectangle rect) { int x = bounds.x, y = bounds.y; boolean resize = (rect.width != bounds.width) || (rect.height != bounds.height), translate = (rect.x != x) || (rect.y != y); if ((resize || translate) && isVisible()) erase(); if (translate) { int dx = rect.x - x; int dy = rect.y - y; primTranslate(dx, dy); } bounds.width = rect.width; bounds.height = rect.height; if (translate || resize) { fireFigureMoved(); repaint(); } } /** * @see FlowFigure#setFlowContext(FlowContext) */ public void setFlowContext(FlowContext flowContext) { context = flowContext; } /** * Do not validate children. * * @see org.eclipse.draw2d.IFigure#validate() */ public void validate() { if (isValid()) return; setValid(true); layout(); } private class FigureBox extends ContentBox { private int ascent; public boolean containsPoint(int x, int y) { return FlowAdapter.this.containsPoint(x, y); } public int getAscent() { return ascent; } public int getDescent() { return 0; } public void setSize(Dimension size) { ascent = size.height; width = size.width; } } }eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/FlowBorder.java000066400000000000000000000055301166301720600273670ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.text; import org.eclipse.draw2d.Border; import org.eclipse.draw2d.Graphics; import org.eclipse.draw2d.geometry.Rectangle; /** * Experimental API. This is a special type of border for use with * {@link org.eclipse.draw2d.text.FlowFigure}s. This interface should not be * implemented by clients. Clients should extend * {@link org.eclipse.draw2d.text.AbstractFlowBorder}. * * @since 3.1 */ public interface FlowBorder extends Border { /** * Returns the collapsable bottom margin in pixels. Margin is the space * external to the border and the flow box on which it is rendered. Vertical * margins (top and bottom) may collapse in some situations, such as * adjacent or nested blocks. * * @return the bottom margin * @since 3.1 */ int getBottomMargin(); /** * Returns the left margin in pixels. Margin is the space external to the * border and the flow box on which it is rendered. * * @return the left margin * @since 3.1 */ int getLeftMargin(); /** * Returns the right margin in pixels. Margin is the space external to the * border and the flow box on which it is rendered. * * @return the right margin * @since 3.1 */ int getRightMargin(); /** * Returns the collapsable top margin in pixels. Margin is the space * external to the border and the flow box on which it is rendered. Vertical * margins (top and bottom) may collapse in some situations, such as * adjacent or nested blocks. * * @return the top margin * @since 3.1 */ int getTopMargin(); /** * Paints the border around the given box location. The border is asked to * paint each of the FlowFigure's boxes. The sideInfo parameter * is used to indicate whether the left and right sides should be rendered. * This parameter will contain the following bit flags: *

      *
    • {@link org.eclipse.swt.SWT#LEAD} *
    • {@link org.eclipse.swt.SWT#TRAIL} *
    • {@link org.eclipse.swt.SWT#RIGHT_TO_LEFT} *
    * * @param figure * the flow figure whose border is being painted * @param g * the graphics * @param where * the relative location of the box * @param sides * bits indicating sides and bidi orientation * @since 3.1 */ void paint(FlowFigure figure, Graphics g, Rectangle where, int sides); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/FlowBox.java000066400000000000000000000102331166301720600266760ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.text; /** * A Geometric object for representing a region on a line of Text. This class * adds the notion of a baseline to * {@link org.eclipse.draw2d.geometry.Rectangle}. Ascent is the distance * above the baseline. Descent is the distance below the baseline. *

    * This class should not be treated as a Rectangle by clients. It * is important to use getters when available for lazy calculation of values. * * @author hudsonr * @since 2.1 */ public abstract class FlowBox { int width; /** * The x location */ private int x; /** * This method must be called on a block that is completely positioned and * committed. * * @param x * X * @param y * Y * @return true if the FlowBox contains the point */ public abstract boolean containsPoint(int x, int y); /** * Returns the amount of line content in pixels which is above the baseline. * Ascent and descent are used to space consecutive lines apart. Certain * types of line content, such as borders, extend beyond the ascent and * descent. * * @return the descent in pixels below the baseline */ public abstract int getAscent(); /** * Returns y coordinate for the box's baseline. * * @return the baseline location * @since 3.1 */ public abstract int getBaseline(); /** * Returns the amount of line content in pixels which is below the baseline. * * @return the descent in pixels * @see #getAscent() */ public abstract int getDescent(); /** * Returns the root LineBox in which this box is placed. The root line is * interesting when painting selection or hit testing. All boxes in a line * should render selection at the same top and bottom location. * * @return the line root. * @since 3.1 */ abstract LineRoot getLineRoot(); /** * Returns the outer ascent of this box. The outer ascent is the ascent * above the baseline including the border size and margin. This is used * when adding content into a LineBox. The linebox's own border must be * drawn around the children. */ int getOuterAscent() { return getAscent(); } /** * Returns the outer descent of this box. The outer descent is the space * below the baseline including the border size and margin. This is used * when adding content into a LineBox. The linebox's own border must be * drawn around the children. */ int getOuterDescent() { return getDescent(); } int getAscentWithBorder() { throw new RuntimeException("Not valid on this box type"); //$NON-NLS-1$ } int getDescentWithBorder() { throw new RuntimeException("Not valid on this box type"); //$NON-NLS-1$ } /** * Returns the width of the box. * * @return the box's width */ public int getWidth() { return width; } /** * Returns the X coordinate of the box. * * @return the x coordinate * @since 3.1 */ public int getX() { return x; } /** * Returns true if any of the children are bi-directional. * Default implementation returns false. * * @return true if the box is bi-directional * @since 3.1 */ public boolean requiresBidi() { return false; } /** * Sets the line root. * * @param root * the line root * @since 3.1 */ void setLineRoot(LineRoot root) { } /** * Sets the width of the box. * * @param width * the new width * @since 3.1 */ public void setWidth(int width) { this.width = width; } /** * Sets the x coordinate for this box. * * @param x * the x coordinate * @since 3.1 */ public void setX(int x) { this.x = x; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/FlowContainerLayout.java000066400000000000000000000056461166301720600313020ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.text; import java.util.List; import org.eclipse.draw2d.Figure; /** * A layout for FlowFigures with children. * *

    * WARNING: This class is not intended to be subclassed by clients. * * @author hudsonr * @since 2.1 */ public abstract class FlowContainerLayout extends FlowFigureLayout implements FlowContext { /** * the current line */ LineBox currentLine; /** * @see org.eclipse.draw2d.text.FlowFigureLayout#FlowFigureLayout(FlowFigure) */ protected FlowContainerLayout(FlowFigure flowFigure) { super(flowFigure); } /** * Adds the given box the current line and clears the context's state. * * @see org.eclipse.draw2d.text.FlowContext#addToCurrentLine(FlowBox) */ public void addToCurrentLine(FlowBox child) { getCurrentLine().add(child); setContinueOnSameLine(false); } /** * Flush anything pending and free all temporary data used during layout. */ protected void cleanup() { currentLine = null; } /** * Used by getCurrentLine(). */ protected abstract void createNewLine(); /** * Called after {@link #layoutChildren()} when all children have been laid * out. This method exists to flush the last line. */ protected abstract void flush(); /** * FlowBoxes shouldn't be added directly to the current line. Use * {@link #addToCurrentLine(FlowBox)} for that. * * @see org.eclipse.draw2d.text.FlowContext#getCurrentLine() */ LineBox getCurrentLine() { if (currentLine == null) createNewLine(); return currentLine; } /** * @see FlowContext#getRemainingLineWidth() */ public int getRemainingLineWidth() { return getCurrentLine().getAvailableWidth(); } /** * @see FlowContext#isCurrentLineOccupied() */ public boolean isCurrentLineOccupied() { return currentLine != null && currentLine.isOccupied(); } /** * @see FlowFigureLayout#layout() */ protected void layout() { preLayout(); layoutChildren(); flush(); cleanup(); } /** * Layout all children. */ protected void layoutChildren() { List children = getFlowFigure().getChildren(); for (int i = 0; i < children.size(); i++) { Figure f = (Figure) children.get(i); if (forceChildInvalidation(f)) f.invalidate(); f.validate(); } } boolean forceChildInvalidation(Figure f) { return true; } /** * Called before layoutChildren() to setup any necessary state. */ protected abstract void preLayout(); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/FlowContext.java000066400000000000000000000060521166301720600275760ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.text; /** * The context that a {@link FlowFigureLayout} uses to perform its layout. * *

    * WARNING: This interface is not intended to be implemented by clients. It * exists to define the API between the layout and its context. */ public interface FlowContext { /** * Adds the given box into the current line. * * @param box * the FlowBox to add */ void addToCurrentLine(FlowBox box); /** * Adds an entire line into the context. If there is a previous line, it is * ended. * * @param box * the line being added * @since 3.1 */ void addLine(CompositeBox box); /** * The current line should be committed if it is occupied, and then set to * null. Otherwise, do nothing. */ void endLine(); /** * This method can be used to query the amount of space left on the current * line. It can help determine where to wrap during layout. * * @return the amount of space left on the current line * @since 3.1 */ int getRemainingLineWidth(); /** * This method is used to convey layout state to different FlowFigures. This * state is cleared when a fragment is added to the current line and once * the layout is complete. * * @return true if the next fragment should be placed on the * current line * @since 3.1 * @see #setContinueOnSameLine(boolean) */ boolean getContinueOnSameLine(); /** * This method looks ahead for line-breaks. When laying out, this method can * be used to determine the next line-break across multiple figures. * * @param child * the search will occur starting from the figure after the given * child * @param width * the width before the next line-break (if one's found; all the * width, otherwise) will be added on to the first int in the * given array * @since 3.1 */ void getWidthLookahead(FlowFigure child, int width[]); /** * @return true if the current line contains any fragments */ boolean isCurrentLineOccupied(); /** * This method is used to convey layout state to different FlowFigures. This * state is cleared when a fragment is added and once the layout is * complete. * * @param value * true indicates that the first fragment of the * next TextFlow should be laid out on the current line, and not * a new one * @since 3.1 * @see #getContinueOnSameLine() */ void setContinueOnSameLine(boolean value); } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/FlowFigure.java000066400000000000000000000142101166301720600273660ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.text; import java.util.Iterator; import org.eclipse.draw2d.Figure; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.geometry.Rectangle; /** * The base implementation for text flow figures. A flow figure is used to * render a document in which elements are laid out horizontally within a "line" * until that line is filled. Layout continues on the next line. * *

    * WARNING: This class is not intended to be subclassed by clients. Future * versions may contain additional abstract methods. * * @author hudsonr * @since 2.1 */ public abstract class FlowFigure extends Figure { /** * integer indicating whether selection should be displayed. */ protected int selectionStart = -1; /** * Constructs a new FlowFigure. */ public FlowFigure() { setLayoutManager(createDefaultFlowLayout()); } /** * If the child is a FlowFigure, its FlowContext is passed to * it. * * @see org.eclipse.draw2d.IFigure#add(IFigure, Object, int) */ public void add(IFigure child, Object constraint, int index) { super.add(child, constraint, index); // If this layout manager is a FlowContext, then the child *must* be a // FlowFigure if (getLayoutManager() instanceof FlowContext) ((FlowFigure) child) .setFlowContext((FlowContext) getLayoutManager()); revalidateBidi(this); } /** * Calculates the width of text before the next line-break is encountered. *

    * Default implementation treats each FlowFigure as a line-break. It adds no * width and returns true. Sub-classes should override as * needed. * * @param width * the width before the next line-break (if one's found; all the * width, otherwise) will be added on to the first int in the * given array * @return boolean indicating whether or not a line-break was found * @since 3.1 */ public boolean addLeadingWordRequirements(int[] width) { return true; } /** * FlowFigures can contribute text for their block to the given * {@link BidiProcessor}, which will process the contributions to determine * Bidi levels and shaping requirements. *

    * This method is invoked as part of validating Bidi. *

    * Sub-classes that cache the BidiInfo and/or the bidi level in ContentBoxes * should clear the cached values when this method is invoked. * * @param proc * the BidiProcessor to which contributions should be made * @see BidiProcessor#add(FlowFigure, String) * @since 3.1 */ protected void contributeBidi(BidiProcessor proc) { for (Iterator iter = getChildren().iterator(); iter.hasNext();) ((FlowFigure) iter.next()).contributeBidi(proc); } /** * Creates the default layout manager * * @return The default layout */ protected abstract FlowFigureLayout createDefaultFlowLayout(); /** * Called after validate has occurred. This is used to update the bounds of * the FlowFigure to encompass its new flow boxed created during validate. */ public abstract void postValidate(); /** * Overridden to revalidateBidi when fragments are removed. * * @see org.eclipse.draw2d.IFigure#remove(org.eclipse.draw2d.IFigure) */ public void remove(IFigure figure) { super.remove(figure); revalidateBidi(this); } /** * This method should be invoked whenever a change that can potentially * affect the Bidi evaluation is made (eg., adding or removing children, * changing text, etc.). *

    * The default implementation delegates the revalidation task to the parent. * Only {@link BlockFlow#revalidateBidi(IFigure) blocks} perform the actual * revalidation. *

    * The given IFigure is the one that triggered the revalidation. This can be * used to optimize bidi evaluation. * * @param origin * the figure that was revalidated * @since 3.1 */ protected void revalidateBidi(IFigure origin) { if (getParent() != null) ((FlowFigure) getParent()).revalidateBidi(origin); } /** * Sets the bidi information for this figure. A flow figure contributes bidi * text in {@link #contributeBidi(BidiProcessor)}. If the figure contributes * text associated with it, this method is called back to indicate the bidi * properties for that text within its block. * * @param info * the BidiInfo for this figure * @since 3.1 */ public void setBidiInfo(BidiInfo info) { } /** * FlowFigures override setBounds() to prevent translation of children. * "bounds" is a derived property for FlowFigures, calculated from the * fragments that make up the FlowFigure. * * @see Figure#setBounds(Rectangle) */ public void setBounds(Rectangle r) { if (bounds.equals(r)) return; if (!r.contains(bounds)) erase(); bounds.x = r.x; bounds.y = r.y; bounds.width = r.width; bounds.height = r.height; fireFigureMoved(); if (isCoordinateSystem()) fireCoordinateSystemChanged(); repaint(); } /** * Sets the flow context. * * @param flowContext * the flow context for this flow figure */ public void setFlowContext(FlowContext flowContext) { ((FlowFigureLayout) getLayoutManager()).setFlowContext(flowContext); } /** * Sets the selection or a range of selection. A start value of -1 is used * to indicate no selection. A start value >=0 indicates show selection. A * start and end value can be used to represent a range of offsets which * should render selection. * * @param start * the start offset * @param end * the end offset * @since 3.1 */ public void setSelection(int start, int end) { if (selectionStart == start) return; selectionStart = start; repaint(); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/FlowFigureLayout.java000066400000000000000000000062371166301720600305760ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.text; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.LayoutManager; import org.eclipse.draw2d.geometry.Dimension; /** * A LayoutManager for use with FlowFigure. * *

    * WARNING: This class is not intended to be subclassed by clients. * * @author hudsonr * @since 2.1 */ public abstract class FlowFigureLayout implements LayoutManager { /** * The flow context in which this LayoutManager exists. */ private FlowContext context; /** * The figure passed by layout(Figure) is held for convenience. */ private final FlowFigure flowFigure; /** * Constructs a new FlowFigureLayout with the given FlowFigure. * * @param flowfigure * the FlowFigure */ protected FlowFigureLayout(FlowFigure flowfigure) { this.flowFigure = flowfigure; } /** * Not applicable. * * @see org.eclipse.draw2d.LayoutManager#getConstraint(org.eclipse.draw2d.IFigure) */ public Object getConstraint(IFigure child) { return null; } /** * Returns this layout's context or null. * * @return null or a context * @since 3.1 */ protected FlowContext getContext() { return context; } /** * @return the FlowFigure */ protected FlowFigure getFlowFigure() { return flowFigure; } /** * Not applicable. * * @see org.eclipse.draw2d.LayoutManager#getMinimumSize(org.eclipse.draw2d.IFigure, * int, int) */ public Dimension getMinimumSize(IFigure container, int wHint, int hHint) { return null; } /** * Not applicable. * * @see org.eclipse.draw2d.LayoutManager#getPreferredSize(org.eclipse.draw2d.IFigure, * int, int) */ public Dimension getPreferredSize(IFigure container, int wHint, int hHint) { return null; } /** * Not applicable. * * @see org.eclipse.draw2d.LayoutManager#invalidate() */ public void invalidate() { } /** * Called during {@link #layout(IFigure)}. */ protected abstract void layout(); /** * @see org.eclipse.draw2d.LayoutManager#layout(IFigure) */ public final void layout(IFigure figure) { layout(); } /** * Not applicable. * * @see org.eclipse.draw2d.LayoutManager#remove(org.eclipse.draw2d.IFigure) */ public void remove(IFigure child) { } /** * Not applicable. * * @see org.eclipse.draw2d.LayoutManager#setConstraint(org.eclipse.draw2d.IFigure, * java.lang.Object) */ public void setConstraint(IFigure child, Object constraint) { } /** * Sets the context for this layout manager. * * @param flowContext * the context of this layout */ public void setFlowContext(FlowContext flowContext) { context = flowContext; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/FlowPage.java000066400000000000000000000075661166301720600270410ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.text; import java.util.List; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Rectangle; /** * The root of a Flow hierarchy. A flow page can be treated as a normal figure, * but contains FlowFigures. *

    * A FlowPage will not have a defined width unless it is inside a figure whose * layout provides width hints when calling * {@link org.eclipse.draw2d.IFigure#getPreferredSize(int, int)}. * *

    * WARNING: This class is not intended to be subclassed by clients. */ public class FlowPage extends BlockFlow { private Dimension pageSize = new Dimension(); private int recommendedWidth; private int pageSizeCacheKeys[] = new int[3]; private Dimension pageSizeCacheValues[] = new Dimension[3]; /** * @see org.eclipse.draw2d.Figure#addNotify() */ public void addNotify() { super.addNotify(); setValid(false); } /** * @see org.eclipse.draw2d.text.BlockFlow#createDefaultFlowLayout() */ protected FlowFigureLayout createDefaultFlowLayout() { return new PageFlowLayout(this); } /** * @see org.eclipse.draw2d.Figure#getMinimumSize(int, int) */ public Dimension getMinimumSize(int w, int h) { return getPreferredSize(w, h); } /** * @see org.eclipse.draw2d.Figure#invalidate() */ public void invalidate() { pageSizeCacheValues = new Dimension[3]; super.invalidate(); } /** * @see org.eclipse.draw2d.Figure#getPreferredSize(int, int) */ public Dimension getPreferredSize(int width, int h) { for (int i = 0; i < 3; i++) { if (pageSizeCacheKeys[i] == width && pageSizeCacheValues[i] != null) return pageSizeCacheValues[i]; } pageSizeCacheKeys[2] = pageSizeCacheKeys[1]; pageSizeCacheKeys[1] = pageSizeCacheKeys[0]; pageSizeCacheKeys[0] = width; pageSizeCacheValues[2] = pageSizeCacheValues[1]; pageSizeCacheValues[1] = pageSizeCacheValues[0]; // Flowpage must temporarily layout to determine its preferred size int oldWidth = getPageWidth(); setPageWidth(width); validate(); pageSizeCacheValues[0] = pageSize.getCopy(); if (width != oldWidth) { setPageWidth(oldWidth); getUpdateManager().addInvalidFigure(this); } return pageSizeCacheValues[0]; } int getPageWidth() { return recommendedWidth; } /** * @see BlockFlow#postValidate() */ public void postValidate() { Rectangle r = getBlockBox().toRectangle(); pageSize.width = r.width; pageSize.height = r.height; List v = getChildren(); for (int i = 0; i < v.size(); i++) ((FlowFigure) v.get(i)).postValidate(); } /** * Overridden to set valid. * * @see org.eclipse.draw2d.IFigure#removeNotify() */ public void removeNotify() { super.removeNotify(); setValid(true); } /** * @see FlowFigure#setBounds(Rectangle) */ public void setBounds(Rectangle r) { if (getBounds().equals(r)) return; boolean invalidate = getBounds().width != r.width || getBounds().height != r.height; super.setBounds(r); int newWidth = r.width; if (invalidate || getPageWidth() != newWidth) { setPageWidth(newWidth); getUpdateManager().addInvalidFigure(this); } } private void setPageWidth(int width) { if (recommendedWidth == width) return; recommendedWidth = width; super.invalidate(); } /** * @see org.eclipse.draw2d.Figure#validate() */ public void validate() { if (isValid()) return; super.validate(); postValidate(); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/FlowUtilities.java000066400000000000000000000270761166301720600301360ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.text; import com.ibm.icu.text.BreakIterator; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.graphics.TextLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.draw2d.FigureUtilities; import org.eclipse.draw2d.TextUtilities; /** * Utility class for FlowFigures. * * @author hudsonr * @since 3.4 */ public class FlowUtilities { interface LookAhead { int getWidth(); } /** * a singleton default instance */ public static FlowUtilities INSTANCE = new FlowUtilities(); private static final BreakIterator INTERNAL_LINE_BREAK = BreakIterator .getLineInstance(); private static TextLayout layout; static final BreakIterator LINE_BREAK = BreakIterator.getLineInstance(); static boolean canBreakAfter(char c) { boolean result = Character.isWhitespace(c) || c == '-'; if (!result && (c < 'a' || c > 'z')) { // chinese characters and such would be caught in here // LINE_BREAK is used here because INTERNAL_LINE_BREAK might be in // use LINE_BREAK.setText(c + "a"); //$NON-NLS-1$ result = LINE_BREAK.isBoundary(1); } return result; } private static int findFirstDelimeter(String string) { int macNL = string.indexOf('\r'); int unixNL = string.indexOf('\n'); if (macNL == -1) macNL = Integer.MAX_VALUE; if (unixNL == -1) unixNL = Integer.MAX_VALUE; return Math.min(macNL, unixNL); } /** * Gets the average character width. * * @param fragment * the supplied TextFragmentBox to use for calculation. if the * length is 0 or if the width is or below 0, the average * character width is taken from standard font metrics. * @param font * the font to use in case the TextFragmentBox conditions above * are true. * @return the average character width */ protected float getAverageCharWidth(TextFragmentBox fragment, Font font) { if (fragment.getWidth() > 0 && fragment.length != 0) return fragment.getWidth() / (float) fragment.length; return FigureUtilities.getFontMetrics(font).getAverageCharWidth(); } static int getBorderAscent(InlineFlow owner) { if (owner.getBorder() instanceof FlowBorder) { FlowBorder border = (FlowBorder) owner.getBorder(); return border.getInsets(owner).top; } return 0; } static int getBorderAscentWithMargin(InlineFlow owner) { if (owner.getBorder() instanceof FlowBorder) { FlowBorder border = (FlowBorder) owner.getBorder(); return border.getTopMargin() + border.getInsets(owner).top; } return 0; } static int getBorderDescent(InlineFlow owner) { if (owner.getBorder() instanceof FlowBorder) { FlowBorder border = (FlowBorder) owner.getBorder(); return border.getInsets(owner).bottom; } return 0; } static int getBorderDescentWithMargin(InlineFlow owner) { if (owner.getBorder() instanceof FlowBorder) { FlowBorder border = (FlowBorder) owner.getBorder(); return border.getBottomMargin() + border.getInsets(owner).bottom; } return 0; } /** * Provides a TextLayout that can be used by the Draw2d text package for * Bidi. This TextLayout should not be disposed by clients. The provided * TextLayout's orientation will be LTR. * * @return an SWT TextLayout that can be used for Bidi * @since 3.1 */ static TextLayout getTextLayout() { if (layout == null) layout = new TextLayout(Display.getDefault()); layout.setOrientation(SWT.LEFT_TO_RIGHT); return layout; } /** * @param frag * @param string * @param font * @since 3.1 */ private static void initBidi(TextFragmentBox frag, String string, Font font) { if (frag.requiresBidi()) { TextLayout textLayout = getTextLayout(); textLayout.setFont(font); // $TODO need to insert overrides in front of string. textLayout.setText(string); } } private int measureString(TextFragmentBox frag, String string, int guess, Font font) { if (frag.requiresBidi()) { // The text and/or could have changed if the lookAhead was invoked. // This will // happen at most once. return getTextLayoutBounds(string, font, 0, guess - 1).width; } else return getTextUtilities().getTextExtents( string.substring(0, guess), font).width; } /** * Sets up the fragment width based using the font and string passed in. * * @param fragment * the text fragment whose width will be set * @param font * the font to be used in the calculation * @param string * the string to be used in the calculation */ final protected void setupFragment(TextFragmentBox fragment, Font font, String string) { if (fragment.getWidth() == -1 || fragment.isTruncated()) { int width; if (string.length() == 0 || fragment.length == 0) width = 0; else if (fragment.requiresBidi()) { width = getTextLayoutBounds(string, font, 0, fragment.length - 1).width; } else width = getTextUtilities().getTextExtents( string.substring(0, fragment.length), font).width; if (fragment.isTruncated()) width += getEllipsisWidth(font); fragment.setWidth(width); } } /** * Sets up a fragment and returns the number of characters consumed from the * given String. An average character width can be provided as a hint for * faster calculation. If a fragment's bidi level is set, a TextLayout will * be used to calculate the width. * * @param frag * the TextFragmentBox * @param string * the String * @param font * the Font used for measuring * @param context * the flow context * @param wrapping * the word wrap style * @return the number of characters that will fit in the given space; can be * 0 (eg., when the first character of the given string is a * newline) */ final protected int wrapFragmentInContext(TextFragmentBox frag, String string, FlowContext context, LookAhead lookahead, Font font, int wrapping) { frag.setTruncated(false); int strLen = string.length(); if (strLen == 0) { frag.setWidth(-1); frag.length = 0; setupFragment(frag, font, string); context.addToCurrentLine(frag); return 0; } INTERNAL_LINE_BREAK.setText(string); initBidi(frag, string, font); float avgCharWidth = getAverageCharWidth(frag, font); frag.setWidth(-1); /* * Setup initial boundaries within the string. */ int absoluteMin = 0; int max, min = 1; if (wrapping == ParagraphTextLayout.WORD_WRAP_HARD) { absoluteMin = INTERNAL_LINE_BREAK.next(); while (absoluteMin > 0 && Character.isWhitespace(string.charAt(absoluteMin - 1))) absoluteMin--; min = Math.max(absoluteMin, 1); } int firstDelimiter = findFirstDelimeter(string); if (firstDelimiter == 0) min = max = 0; else max = Math.min(strLen, firstDelimiter) + 1; int availableWidth = context.getRemainingLineWidth(); int guess = 0, guessSize = 0; while (true) { if ((max - min) <= 1) { if (min == absoluteMin && context.isCurrentLineOccupied() && !context.getContinueOnSameLine() && availableWidth < measureString(frag, string, min, font) + ((min == strLen && lookahead != null) ? lookahead .getWidth() : 0)) { context.endLine(); availableWidth = context.getRemainingLineWidth(); max = Math.min(strLen, firstDelimiter) + 1; if ((max - min) <= 1) break; } else break; } // Pick a new guess size // New guess is the last guess plus the missing width in pixels // divided by the average character size in pixels guess += 0.5f + (availableWidth - guessSize) / avgCharWidth; if (guess >= max) guess = max - 1; if (guess <= min) guess = min + 1; guessSize = measureString(frag, string, guess, font); if (guess == strLen && lookahead != null && !canBreakAfter(string.charAt(strLen - 1)) && guessSize + lookahead.getWidth() > availableWidth) { max = guess; continue; } if (guessSize <= availableWidth) { min = guess; frag.setWidth(guessSize); if (guessSize == availableWidth) max = guess + 1; } else max = guess; } int result = min; boolean continueOnLine = false; if (min == strLen) { // Everything fits if (string.charAt(strLen - 1) == ' ') { if (frag.getWidth() == -1) { frag.length = result; frag.setWidth(measureString(frag, string, result, font)); } if (lookahead.getWidth() > availableWidth - frag.getWidth()) { frag.length = result - 1; frag.setWidth(-1); } else frag.length = result; } else { continueOnLine = !canBreakAfter(string.charAt(strLen - 1)); frag.length = result; } } else if (min == firstDelimiter) { // move result past the delimiter frag.length = result; if (string.charAt(min) == '\r') { result++; if (++min < strLen && string.charAt(min) == '\n') result++; } else if (string.charAt(min) == '\n') result++; } else if (string.charAt(min) == ' ' || canBreakAfter(string.charAt(min - 1)) || INTERNAL_LINE_BREAK.isBoundary(min)) { frag.length = min; if (string.charAt(min) == ' ') result++; else if (string.charAt(min - 1) == ' ') { frag.length--; frag.setWidth(-1); } } else out: { // In the middle of an unbreakable offset result = INTERNAL_LINE_BREAK.preceding(min); if (result == 0) { switch (wrapping) { case ParagraphTextLayout.WORD_WRAP_TRUNCATE: int truncatedWidth = availableWidth - getEllipsisWidth(font); if (truncatedWidth > 0) { // $TODO this is very slow. It should be using // avgCharWidth to go faster while (min > 0) { guessSize = measureString(frag, string, min, font); if (guessSize <= truncatedWidth) break; min--; } frag.length = min; } else frag.length = 0; frag.setTruncated(true); result = INTERNAL_LINE_BREAK.following(max - 1); break out; default: result = min; break; } } frag.length = result; if (string.charAt(result - 1) == ' ') frag.length--; frag.setWidth(-1); } setupFragment(frag, font, string); context.addToCurrentLine(frag); context.setContinueOnSameLine(continueOnLine); return result; } /** * @see TextLayout#getBounds() */ protected Rectangle getTextLayoutBounds(String s, Font f, int start, int end) { TextLayout textLayout = getTextLayout(); textLayout.setFont(f); textLayout.setText(s); return textLayout.getBounds(start, end); } /** * Returns an instance of a TextUtililities class on which text * calculations can be performed. Clients may override to customize. * * @return the TextUtililities instance * @since 3.4 */ protected TextUtilities getTextUtilities() { return TextUtilities.INSTANCE; } /** * Gets the ellipsis width. * * @param font * the font to be used in the calculation * @return the width of the ellipsis * @since 3.4 */ private int getEllipsisWidth(Font font) { return getTextUtilities().getTextExtents(TextFlow.ELLIPSIS, font).width; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/InlineFlow.java000066400000000000000000000124321166301720600273670ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.text; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.eclipse.swt.SWT; import org.eclipse.draw2d.Border; import org.eclipse.draw2d.ColorConstants; import org.eclipse.draw2d.Graphics; import org.eclipse.draw2d.geometry.Rectangle; /** * A FlowFigure represented by multiple LineBox * fragments. An InlineFlow's parent must be either a * {@link BlockFlow} or another InlineFlow. * *

    * An InlineFlow may contain other InlineFlow figures. * *

    * WARNING: This class is not intended to be subclassed by clients. * * @author Randy Hudson * @since 2.0 */ public class InlineFlow extends FlowFigure { List fragments = new ArrayList(1); /** * Iterates over the children to find the width before a line-break is * encountered. * * @see org.eclipse.draw2d.text.FlowFigure#addLeadingWordRequirements(int[]) */ public boolean addLeadingWordRequirements(int[] width) { Iterator iter = getChildren().iterator(); while (iter.hasNext()) { if (((FlowFigure) iter.next()).addLeadingWordRequirements(width)) return true; } return false; } /** * Extended to return false if the point is not also contained by at least * one fragment. * * @return true if a fragment contains the given point * @param x * the relative x coordinate * @param y * the relative y coordinate */ public boolean containsPoint(int x, int y) { if (super.containsPoint(x, y)) { List frags = getFragments(); for (int i = 0; i < frags.size(); i++) if (((FlowBox) frags.get(i)).containsPoint(x, y)) return true; } return false; } /** * @see FlowFigure#createDefaultFlowLayout() */ protected FlowFigureLayout createDefaultFlowLayout() { return new InlineFlowLayout(this); } /** * Returns the FlowBox fragments contained in this InlineFlow. * The returned list should not be modified. * * @return The fragments */ public List getFragments() { return fragments; } /** * Overridden to paint a {@link FlowBorder} if present, and draw selection. * The border is painted first, followed by selection which is generally * done in XOR, which still allows the border to be seen. * * @param graphics * the graphics */ protected void paintBorder(Graphics graphics) { if (getBorder() != null) { FlowBorder fb = (FlowBorder) getBorder(); List frags = getFragments(); Rectangle where = new Rectangle(); int sides; for (int i = 0; i < frags.size(); i++) { FlowBox box = (FlowBox) frags.get(i); where.x = box.getX(); where.width = box.getWidth(); where.y = -box.getAscentWithBorder(); where.height = box.getDescentWithBorder() - where.y; where.y += box.getBaseline(); sides = 0; if (i == 0) sides = SWT.LEAD; if (i == frags.size() - 1) sides |= SWT.TRAIL; fb.paint(this, graphics, where, sides); } graphics.restoreState(); } if (selectionStart != -1) paintSelection(graphics); } /** * Renders the XOR selection rectangles to the graphics. * * @param graphics * the graphics to paint on * @since 3.1 */ protected void paintSelection(Graphics graphics) { graphics.restoreState(); graphics.setXORMode(true); graphics.setBackgroundColor(ColorConstants.white); List list = getFragments(); FlowBox box; for (int i = 0; i < list.size(); i++) { box = (FlowBox) list.get(i); int top = box.getLineRoot().getVisibleTop(); int bottom = box.getLineRoot().getVisibleBottom(); graphics.fillRectangle(box.getX(), top, box.getWidth(), bottom - top); } } /** * @see FlowFigure#postValidate() */ public void postValidate() { List list = getFragments(); FlowBox box; int left = Integer.MAX_VALUE, top = left; int right = Integer.MIN_VALUE, bottom = right; for (int i = 0; i < list.size(); i++) { box = (FlowBox) list.get(i); left = Math.min(left, box.getX()); right = Math.max(right, box.getX() + box.getWidth()); top = Math.min(top, box.getLineRoot().getVisibleTop()); bottom = Math.max(bottom, box.getLineRoot().getVisibleBottom()); } setBounds(new Rectangle(left, top, right - left, bottom - top)); repaint(); list = getChildren(); for (int i = 0; i < list.size(); i++) ((FlowFigure) list.get(i)).postValidate(); } /** * Overridden to assert that only {@link FlowBorder} is used. * null is still a valid value as well. * * @param border * null or a FlowBorder */ public void setBorder(Border border) { if (border == null || border instanceof FlowBorder) super.setBorder(border); else throw new RuntimeException( "Border must be an instance of FlowBorder"); //$NON-NLS-1$ } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/InlineFlowLayout.java000066400000000000000000000067061166301720600305740ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.text; import java.util.List; /** * The layout manager for {@link InlineFlow} figures. * *

    * WARNING: This class is not intended to be subclassed by clients. * * @author hudsonr * @since 2.1 */ public class InlineFlowLayout extends FlowContainerLayout { /** * Creates a new InlineFlowLayout with the given FlowFigure. * * @param flow * The FlowFigure */ public InlineFlowLayout(FlowFigure flow) { super(flow); } /** * Adds the given box as a line below the current line. * * @param box * the box to add */ public void addLine(CompositeBox box) { endLine(); getContext().addLine(box); } /** * @see FlowContainerLayout#createNewLine() */ protected void createNewLine() { currentLine = new NestedLine((InlineFlow) getFlowFigure()); setupLine(currentLine); } /** * @see FlowContext#endLine() */ public void endLine() { flush(); getContext().endLine(); } /** * @see FlowContainerLayout#flush() */ protected void flush() { if (currentLine != null && currentLine.isOccupied()) { // We want to preserve the state when a linebox is being added boolean sameLine = getContext().getContinueOnSameLine(); getContext().addToCurrentLine(currentLine); ((InlineFlow) getFlowFigure()).getFragments().add(currentLine); currentLine = null; getContext().setContinueOnSameLine(sameLine); } } /** * InlineFlowLayout gets this information from its context. * * @see FlowContext#getContinueOnSameLine() */ public boolean getContinueOnSameLine() { return getContext().getContinueOnSameLine(); } /** * @see FlowContext#getWidthLookahead(FlowFigure, int[]) */ public void getWidthLookahead(FlowFigure child, int result[]) { List children = getFlowFigure().getChildren(); int index = -1; if (child != null) index = children.indexOf(child); for (int i = index + 1; i < children.size(); i++) if (((FlowFigure) children.get(i)) .addLeadingWordRequirements(result)) return; getContext().getWidthLookahead(getFlowFigure(), result); } /** * @see FlowContainerLayout#isCurrentLineOccupied() */ public boolean isCurrentLineOccupied() { return (currentLine != null && !currentLine.getFragments().isEmpty()) || getContext().isCurrentLineOccupied(); } /** * Clears out all fragments prior to the call to layoutChildren(). */ public void preLayout() { ((InlineFlow) getFlowFigure()).getFragments().clear(); } /** * InlineFlow passes this information to its context. * * @see FlowContext#setContinueOnSameLine(boolean) */ public void setContinueOnSameLine(boolean value) { getContext().setContinueOnSameLine(value); } /** * Initializes the given LineBox. Called by createNewLine(). * * @param line * The LineBox to initialize. */ protected void setupLine(LineBox line) { line.setX(0); line.setRecommendedWidth(getContext().getRemainingLineWidth()); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/LineBox.java000066400000000000000000000050611166301720600266610ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.text; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /** * @author hudsonr * @since 2.1 */ public abstract class LineBox extends CompositeBox { /** * The maximum ascent of all contained fragments. */ int contentAscent; /** * The maximum descent of all contained fragments. */ int contentDescent; List fragments = new ArrayList(); /** * @see org.eclipse.draw2d.text.CompositeBox#add(org.eclipse.draw2d.text.FlowBox) */ public void add(FlowBox child) { fragments.add(child); width += child.getWidth(); contentAscent = Math.max(contentAscent, child.getOuterAscent()); contentDescent = Math.max(contentDescent, child.getOuterDescent()); } /** * @see org.eclipse.draw2d.text.FlowBox#getAscent() */ public int getAscent() { int ascent = 0; for (int i = 0; i < fragments.size(); i++) ascent = Math.max(ascent, ((FlowBox) fragments.get(i)).getAscent()); return ascent; } /** * Returns the remaining width available for line content. * * @return the available width in pixels */ int getAvailableWidth() { if (recommendedWidth < 0) return Integer.MAX_VALUE; return recommendedWidth - getWidth(); } int getBottomMargin() { return 0; } /** * @see org.eclipse.draw2d.text.FlowBox#getDescent() */ public int getDescent() { int descent = 0; for (int i = 0; i < fragments.size(); i++) descent = Math.max(descent, ((FlowBox) fragments.get(i)).getDescent()); return descent; } /** * @return Returns the fragments. */ List getFragments() { return fragments; } int getTopMargin() { return 0; } /** * @return true if this box contains any fragments */ public boolean isOccupied() { return !fragments.isEmpty(); } /** * @see org.eclipse.draw2d.text.FlowBox#requiresBidi() */ public boolean requiresBidi() { for (Iterator iter = getFragments().iterator(); iter.hasNext();) { FlowBox box = (FlowBox) iter.next(); if (box.requiresBidi()) return true; } return false; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/LineRoot.java000066400000000000000000000167241166301720600270640ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.text; import java.util.ArrayList; import java.util.List; import org.eclipse.draw2d.geometry.Rectangle; /** * LineRoot is the top-most container on a line of text displayed in Draw2d. * Hence, a LineRoot can tell you of things like the highest ascent or descent * on a line, which is required to display selection and such. All * {@link org.eclipse.draw2d.text.ContentBox fragments} know of the LineRoot * they belong to. * * @author Randy Hudson * @author Pratik Shah * @since 3.1 */ public class LineRoot extends LineBox { private int baseline; private boolean isMirrored; /** * Constructor * * @param isMirrored * true if the line is to be displayed in a mirrored * control */ public LineRoot(boolean isMirrored) { this.isMirrored = isMirrored; } /** * @see org.eclipse.draw2d.text.CompositeBox#add(org.eclipse.draw2d.text.FlowBox) */ public void add(FlowBox child) { super.add(child); child.setLineRoot(this); } private void bidiCommit() { int xLocation = getX(); BidiLevelNode root = new BidiLevelNode(); List branches = new ArrayList(); // branches does not include this LineRoot; all the non-leaf child // fragments of a // parent will be listed before the parent itself in this list buildBidiTree(this, root, branches); List result = new ArrayList(); root.emit(result); int i = isMirrored ? result.size() - 1 : 0; while (i >= 0 && i < result.size()) { FlowBox box = (FlowBox) result.get(i); box.setX(xLocation); xLocation += box.getWidth(); i += isMirrored ? -1 : 1; } // set the bounds of the composite boxes, and break overlapping ones // into two layoutNestedLines(branches); } private void buildBidiTree(FlowBox box, BidiLevelNode node, List branches) { if (box instanceof LineBox) { List children = ((LineBox) box).getFragments(); for (int i = 0; i < children.size(); i++) buildBidiTree((FlowBox) children.get(i), node, branches); if (box != this) branches.add(box); } else { ContentBox leafBox = (ContentBox) box; while (leafBox.getBidiLevel() < node.level) node = node.pop(); while (leafBox.getBidiLevel() > node.level) node = node.push(); node.add(leafBox); } } /** * Committing a LineRoot will position its children correctly. All children * boxes are made to have the same baseline, and are laid out according to * the Unicode BiDi Algorithm, or left-to-right if Bidi is not necessary. */ public void commit() { if (requiresBidi()) bidiCommit(); else contiguousCommit(this, getX()); } /** * A LineRoot cannot be targetted. * * @see org.eclipse.draw2d.text.FlowBox#containsPoint(int, int) */ public boolean containsPoint(int x, int y) { return false; } /* * Simply lays out all fragments from left-to-right in the order in which * they're contained. */ private void contiguousCommit(FlowBox box, int x) { box.setX(x); if (box instanceof LineBox) { List fragments = ((LineBox) box).getFragments(); int i = isMirrored ? fragments.size() - 1 : 0; while (i >= 0 && i < fragments.size()) { FlowBox child = (FlowBox) fragments.get(i); contiguousCommit(child, x); x += child.getWidth(); i += isMirrored ? -1 : 1; } } } private Result findParent(NestedLine line, List branches, int afterIndex) { for (int i = afterIndex + 1; i < branches.size(); i++) { NestedLine box = (NestedLine) branches.get(i); int index = box.getFragments().indexOf(line); if (index >= 0) return new Result(box, index); } return new Result(this, getFragments().indexOf(line)); } /** * @see org.eclipse.draw2d.text.FlowBox#getBaseline() */ public int getBaseline() { return baseline; } LineRoot getLineRoot() { return this; } int getVisibleBottom() { return baseline + contentDescent; } int getVisibleTop() { return baseline - contentAscent; } private void layoutNestedLines(List branches) { for (int i = 0; i < branches.size(); i++) { NestedLine parent = (NestedLine) branches.get(i); FlowBox prevChild = null; Rectangle bounds = null; List frags = parent.getFragments(); for (int j = 0; j < frags.size(); j++) { FlowBox child = (FlowBox) frags.get(j); if (prevChild != null && prevChild.getX() + prevChild.width != child.getX() && child.getX() + child.width != prevChild.getX()) { // the boxes are not adjacent, and hence the parent box // needs to // be broken up InlineFlow parentFig = parent.owner; // Create and initialize a new line box NestedLine newBox = new NestedLine(parentFig); newBox.setLineRoot(this); // Add all remaining fragments from the current line box to // the new one for (int k = j; k < frags.size();) newBox.fragments.add(frags.remove(k)); // Add the new line box to the parent box's list of // fragments Result result = findParent(parent, branches, i); result.parent.getFragments().add(result.index + 1, newBox); // Add the new line box to the flow figure's list of // fragments parentFig.fragments.add( parentFig.fragments.indexOf(parent) + 1, newBox); branches.add(i + 1, newBox); break; } if (bounds == null) bounds = new Rectangle(child.getX(), 1, child.getWidth(), 1); else bounds.union(child.getX(), 1, child.getWidth(), 1); prevChild = child; } parent.setX(bounds.x); parent.setWidth(bounds.width); } } /** * Positions the line vertically by settings its baseline. * * @param baseline * the baseline */ public void setBaseline(int baseline) { this.baseline = baseline; } /** * @see org.eclipse.draw2d.text.CompositeBox#setLineTop(int) */ public void setLineTop(int top) { this.baseline = top + getAscent(); } private static class BidiLevelNode extends ArrayList { int level; final BidiLevelNode parent; BidiLevelNode() { this(null, 0); } BidiLevelNode(BidiLevelNode parent, int level) { this.parent = parent; this.level = level; } void emit(List list) { if (level % 2 == 1) { for (int i = size() - 1; i >= 0; i--) { Object child = get(i); if (child instanceof BidiLevelNode) ((BidiLevelNode) child).emit(list); else list.add(child); } } else { for (int i = 0; i < size(); i++) { Object child = get(i); if (child instanceof BidiLevelNode) ((BidiLevelNode) child).emit(list); else list.add(child); } } } BidiLevelNode pop() { return parent; } BidiLevelNode push() { if (!isEmpty()) { Object last = get(size() - 1); if (last instanceof BidiLevelNode && ((BidiLevelNode) last).level == level + 1) return (BidiLevelNode) last; } BidiLevelNode child = new BidiLevelNode(this, level + 1); add(child); return child; } } private static class Result { private int index; private LineBox parent; private Result(LineBox box, int i) { parent = box; index = i; } } }eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/NestedLine.java000066400000000000000000000053541166301720600273600ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.text; /** * @since 3.1 */ public class NestedLine extends LineBox { InlineFlow owner; private LineRoot root; NestedLine(InlineFlow owner) { this.owner = owner; } /** * @see org.eclipse.draw2d.text.FlowBox#containsPoint(int, int) */ public boolean containsPoint(int x, int y) { // $TODO should contains use LineRoot? return x >= getX() && x < getX() + getWidth() && y >= getBaseline() - getAscentWithBorder() && y < getBaseline() + getDescentWithBorder(); } int getAscentWithBorder() { return contentAscent + FlowUtilities.getBorderAscent(owner); } int getDescentWithBorder() { return contentDescent + FlowUtilities.getBorderDescent(owner); } /** * @see org.eclipse.draw2d.text.FlowBox#getBaseline() */ public int getBaseline() { return root.getBaseline(); } LineRoot getLineRoot() { return root; } // int getVisibleAscent() { // return contentAscent + FlowUtilities.getBorderAscent(owner); // } // // int getVisibleDescent() { // return contentDescent + FlowUtilities.getBorderDescent(owner); // } /** * Returns the outer ascent of this box. The outer ascent is the ascent * above the baseline including the border size and margin. This is used * when adding content into a LineBox. The linebox's own border must be * drawn around the children. * * @return the outer ascent of this box */ public int getOuterAscent() { return contentAscent + FlowUtilities.getBorderAscentWithMargin(owner); } /** * Returns the outer descent of this box. The outer descent is the space * below the baseline including the border size and margin. This is used * when adding content into a LineBox. The linebox's own border must be * drawn around the children. * * @return the outer descent of this box */ public int getOuterDescent() { return contentDescent + FlowUtilities.getBorderDescentWithMargin(owner); } void setLineRoot(LineRoot root) { this.root = root; for (int i = 0; i < fragments.size(); i++) ((FlowBox) fragments.get(i)).setLineRoot(root); } /** * @see org.eclipse.draw2d.text.CompositeBox#setLineTop(int) */ public void setLineTop(int top) { throw new RuntimeException("not supported"); //$NON-NLS-1$ } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/PageFlowLayout.java000066400000000000000000000022141166301720600302200ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.text; /** * A block layout which requires no FlowContext to perform its layout. This * class is used by {@link FlowPage}. *

    * WARNING: This class is not intended to be subclassed by clients. */ public class PageFlowLayout extends BlockFlowLayout { /** * Creates a new PageFlowLayout with the given FlowPage * * @param page * the FlowPage */ public PageFlowLayout(FlowPage page) { super(page); } /** * @see org.eclipse.draw2d.text.BlockFlowLayout#getContextWidth() */ int getContextWidth() { return ((FlowPage) getFlowFigure()).getPageWidth(); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/ParagraphTextLayout.java000066400000000000000000000141221166301720600312670ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.text; import java.util.List; import org.eclipse.swt.graphics.Font; /** * The layout for {@link TextFlow}. * * @author hudsonr * @since 2.1 */ public class ParagraphTextLayout extends TextLayout { /** * Wrapping will ONLY occur at valid line breaks */ public static final int WORD_WRAP_HARD = 0; /** * Wrapping will always occur at the end of the available space, breaking in * the middle of a word. */ public static final int WORD_WRAP_SOFT = 1; /** * Wrapping will always occur at the end of available space, truncating a * word if it doesn't fit. Note that truncation is not supported across * multiple figures and with BiDi. Undesired effects may result if that is * the case. */ public static final int WORD_WRAP_TRUNCATE = 2; private int wrappingStyle = WORD_WRAP_HARD; /** * Constructs a new ParagraphTextLayout on the specified TextFlow. * * @param flow * the TextFlow */ public ParagraphTextLayout(TextFlow flow) { super(flow); } /** * Constructs the layout with the specified TextFlow and wrapping style. The * wrapping style must be one of: *

      *
    • {@link #WORD_WRAP_HARD}
    • *
    • {@link #WORD_WRAP_SOFT}
    • *
    • {@link #WORD_WRAP_TRUNCATE}
    • *
    * * @param flow * the textflow * @param style * the style of wrapping */ public ParagraphTextLayout(TextFlow flow, int style) { this(flow); wrappingStyle = style; } /** * Given the Bidi levels of the given text, this method breaks the given * text up by its level runs. * * @param text * the String that needs to be broken up into its level runs * @param levelInfo * the Bidi levels * @return the requested segment */ private String[] getSegments(String text, int levelInfo[]) { if (levelInfo.length == 1) return new String[] { text }; String result[] = new String[levelInfo.length / 2 + 1]; int i; int endOffset; int beginOffset = 0; for (i = 0; i < result.length - 1; i++) { endOffset = levelInfo[i * 2 + 1]; result[i] = text.substring(beginOffset, endOffset); beginOffset = endOffset; } endOffset = text.length(); result[i] = text.substring(beginOffset, endOffset); return result; } class SegmentLookahead implements FlowUtilities.LookAhead { private int seg = -1; private String segs[]; private int[] width; private final int trailingBorderSize; SegmentLookahead(String segs[], int trailingBorderSize) { this.segs = segs; this.trailingBorderSize = trailingBorderSize; } public int getWidth() { if (width == null) { width = new int[1]; int startingIndex = seg + 1; TextFlow textFlow = (TextFlow) getFlowFigure(); if (startingIndex == segs.length) { width[0] += trailingBorderSize; getContext().getWidthLookahead(textFlow, width); } else { String rest = segs[startingIndex]; for (int k = startingIndex + 1; k < segs.length; k++) rest += segs[k]; if (!textFlow.addLeadingWordWidth(rest, width)) { width[0] += trailingBorderSize; getContext().getWidthLookahead(textFlow, width); } } } return width[0]; } public void setIndex(int value) { this.seg = value; width = null; } } /** * @see org.eclipse.draw2d.text.FlowFigureLayout#layout() */ protected void layout() { TextFlow textFlow = (TextFlow) getFlowFigure(); int offset = 0; FlowContext context = getContext(); List fragments = textFlow.getFragments(); Font font = textFlow.getFont(); int fragIndex = 0; int advance = 0; TextFragmentBox fragment; int levelInfo[] = (textFlow.getBidiInfo() == null) ? new int[] { -1 } : textFlow.getBidiInfo().levelInfo; String segment, segments[] = getSegments(textFlow.getText(), levelInfo); FlowBorder border = null; if (textFlow.getBorder() instanceof FlowBorder) border = (FlowBorder) textFlow.getBorder(); SegmentLookahead lookahead = new SegmentLookahead(segments, border == null ? 0 : border.getRightMargin()); int seg; if (border != null) { fragment = getFragment(fragIndex++, fragments); fragment.setBidiLevel(levelInfo[0]); fragment.setTruncated(false); fragment.offset = fragment.length = -1; fragment.setWidth(border.getLeftMargin() + border.getInsets(textFlow).left); if (context.getRemainingLineWidth() < fragment.getWidth() + lookahead.getWidth()) context.endLine(); context.addToCurrentLine(fragment); } FlowUtilities flowUtilities = textFlow.getFlowUtilities(); for (seg = 0; seg < segments.length; seg++) { segment = segments[seg]; lookahead.setIndex(seg); do { fragment = getFragment(fragIndex++, fragments); fragment.offset = offset; fragment.setBidiLevel(levelInfo[seg * 2]); advance = flowUtilities.wrapFragmentInContext(fragment, segment, context, lookahead, font, wrappingStyle); segment = segment.substring(advance); offset += advance; if ((segment.length() > 0 || fragment.length < advance) || fragment.isTruncated()) context.endLine(); } while (segment.length() > 0 || (!fragment.isTruncated() && fragment.length < advance)); } if (border != null) { fragment = getFragment(fragIndex++, fragments); fragment.setBidiLevel(levelInfo[0]); fragment.setTruncated(false); fragment.offset = fragment.length = -1; fragment.setWidth(border.getRightMargin() + border.getInsets(textFlow).right); context.addToCurrentLine(fragment); } // Remove the remaining unused fragments. while (fragIndex < fragments.size()) fragments.remove(fragments.size() - 1); } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/SimpleTextLayout.java000066400000000000000000000044471166301720600306240ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.text; import java.util.List; import org.eclipse.swt.graphics.Font; /** * @author hudsonr * @since 2.1 */ public class SimpleTextLayout extends TextLayout { private static final String[] DELIMITERS = { "\r\n", //$NON-NLS-1$ "\n", //$NON-NLS-1$ "\r" };//$NON-NLS-1$ private static int result; private static int delimeterLength; /** * Creates a new SimpleTextLayout with the given TextFlow * * @param flow * the TextFlow */ public SimpleTextLayout(TextFlow flow) { super(flow); } /** * @see org.eclipse.draw2d.text.FlowFigureLayout#layout() */ protected void layout() { TextFlow textFlow = (TextFlow) getFlowFigure(); String text = textFlow.getText(); List fragments = textFlow.getFragments(); Font font = textFlow.getFont(); TextFragmentBox fragment; int i = 0; int offset = 0; FlowUtilities flowUtilities = textFlow.getFlowUtilities(); do { nextLineBreak(text, offset); fragment = getFragment(i++, fragments); fragment.length = result - offset; fragment.offset = offset; fragment.setWidth(-1); flowUtilities.setupFragment(fragment, font, text.substring(offset, result)); getContext().addToCurrentLine(fragment); getContext().endLine(); offset = result + delimeterLength; } while (offset < text.length()); // Remove the remaining unused fragments. while (i < fragments.size()) fragments.remove(i++); } private int nextLineBreak(String text, int offset) { result = text.length(); delimeterLength = 0; int current; for (int i = 0; i < DELIMITERS.length; i++) { current = text.indexOf(DELIMITERS[i], offset); if (current != -1 && current < result) { result = current; delimeterLength = DELIMITERS[i].length(); } } return result; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/TextFlow.java000066400000000000000000000532641166301720600271050ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.text; import java.util.List; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.TextLayout; import org.eclipse.draw2d.ColorConstants; import org.eclipse.draw2d.Graphics; import org.eclipse.draw2d.TextUtilities; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; /** * An inline flow figure that renders a string of text across one or more lines. * A TextFlow cannot contain children. All InlineFlow figure's must * be parented by a FlowFigure. *

    * WARNING: This class is not intended to be subclassed by clients. * * @author hudsonr * @author Pratik Shah * @since 2.1 */ public class TextFlow extends InlineFlow { static final String ELLIPSIS = "..."; //$NON-NLS-1$ private BidiInfo bidiInfo; private int selectionEnd = -1; private String text; /** * Constructs a new TextFlow with the empty String. * * @see java.lang.Object#Object() */ public TextFlow() { this(new String()); } /** * Constructs a new TextFlow with the specified String. * * @param s * the string */ public TextFlow(String s) { text = s; } /** * Returns the width of the text until the first line-break. * * @see org.eclipse.draw2d.text.FlowFigure#addLeadingWordRequirements(int[]) */ public boolean addLeadingWordRequirements(int[] width) { return addLeadingWordWidth(getText(), width); } /** * Calculates the width taken up by the given text before a line-break is * encountered. * * @param text * the text in which the break is to be found * @param width * the width before the next line-break (if one's found; the * width of all the given text, otherwise) will be added on to * the first int in the given array * @return true if a line-break was found * @since 3.1 */ boolean addLeadingWordWidth(String text, int[] width) { if (text.length() == 0) return false; if (Character.isWhitespace(text.charAt(0))) return true; text = 'a' + text + 'a'; FlowUtilities.LINE_BREAK.setText(text); int index = FlowUtilities.LINE_BREAK.next() - 1; if (index == 0) return true; while (Character.isWhitespace(text.charAt(index))) index--; boolean result = index < text.length() - 1; // index should point to the end of the actual text (not including the // 'a' that was // appended), if there were no breaks if (index == text.length() - 1) index--; text = text.substring(1, index + 1); if (bidiInfo == null) width[0] += getTextUtilities().getTextExtents(text, getFont()).width; else { TextLayout textLayout = FlowUtilities.getTextLayout(); textLayout.setFont(getFont()); textLayout.setText(text); width[0] += textLayout.getBounds().width; } return result; } /** * A TextFlow contributes its text. * * @see org.eclipse.draw2d.text.FlowFigure#contributeBidi(org.eclipse.draw2d.text.BidiProcessor) */ protected void contributeBidi(BidiProcessor proc) { bidiInfo = null; proc.add(this, getText()); } /** * @see org.eclipse.draw2d.text.InlineFlow#createDefaultFlowLayout() */ protected FlowFigureLayout createDefaultFlowLayout() { return new ParagraphTextLayout(this); } private int findNextLineOffset(Point p, int[] trailing) { if (getBounds().bottom() <= p.y) return -1; TextFragmentBox closestBox = null; int index = 0; List fragments = getFragmentsWithoutBorder(); for (int i = fragments.size() - 1; i >= 0; i--) { TextFragmentBox box = (TextFragmentBox) fragments.get(i); if (box.getBaseline() - box.getLineRoot().getAscent() > p.y && (closestBox == null || box.getBaseline() < closestBox.getBaseline() || (box .getBaseline() == closestBox.getBaseline() && hDistanceBetween( box, p.x) < hDistanceBetween(closestBox, p.x)))) { closestBox = box; index = i; } } return findOffset(p, trailing, closestBox, index); } private int findOffset(Point p, int[] trailing, TextFragmentBox box, int boxIndex) { if (box == null) return -1; TextLayout layout = FlowUtilities.getTextLayout(); layout.setFont(getFont()); layout.setText(getBidiSubstring(box, boxIndex)); int x = p.x - box.getX(); if (isMirrored()) x = box.getWidth() - x; int layoutOffset = layout .getOffset(x, p.y - box.getTextTop(), trailing); return box.offset + layoutOffset - getBidiPrefixLength(box, boxIndex); } private int findPreviousLineOffset(Point p, int[] trailing) { if (getBounds().y > p.y) return -1; TextFragmentBox closestBox = null; int index = 0; List fragments = getFragmentsWithoutBorder(); for (int i = fragments.size() - 1; i >= 0; i--) { TextFragmentBox box = (TextFragmentBox) fragments.get(i); if (box.getBaseline() + box.getLineRoot().getDescent() < p.y && (closestBox == null || box.getBaseline() > closestBox.getBaseline() || (box .getBaseline() == closestBox.getBaseline() && hDistanceBetween( box, p.x) < hDistanceBetween(closestBox, p.x)))) { closestBox = box; index = i; } } return findOffset(p, trailing, closestBox, index); } int getAscent() { return getTextUtilities().getAscent(getFont()); } /** * Returns the BidiInfo for this figure or null. * * @return null or the info * @since 3.1 */ public BidiInfo getBidiInfo() { return bidiInfo; } private int getBidiPrefixLength(TextFragmentBox box, int index) { if (box.getBidiLevel() < 1) return 0; if (index > 0 || !bidiInfo.leadingJoiner) return 1; return 2; } /** * @param box * which fragment * @param index * the fragment index * @return the bidi string for that fragment * @since 3.1 */ protected String getBidiSubstring(TextFragmentBox box, int index) { if (box.getBidiLevel() < 1) return getText().substring(box.offset, box.offset + box.length); StringBuffer buffer = new StringBuffer(box.length + 3); buffer.append(box.isRightToLeft() ? BidiChars.RLO : BidiChars.LRO); if (index == 0 && bidiInfo.leadingJoiner) buffer.append(BidiChars.ZWJ); buffer.append(getText().substring(box.offset, box.offset + box.length)); if (index == getFragmentsWithoutBorder().size() - 1 && bidiInfo.trailingJoiner) buffer.append(BidiChars.ZWJ); return buffer.toString(); } /** * Returns the CaretInfo in absolute coordinates. The offset must be between * 0 and the length of the String being displayed. * * @since 3.1 * @param offset * the location in this figure's text * @param trailing * true if the caret is being placed after the offset * @exception IllegalArgumentException * If the offset is not between 0 and the length * of the string inclusively * @return the caret bounds relative to this figure */ public CaretInfo getCaretPlacement(int offset, boolean trailing) { if (offset < 0 || offset > getText().length()) throw new IllegalArgumentException("Offset: " + offset //$NON-NLS-1$ + " is invalid"); //$NON-NLS-1$ if (offset == getText().length()) trailing = false; List fragments = getFragmentsWithoutBorder(); int i = fragments.size(); TextFragmentBox box; do box = (TextFragmentBox) fragments.get(--i); while (offset < box.offset && i > 0); // Cannot be trailing and after the last char, so go to first char in // next box if (trailing && box.offset + box.length <= offset) { box = (TextFragmentBox) fragments.get(++i); offset = box.offset; trailing = false; } Point where = getPointInBox(box, offset, i, trailing); CaretInfo info = new CaretInfo(where.x, where.y, box.getAscent(), box.getDescent(), box.getLineRoot().getAscent(), box .getLineRoot().getDescent()); translateToAbsolute(info); return info; } Point getPointInBox(TextFragmentBox box, int offset, int index, boolean trailing) { offset -= box.offset; offset = Math.min(box.length, offset); Point result = new Point(0, box.getTextTop()); if (bidiInfo == null) { if (trailing && offset < box.length) offset++; String substring = getText().substring(box.offset, box.offset + offset); result.x = getTextUtilities().getTextExtents(substring, getFont()).width; } else { TextLayout layout = FlowUtilities.getTextLayout(); layout.setFont(getFont()); String fragString = getBidiSubstring(box, index); layout.setText(fragString); offset += getBidiPrefixLength(box, index); result.x = layout.getLocation(offset, trailing).x; if (isMirrored()) result.x = box.width - result.x; } result.x += box.getX(); return result; } int getDescent() { return getTextUtilities().getDescent(getFont()); } /** * Returns the minimum character offset which is on the given baseline * y-coordinate. The y location should be relative to this figure. The * return value will be between 0 and N-1. If no fragment is located on the * baseline, -1 is returned. * * @since 3.1 * @param baseline * the relative baseline coordinate * @return -1 or the lowest offset for the line */ public int getFirstOffsetForLine(int baseline) { TextFragmentBox box; List fragments = getFragmentsWithoutBorder(); for (int i = 0; i < fragments.size(); i++) { box = (TextFragmentBox) fragments.get(i); if (baseline == box.getBaseline()) return box.offset; } return -1; } /** * Returns the TextFragmentBox fragments contained in this * TextFlow, not including the border fragments. The returned list should * not be modified. * * @return list of fragments without the border fragments * @since 3.4 */ protected List getFragmentsWithoutBorder() { List fragments = getFragments(); if (getBorder() != null) fragments = fragments.subList(1, fragments.size() - 1); return fragments; } /** * Returns the maximum offset for a character which is on the given baseline * y-coordinate. The y location should be relative to this figure. The * return value will be between 0 and N-1. If no fragment is located on the * baseline, -1 is returned. * * @since 3.1 * @param baseline * the relative baseline coordinate * @return -1 or the highest offset at the given baseline */ public int getLastOffsetForLine(int baseline) { TextFragmentBox box; List fragments = getFragmentsWithoutBorder(); for (int i = fragments.size() - 1; i >= 0; i--) { box = (TextFragmentBox) fragments.get(i); if (baseline == box.getBaseline()) return box.offset + box.length - 1; } return -1; } /** * Returns the offset nearest the given point either up or down one line. If * no offset is found, -1 is returned. trailing[0] will be set * to 1 if the reference point is closer to the trailing edge of the offset * than it is to the leading edge. * * @since 3.1 * @param p * a reference point * @param down * true if the search is down * @param trailing * an int array * @return the next offset or -1 */ public int getNextOffset(Point p, boolean down, int[] trailing) { return down ? findNextLineOffset(p, trailing) : findPreviousLineOffset( p, trailing); } /** * Returns the next offset which is visible in at least one fragment or -1 * if there is not one. A visible offset means that the character or the one * preceding it is displayed, which implies that a caret can be positioned * at such an offset. This is useful for advancing a caret past characters * which resulted in a line wrap. * * @param offset * the reference offset * @return the next offset which is visible * @since 3.1 */ public int getNextVisibleOffset(int offset) { TextFragmentBox box; List fragments = getFragmentsWithoutBorder(); for (int i = 0; i < fragments.size(); i++) { box = (TextFragmentBox) fragments.get(i); if (box.offset + box.length <= offset) continue; return Math.max(box.offset, offset + 1); } return -1; } /** * Returns the offset of the character directly below or nearest the given * location. The point must be relative to this figure. The return value * will be between 0 and N-1. If the proximity argument is not * null, the result may also be -1 if no offset * was found within the proximity. *

    * For a typical character, the trailing argument will be filled in to * indicate whether the point is closer to the leading edge (0) or the * trailing edge (1). When the point is over a cluster composed of multiple * characters, the trailing argument will be filled with the position of the * character in the cluster that is closest to the point. *

    * If the proximity argument is not null, then the location may * be no further than the proximity given. Passing null is * equivalent to passing new * Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE). The * width field of the proximity will contain the horizontal * distance, height will contain vertical. Vertical proximity * is more important than horizontal. The returned offset is the lowest * index with minimum vertical proximity not exceeding the given limit, with * horizontal proximity not exceeding the given limit. If an offset that is * within the proximity is found, then the given Dimension will * be updated to reflect the new proximity. * * * @since 3.1 * @param p * the point relative to this figure * @param trailing * the trailing buffer * @param proximity * restricts and records the distance of the returned offset * @return the nearest offset in this figure's text */ public int getOffset(Point p, int trailing[], Dimension proximity) { if (proximity == null) proximity = new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE); TextFragmentBox closestBox = null; int index = 0; int dy; int dx; int i = 0; int size = fragments.size(); if (getBorder() instanceof FlowBorder) { i++; size--; } for (; i < size; i++) { TextFragmentBox box = (TextFragmentBox) fragments.get(i); dy = vDistanceBetween(box, p.y); if (dy > proximity.height) continue; dx = hDistanceBetween(box, p.x); if (dy == proximity.height && dx >= proximity.width) continue; proximity.height = dy; proximity.width = dx; closestBox = box; index = i; } return findOffset(p, trailing, closestBox, index); } /** * Returns the previous offset which is visible in at least one fragment or * -1 if there is not one. See {@link #getNextVisibleOffset(int)} for more. * * @param offset * a reference offset * @return -1 or the previous offset which is visible * @since 3.1 */ public int getPreviousVisibleOffset(int offset) { TextFragmentBox box; if (offset == -1) offset = Integer.MAX_VALUE; List fragments = getFragmentsWithoutBorder(); for (int i = fragments.size() - 1; i >= 0; i--) { box = (TextFragmentBox) fragments.get(i); if (box.offset >= offset) continue; return Math.min(box.offset + box.length, offset - 1); } return -1; } /** * @return the String being displayed; will not be null */ public String getText() { return text; } int getVisibleAscent() { if (getBorder() instanceof FlowBorder) { FlowBorder border = (FlowBorder) getBorder(); return border.getInsets(this).top + getAscent(); } return getAscent(); } int getVisibleDescent() { if (getBorder() instanceof FlowBorder) { FlowBorder border = (FlowBorder) getBorder(); return border.getInsets(this).bottom + getDescent(); } return getDescent(); } private int hDistanceBetween(TextFragmentBox box, int x) { if (x < box.getX()) return box.getX() - x; return Math.max(0, x - (box.getX() + box.getWidth())); } /** * Returns true if a portion if the text is truncated using * ellipses ("..."). * * @return true if the text is truncated with ellipses */ public boolean isTextTruncated() { for (int i = 0; i < fragments.size(); i++) { if (((TextFragmentBox) fragments.get(i)).isTruncated()) return true; } return false; } /** * @see org.eclipse.draw2d.Figure#paintFigure(Graphics) */ protected void paintFigure(Graphics g) { TextFragmentBox frag; g.getClip(Rectangle.SINGLETON); int yStart = Rectangle.SINGLETON.y; int yEnd = Rectangle.SINGLETON.bottom(); for (int i = 0; i < fragments.size(); i++) { frag = (TextFragmentBox) fragments.get(i); // g.drawLine(frag.getX(), frag.getLineRoot().getVisibleTop(), // frag.getWidth() + frag.getX(), // frag.getLineRoot().getVisibleTop()); // g.drawLine(frag.getX(), frag.getBaseline(), frag.getWidth() + // frag.getX(), frag.getBaseline()); if (frag.offset == -1) continue; // Loop until first visible fragment if (yStart > frag.getLineRoot().getVisibleBottom() + 1)// The + 1 is // for // disabled // text continue; // Break loop at first non-visible fragment if (yEnd < frag.getLineRoot().getVisibleTop()) break; String draw = getBidiSubstring(frag, i); if (frag.isTruncated()) draw += ELLIPSIS; if (!isEnabled()) { Color fgColor = g.getForegroundColor(); g.setForegroundColor(ColorConstants.buttonLightest); paintText(g, draw, frag.getX() + 1, frag.getBaseline() - getAscent() + 1, frag.getBidiLevel()); g.setForegroundColor(ColorConstants.buttonDarker); paintText(g, draw, frag.getX(), frag.getBaseline() - getAscent(), frag.getBidiLevel()); g.setForegroundColor(fgColor); } else { paintText(g, draw, frag.getX(), frag.getBaseline() - getAscent(), frag.getBidiLevel()); } } } /** * @see InlineFlow#paintSelection(org.eclipse.draw2d.Graphics) */ protected void paintSelection(Graphics graphics) { if (selectionStart == -1) return; graphics.setXORMode(true); graphics.setBackgroundColor(ColorConstants.white); TextFragmentBox frag; for (int i = 0; i < fragments.size(); i++) { frag = (TextFragmentBox) fragments.get(i); // Loop until first visible fragment if (frag.offset + frag.length <= selectionStart) continue; if (frag.offset > selectionEnd) return; if (selectionStart <= frag.offset && selectionEnd >= frag.offset + frag.length) { int y = frag.getLineRoot().getVisibleTop(); int height = frag.getLineRoot().getVisibleBottom() - y; graphics.fillRectangle(frag.getX(), y, frag.getWidth(), height); } else if (selectionEnd > frag.offset && selectionStart < frag.offset + frag.length) { Point p1 = getPointInBox(frag, Math.max(frag.offset, selectionStart), i, false); Point p2 = getPointInBox(frag, Math.min(frag.offset + frag.length, selectionEnd) - 1, i, true); Rectangle rect = new Rectangle(p1, p2); rect.width--; rect.y = frag.getLineRoot().getVisibleTop(); rect.height = frag.getLineRoot().getVisibleBottom() - rect.y; graphics.fillRectangle(rect); } } } protected void paintText(Graphics g, String draw, int x, int y, int bidiLevel) { if (bidiLevel == -1) { g.drawText(draw, x, y); } else { TextLayout tl = FlowUtilities.getTextLayout(); if (isMirrored()) tl.setOrientation(SWT.RIGHT_TO_LEFT); tl.setFont(g.getFont()); tl.setText(draw); g.drawTextLayout(tl, x, y); } } /** * @see org.eclipse.draw2d.text.FlowFigure#setBidiInfo(org.eclipse.draw2d.text.BidiInfo) */ public void setBidiInfo(BidiInfo info) { this.bidiInfo = info; } /** * Sets the extent of selection. The selection range is inclusive. For * example, the range [0, 0] indicates that the first character is selected. * * @param start * the start offset * @param end * the end offset * @since 3.1 */ public void setSelection(int start, int end) { boolean repaint = false; if (selectionStart == start) { if (selectionEnd == end) return; repaint = true; } else repaint = selectionStart != selectionEnd || start != end; selectionStart = start; selectionEnd = end; if (repaint) repaint(); } /** * Sets the text being displayed. The string may not be null. * * @param s * The new text */ public void setText(String s) { if (s != null && !s.equals(text)) { text = s; revalidateBidi(this); repaint(); } } /** * @see java.lang.Object#toString() */ public String toString() { return text; } private int vDistanceBetween(TextFragmentBox box, int y) { int top = box.getBaseline() - box.getLineRoot().getAscent(); if (y < top) return top - y; return Math.max(0, y - (box.getBaseline() + box.getLineRoot().getDescent())); } /** * Gets the FlowUtilities instance to be used in measurement * calculations. * * @return a FlowUtilities instance * @since 3.4 */ protected FlowUtilities getFlowUtilities() { return FlowUtilities.INSTANCE; } /** * Gets the TextUtilities instance to be used in measurement * calculations. * * @return a TextUtilities instance * @since 3.4 */ protected TextUtilities getTextUtilities() { return TextUtilities.INSTANCE; } }eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/TextFragmentBox.java000066400000000000000000000064731166301720600304120ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.text; /** * A Geometric object for representing a TextFragment region on a line of Text. */ public class TextFragmentBox extends ContentBox { /** * The fragment's length in characters. */ public int length; /** * The character offset at which this fragment begins. */ public int offset; private TextFlow textflow; private boolean truncated; /** * Creates a new TextFragmentBox for the given text flow. * * @param textflow * the text flow */ public TextFragmentBox(TextFlow textflow) { this.textflow = textflow; } /** * @see org.eclipse.draw2d.text.FlowBox#containsPoint(int, int) */ public boolean containsPoint(int x, int y) { return x >= getX() && x < getX() + getWidth() && y >= getBaseline() - getAscentWithBorder() && y <= getBaseline() + getDescentWithBorder(); } /** * Returns the textflow's font's ascent. The ascent is the same for all * fragments in a given TextFlow. * * @return the ascent */ public int getAscent() { return textflow.getAscent(); } int getAscentWithBorder() { return textflow.getAscent() + FlowUtilities.getBorderAscent(textflow); } /** * Returns the textflow's font's descent. The descent is the same for all * fragments in a given TextFlow. * * @return the descent */ public int getDescent() { return textflow.getDescent(); } int getDescentWithBorder() { return textflow.getDescent() + FlowUtilities.getBorderDescent(textflow); } int getOuterAscent() { return textflow.getAscent() + FlowUtilities.getBorderAscentWithMargin(textflow); } int getOuterDescent() { return textflow.getDescent() + FlowUtilities.getBorderDescentWithMargin(textflow); } final int getTextTop() { return getBaseline() - getAscent(); } /** * Returns true if the bidi level is odd. Right to left * fragments should be queried and rendered with the RLO control character * inserted in front. * * @return true if right-to-left * @since 3.1 */ public boolean isRightToLeft() { // -1 % 2 == -1 return getBidiLevel() % 2 == 1; } /** * Returns true if the fragment should be rendered as * truncated. * * @return true if the fragment is truncated * @since 3.1 */ public boolean isTruncated() { return truncated; } /** * Marks the fragment as having been truncated. * * @param value * true if the fragment is truncated * @since 3.1 */ public void setTruncated(boolean value) { this.truncated = value; } /** * @see java.lang.Object#toString() */ public String toString() { return "[" + offset + ", " + (offset + length) //$NON-NLS-1$ //$NON-NLS-2$ + ") = \"" + textflow.getText().substring(offset, offset + length) + '\"'; //$NON-NLS-1$ } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/TextLayout.java000066400000000000000000000025021166301720600274400ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.text; import java.util.List; /** * @author hudsonr * @since 2.1 */ public abstract class TextLayout extends FlowFigureLayout { /** * Creates a new TextLayout with the given TextFlow * * @param flow * The TextFlow */ public TextLayout(TextFlow flow) { super(flow); } /** * Reuses an existing TextFragmentBox, or creates a new one. * * @param i * the index * @param fragments * the original list of fragments * @return a TextFragmentBox */ protected TextFragmentBox getFragment(int i, List fragments) { if (fragments.size() > i) return (TextFragmentBox) fragments.get(i); TextFragmentBox box = new TextFragmentBox((TextFlow) getFlowFigure()); fragments.add(box); return box; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/text/package.html000066400000000000000000000002651166301720600267400ustar00rootroot00000000000000 Figures and support classes related to the layout and rendering of rich text. eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/widgets/000077500000000000000000000000001166301720600251365ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/widgets/ImageBorder.java000066400000000000000000000035571166301720600301730ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.widgets; import org.eclipse.swt.graphics.Image; import org.eclipse.draw2d.AbstractBorder; import org.eclipse.draw2d.Graphics; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Insets; import org.eclipse.draw2d.geometry.Rectangle; /** * @author Pratik Shah */ class ImageBorder extends AbstractBorder { /* * @TODO:Pratik Need to test this class extensively * * @TODO Test inside compound borders */ private Insets imgInsets; private Image image; private Dimension imageSize; public ImageBorder(Image image) { setImage(image); } public Insets getInsets(IFigure figure) { return imgInsets; } public Image getImage() { return image; } /** * @see org.eclipse.draw2d.AbstractBorder#getPreferredSize(org.eclipse.draw2d.IFigure) */ public Dimension getPreferredSize(IFigure f) { return imageSize; } public void paint(IFigure figure, Graphics graphics, Insets insets) { if (image == null) return; Rectangle rect = getPaintRectangle(figure, insets); int x = rect.x; int y = rect.y + (rect.height - imageSize.height) / 2; graphics.drawImage(getImage(), x, y); } public void setImage(Image img) { image = img; imageSize = new Dimension(image); imgInsets = new Insets(); imgInsets.left = imageSize.width; } } eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/widgets/MultiLineLabel.java000066400000000000000000000125411166301720600306460ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.draw2d.widgets; import org.eclipse.swt.SWT; import org.eclipse.swt.accessibility.ACC; import org.eclipse.swt.accessibility.AccessibleAdapter; import org.eclipse.swt.accessibility.AccessibleControlAdapter; import org.eclipse.swt.accessibility.AccessibleControlEvent; import org.eclipse.swt.accessibility.AccessibleEvent; import org.eclipse.swt.events.KeyAdapter; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Composite; import org.eclipse.draw2d.Border; import org.eclipse.draw2d.ColorConstants; import org.eclipse.draw2d.FigureCanvas; import org.eclipse.draw2d.FocusEvent; import org.eclipse.draw2d.Graphics; import org.eclipse.draw2d.MarginBorder; import org.eclipse.draw2d.Viewport; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.text.FlowPage; import org.eclipse.draw2d.text.TextFlow; /** * A widget for displaying a multi-line string. The label will have a vertical * or horizontal scrollbar when needed. Unlike the platform Label, this label is * focusable and accessible to screen-readers. * * @author hudsonr */ public final class MultiLineLabel extends FigureCanvas { private TextFlow textFlow; static final Border MARGIN = new MarginBorder(2); private Image image; class FocusableViewport extends Viewport { FocusableViewport() { super(true); setFocusTraversable(true); setBorder(MARGIN); } public void handleFocusGained(FocusEvent event) { super.handleFocusGained(event); repaint(); } public void handleFocusLost(FocusEvent event) { super.handleFocusLost(event); repaint(); } protected void paintBorder(Graphics graphics) { super.paintBorder(graphics); if (hasFocus()) { graphics.setForegroundColor(ColorConstants.black); graphics.setBackgroundColor(ColorConstants.white); graphics.drawFocus(getBounds().getResized(-1, -1)); } } } /** * Constructs a new MultiLineLabel with the given parent. * * @param parent * the parent */ public MultiLineLabel(Composite parent) { super(parent); setViewport(new FocusableViewport()); FlowPage page = new FlowPage(); textFlow = new TextFlow(); page.add(textFlow); setContents(page); getViewport().setContentsTracksWidth(true); addAccessibility(); } private void addAccessibility() { getAccessible().addAccessibleControlListener( new AccessibleControlAdapter() { public void getRole(AccessibleControlEvent e) { e.detail = ACC.ROLE_LABEL; } public void getState(AccessibleControlEvent e) { e.detail = ACC.STATE_READONLY; } }); getAccessible().addAccessibleListener(new AccessibleAdapter() { public void getName(AccessibleEvent e) { e.result = getText(); } }); addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { Point p = getViewport().getViewLocation(); int dy = getFont().getFontData()[0].getHeight(); int dx = dy * 3 / 2; boolean mirrored = (e.widget.getStyle() & SWT.MIRRORED) != 0; if (e.keyCode == SWT.ARROW_DOWN) { scrollToY(p.y + dy / 2); scrollToY(p.y + dy); scrollToY(p.y + dy * 3 / 2); scrollToY(p.y + dy * 2); } else if (e.keyCode == SWT.ARROW_UP) { scrollToY(p.y - dy / 2); scrollToY(p.y - dy); scrollToY(p.y - dy * 3 / 2); scrollToY(p.y - dy * 2); } else if ((!mirrored && e.keyCode == SWT.ARROW_RIGHT) || (mirrored && e.keyCode == SWT.ARROW_LEFT)) { scrollToX(p.x + dx); scrollToX(p.x + dx * 2); scrollToX(p.x + dx * 3); } else if ((!mirrored && e.keyCode == SWT.ARROW_LEFT) || (mirrored && e.keyCode == SWT.ARROW_RIGHT)) { scrollToX(p.x - dx); scrollToX(p.x - dx * 2); scrollToX(p.x - dx * 3); } } }); } /** * @see org.eclipse.swt.widgets.Control#setEnabled(boolean) */ public void setEnabled(boolean enabled) { super.setEnabled(enabled); textFlow.setEnabled(getEnabled()); } /** * @return the Image for this label, or null if there is none * @see #setImage(Image) */ public Image getImage() { return image; } /** * Returns the text in this label. * * @return the text */ public String getText() { return textFlow.getText(); } /** * @see org.eclipse.swt.widgets.Canvas#setFont(org.eclipse.swt.graphics.Font) */ public void setFont(Font font) { super.setFont(font); textFlow.revalidate(); } /** * @param image * The Image to be used for this label. It can be * null. */ public void setImage(Image image) { this.image = image; if (image != null) setBorder(new ImageBorder(image)); else setBorder(null); } /** * Sets the text for this label. * * @param text * the new text */ public void setText(String text) { textFlow.setText(text); } }eclipse-gef-3.7.1/org.eclipse.draw2d/src/org/eclipse/draw2d/widgets/package.html000066400000000000000000000002321166301720600274140ustar00rootroot00000000000000 Custom SWT Controls which use figures internally. eclipse-gef-3.7.1/org.eclipse.draw2d/src/overview.html000066400000000000000000000006121166301720600226250ustar00rootroot00000000000000

    The Draw2d API Specification

    eclipse-gef-3.7.1/org.eclipse.gef-feature/000077500000000000000000000000001166301720600203125ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.gef-feature/.project000066400000000000000000000005721166301720600217650ustar00rootroot00000000000000 org.eclipse.gef.feature org.eclipse.pde.FeatureBuilder org.eclipse.pde.FeatureNature eclipse-gef-3.7.1/org.eclipse.gef-feature/build.properties000066400000000000000000000015471166301720600235360ustar00rootroot00000000000000############################################################################### # Copyright (c) 2007, 2009 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # # Contributors: # IBM Corporation - initial API and implementation ############################################################################### bin.includes = epl-v10.html,\ feature.xml,\ feature.properties,\ eclipse_update_120.jpg,\ license.html root=rootfiles src.includes = eclipse_update_120.jpg,\ epl-v10.html,\ feature.properties,\ feature.xml,\ license.html eclipse-gef-3.7.1/org.eclipse.gef-feature/eclipse_update_120.jpg000066400000000000000000000522771166301720600244010ustar00rootroot00000000000000JFIFHHExifMM*bj(1r2iHHAdobe Photoshop CS Windows2005:06:17 09:55:47xx&(.kHHJFIFHH Adobe_CMAdobed            xx"?   3!1AQa"q2B#$Rb34rC%Scs5&DTdE£t6UeuF'Vfv7GWgw5!1AQaq"2B#R3$brCScs4%&5DTdEU6teuFVfv'7GWgw ?I!")Jh*AZRRʉi *d!I$JRI$I$$I)I!"U6PKtwpWOdؕpCfS%*^; vxmgEml>Klz DFWioZMԒqv 5'.'I4򠅖6yU?I| 2(e>s<;B]NI潡2:rI$S8m>#&fXC Lqi@#vJ:+P%q>[hk?IŽqoMWZ\Q7"ʡuQS6㪵}*R AIJK) qOw௬PF(K^HuJI)LJ_-ExKF)&ۺ^"ւ8gou@g>i?><#ɾE*12˿yڕ2R.P%Klz DFWioZMԒqv 5'.'I4򠅖6yU?I| 2(e>s<;B]NI潡2:rI$S8m>#&fXC Lqi@#vJ:+P%q>[hk?IŽqoMWZ\Q7"ʡuQS6㪵}*R AIJK) qOw௬PF(K^HuJI)LJ_-ExKF)&ۺ^"ւ8gou@g>i?><#ɾE*12˿yڕ2R.P% 1 120 120 1 72/1 72/1 2 2005-06-17T09:55:47-05:00 2005-06-17T09:55:47-05:00 2005-06-17T09:55:47-05:00 Adobe Photoshop CS Windows adobe:docid:photoshop:5dd9930e-df37-11d9-b295-daca1d068cfc image/jpeg XICC_PROFILE HLinomntrRGB XYZ  1acspMSFTIEC sRGB-HP cprtP3desclwtptbkptrXYZgXYZ,bXYZ@dmndTpdmddvuedLview$lumimeas $tech0 rTRC< gTRC< bTRC< textCopyright (c) 1998 Hewlett-Packard CompanydescsRGB IEC61966-2.1sRGB IEC61966-2.1XYZ QXYZ XYZ o8XYZ bXYZ $descIEC http://www.iec.chIEC http://www.iec.chdesc.IEC 61966-2.1 Default RGB colour space - sRGB.IEC 61966-2.1 Default RGB colour space - sRGBdesc,Reference Viewing Condition in IEC61966-2.1,Reference Viewing Condition in IEC61966-2.1view_. \XYZ L VPWmeassig CRT curv #(-27;@EJOTY^chmrw| %+28>ELRY`gnu| &/8AKT]gqz !-8COZfr~ -;HUcq~ +:IXgw'7HYj{+=Oat 2FZn  % : O d y  ' = T j " 9 Q i  * C \ u & @ Z t .Id %A^z &Ca~1Om&Ed#Cc'Ij4Vx&IlAe@e Ek*Qw;c*R{Gp@j>i  A l !!H!u!!!"'"U"""# #8#f###$$M$|$$% %8%h%%%&'&W&&&''I'z''( (?(q(())8)k))**5*h**++6+i++,,9,n,,- -A-v--..L.../$/Z///050l0011J1112*2c223 3F3334+4e4455M555676r667$7`7788P8899B999:6:t::;-;k;;<' >`>>?!?a??@#@d@@A)AjAAB0BrBBC:C}CDDGDDEEUEEF"FgFFG5G{GHHKHHIIcIIJ7J}JK KSKKL*LrLMMJMMN%NnNOOIOOP'PqPQQPQQR1R|RSS_SSTBTTU(UuUVV\VVWDWWX/X}XYYiYZZVZZ[E[[\5\\]']x]^^l^__a_``W``aOaabIbbcCccd@dde=eef=ffg=ggh?hhiCiijHjjkOkklWlmm`mnnknooxop+ppq:qqrKrss]sttptu(uuv>vvwVwxxnxy*yyzFz{{c{|!||}A}~~b~#G k͂0WGrׇ;iΉ3dʋ0cʍ1fΏ6n֑?zM _ɖ4 uL$h՛BdҞ@iءG&vVǥ8nRĩ7u\ЭD-u`ֲK³8%yhYѹJº;.! zpg_XQKFAǿ=ȼ:ɹ8ʷ6˶5̵5͵6ζ7ϸ9к<Ѿ?DINU\dlvۀ܊ݖޢ)߯6DScs 2F[p(@Xr4Pm8Ww)KmAdobed@xx     u!"1A2# QBa$3Rqb%C&4r 5'S6DTsEF7Gc(UVWdte)8fu*9:HIJXYZghijvwxyzm!1"AQ2aqB#Rb3 $Cr4%ScD&5T6Ed' sFtUeuV7)(GWf8vgwHXhx9IYiy*:JZjz ?aɰ?A{ߺ\ ?݂1*h=onS>T.T.U׺u{{^׺u{{^Щ$̓ P]Y*ǾP6Uzz /YZVAZ U>})kbG8"F*UksnG!@^H]:QpߏX?.ecqæ|#E5rK{'I$:Lu߿u{{^׺u{{^ѩ_>c54S9WCˋ?*FVnаT ]G"Z9t?4`$%t,ުU_k ު.L=*;W#M{a7'Wҝܵ䊓]V 5MH{\fxMpFaoWgulJ},~UM H! f;8T=E>^?sVnp@I7]UqmIB~tI.Jg4`OdtKwoPWR<W3]?jgtqzS%\ OTrWcſ&KG'(?Imp<^ Q{ID#\@GOcЕtjֹ @,"WzV!]Y.-æTWЋ:ߺ^׽uҩ9.x#q ipeܑã(F0--e,ORGR>}* "8GSc8֨zuy,POu[tr^iX\-LcT!*2S@t.H}}2l?o_oUb#+T Jt 8AG$dϯGW[*6 j7ΩqgfydbڞF.ͽybO7;<#cĜTiE?PO5{OD+M_s(#?m=XX]CS G)7އt>#nyi2.Ot!5JX?EI>2[wC^c7:0bJ~߷|nJ/CMT%U\bH'P*AV +qȓ"UCFQSzuӬ{[)œQ`uM8*=%P֨='xm N")O}C"@?^TQJFú n udtȺO_Judž\icل Iꥦt~yPOG{n%kЖjtHqP?y~gV~ݨvV*9d @T D$ymWKvԀ:I1ts4T qVTVn)9?{Qj::έ $QuInW3_7?텽@\Sg_O?8HIo?Ӑ OX'=)AQLp~!JCOTvbc&?2;z(X莱nlM_H )!g˯^Y~|ǘ7=rA{ԩFPASBYU8څZiݔ^dtomw,D!-&7) x[']R4i%752{y6%Gˡ/bd c$Zr6T^HּBB,HA#H>;܅z1kyny3| 3$j4+ݚ]DRykܛ9؊Y@~9-S}E[xFw9kNJ'ra%r9c o8$噹7>}['y@(V?ɷoi}D ?S??J"ңb[Ey`_ i_5gU@N>9P#\,Κ }gոmtH5-@ p?>?ν-Aթo}1R58oCNG[7UNZ*ҶU_On 0ǯSO6Zw ¹iBct!B'JZN8ApƴJ@DJq?Ýd[[Zjc?DbgpouqZBq8v#+9$CG~?n]6b};sX6{ǤRē7˴ZaI ޑ9bo<~ğv$^OϬ6-{DƤҴC[EFckSӀpbumo }K",iSJWђ (l 8RS֪44.>y;c FtE-D/N۟t=z ֬ ÌU*l\M>cDq=76o׵Ay@=x.o4 ^;XYVcƻ+S%2- $de<tjSPr ҟχEV] ִC"3"TA_{-ܟ '=ά2mo]-k_֔QOu upkt=QӏIݏ?T%gg=Ǧ)%.~}q괯Qi_Ii}XLiLGp/o?>16767W'~<ߟ'lt.F:s?w!PsфKR:S( [kqkҲB|:~`¾?vȿ\9M\z?=]>n?sAשo}8@S`K}l,ea#R.>~D-7z_0k-ȞH>z4/fϝ⥃w1WM;"Y:xj#/oWdĕ%mh-:S}\햗h܃0+Mg>u{YO^|IѰm6C(8q{s~=W)k?7^厢spit?ub28Qcp:UtFXsTFGϬf' 'I7zn~JeQib{Cjd;U0}K4nOљ:tKЩVfA$, zVᎃ3'kf+ ڨ"x{L?~΄v0 ⃡7Ng2fZG>HO)1@'Ldoтҿ>=b65'D]X?gN;gGG3BXڂy>45ţ,/Ϸ!6Bx;6˫&ˏ?˭_;i&m$ԓQV,ѴSE7n~~u/_[:^zoyx_kÏNǩȽw6Vr MՖAU?0z _сt&ѬMՎD4sJmH} xW\PQ3޾A )~Xdr4xɱK U;I  Z#pm@˨Qtra? k'm\,yH#uRqoׂ| *no~-Eiӂ2i^<JܟZˮ/0j$^j5#?'S5{Ztc :GϤc-$NY}/.\=?t^UvM嚧a^(LnE )7N$b(Ao&z?貯X&ndЪ:=ˠ}aIҩaŭǾdק wS`jx,G(K#\ !Bƃ = UvpRJ%sisQ!E $d\bۚV%guЧu)NOXUT}P!pQa h-2 9p,mo ">_}z6dE|ET^j \y!\nE462)|,D&K) gd O: .O5],%|N2ݻ-QXzeM<4c`FR5[ ǰ=nGEw[]Ք%Xzf?dģzpHUM\\N!'#[9p?ޭ;uZ7UgQzKeR噏*I7kצ P3Љ>?nMSo~CY2"Q%.w:D$G ;PUrǷđhmkI'ʜcSM *Qu0AARbTtmQRƱS¡c(<}v±Ơ*`:&zkI iDwөo}1f G$&?$_N[wTAV= FhS<%*7Lvs&:6כKc϶]Ml-cQM#K`)J kpDKS(*o~}:#I=Ei*H 1ֺԩZYH FG Qs Mz "3U'RO^:S2чozUz=El[Pܑ:C-DJM#K<^I\ܟtW.jz6Ѳta)-P)ҧ3?1o?۪h Wj}zY\vAb#Wi7?װDtaN:ǚ1St4پ?_zOul7G>K>.re}Ϸ>g&?SY{BDֹy\ڕON&}7;>"Ӣz>龽{խ8q_Ffb %n c IH" NI,I44JI'ɯL9ꀑé0y5eP?<=O!KR1hyZiZQ[ ty5SJQ>1]ԥ<. #6_?zV'G"駼'ϨrUoŏI.׷><>*VrzS{^׺eclipse-gef-3.7.1/org.eclipse.gef-feature/epl-v10.html000066400000000000000000000402301166301720600223630ustar00rootroot00000000000000 Eclipse Public License - Version 1.0

    Eclipse Public License - v 1.0

    THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.

    1. DEFINITIONS

    "Contribution" means:

    a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
    b) in the case of each subsequent Contributor:

    i) changes to the Program, and

    ii) additions to the Program;

    where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.

    "Contributor" means any person or entity that distributes the Program.

    "Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.

    "Program" means the Contributions distributed in accordance with this Agreement.

    "Recipient" means anyone who receives the Program under this Agreement, including all Contributors.

    2. GRANT OF RIGHTS

    a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.

    b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.

    c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.

    d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.

    3. REQUIREMENTS

    A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:

    a) it complies with the terms and conditions of this Agreement; and

    b) its license agreement:

    i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;

    ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;

    iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and

    iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.

    When the Program is made available in source code form:

    a) it must be made available under this Agreement; and

    b) a copy of this Agreement must be included with each copy of the Program.

    Contributors may not remove or alter any copyright notices contained within the Program.

    Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.

    4. COMMERCIAL DISTRIBUTION

    Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.

    For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.

    5. NO WARRANTY

    EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.

    6. DISCLAIMER OF LIABILITY

    EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

    7. GENERAL

    If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.

    If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.

    All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.

    Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.

    This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.

     

    eclipse-gef-3.7.1/org.eclipse.gef-feature/feature.properties000066400000000000000000000240431166301720600240660ustar00rootroot00000000000000############################################################################### # Copyright (c) 2003, 2010 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # # Contributors: # IBM Corporation - initial API and implementation ############################################################################### # feature.properties # contains externalized strings for feature.xml # "%foo" in feature.xml corresponds to the key "foo" in this file # java.io.Properties file (ISO 8859-1 with "\" escapes) # This file should be translated. # "featureName" property - name of the feature featureName=Graphical Editing Framework GEF # "providerName" property - name of the company that provides the feature providerName=Eclipse Modeling Project # "updateSiteName" property - label for the update site updateSiteName=Graphical Editing Framework (GEF) Update Site # "description" property - description of the feature description=Graphical Editing Framework GEF # "licenseURL" property - URL of the "Feature License" # do not translate value - just change to point to a locale-specific HTML page licenseURL=license.html # "copyright" property - text of the "Feature Update Copyright" copyright=\ Copyright (c) 2000, 2009 IBM Corporation and others.\n\ All rights reserved. This program and the accompanying materials\n\ are made available under the terms of the Eclipse Public License v1.0\n\ which accompanies this distribution, and is available at\n\ http://www.eclipse.org/legal/epl-v10.html\n\ \n\ Contributors:\n\ IBM Corporation - initial API and implementation\n ################ end of copyright property #################################### # "license" property - text of the "Feature Update License" # should be plain text version of license agreement pointed to be "licenseURL" license=\ Eclipse Foundation Software User Agreement\n\ February 1, 2011\n\ \n\ Usage Of Content\n\ \n\ THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\ OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\ USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\ AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\ NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\ AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\ AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\ OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\ TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\ OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\ BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\ \n\ Applicable Licenses\n\ \n\ Unless otherwise indicated, all Content made available by the\n\ Eclipse Foundation is provided to you under the terms and conditions of\n\ the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is\n\ provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\ For purposes of the EPL, "Program" will mean the Content.\n\ \n\ Content includes, but is not limited to, source code, object code,\n\ documentation and other files maintained in the Eclipse Foundation source code\n\ repository ("Repository") in software modules ("Modules") and made available\n\ as downloadable archives ("Downloads").\n\ \n\ - Content may be structured and packaged into modules to facilitate delivering,\n\ extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\ plug-in fragments ("Fragments"), and features ("Features").\n\ - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java(TM) ARchive)\n\ in a directory named "plugins".\n\ - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\ Each Feature may be packaged as a sub-directory in a directory named "features".\n\ Within a Feature, files named "feature.xml" may contain a list of the names and version\n\ numbers of the Plug-ins and/or Fragments associated with that Feature.\n\ - Features may also include other Features ("Included Features"). Within a Feature, files\n\ named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\ \n\ The terms and conditions governing Plug-ins and Fragments should be\n\ contained in files named "about.html" ("Abouts"). The terms and\n\ conditions governing Features and Included Features should be contained\n\ in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\ Licenses may be located in any directory of a Download or Module\n\ including, but not limited to the following locations:\n\ \n\ - The top-level (root) directory\n\ - Plug-in and Fragment directories\n\ - Inside Plug-ins and Fragments packaged as JARs\n\ - Sub-directories of the directory named "src" of certain Plug-ins\n\ - Feature directories\n\ \n\ Note: if a Feature made available by the Eclipse Foundation is installed using the\n\ Provisioning Technology (as defined below), you must agree to a license ("Feature \n\ Update License") during the installation process. If the Feature contains\n\ Included Features, the Feature Update License should either provide you\n\ with the terms and conditions governing the Included Features or inform\n\ you where you can locate them. Feature Update Licenses may be found in\n\ the "license" property of files named "feature.properties" found within a Feature.\n\ Such Abouts, Feature Licenses, and Feature Update Licenses contain the\n\ terms and conditions (or references to such terms and conditions) that\n\ govern your use of the associated Content in that directory.\n\ \n\ THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER\n\ TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\ SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\ \n\ - Eclipse Distribution License Version 1.0 (available at http://www.eclipse.org/licenses/edl-v1.0.html)\n\ - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\ - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\ - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\ - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\ - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\ \n\ IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\ TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License\n\ is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\ govern that particular Content.\n\ \n\ \n\Use of Provisioning Technology\n\ \n\ The Eclipse Foundation makes available provisioning software, examples of which include,\n\ but are not limited to, p2 and the Eclipse Update Manager ("Provisioning Technology") for\n\ the purpose of allowing users to install software, documentation, information and/or\n\ other materials (collectively "Installable Software"). This capability is provided with\n\ the intent of allowing such users to install, extend and update Eclipse-based products.\n\ Information about packaging Installable Software is available at\n\ http://eclipse.org/equinox/p2/repository_packaging.html ("Specification").\n\ \n\ You may use Provisioning Technology to allow other parties to install Installable Software.\n\ You shall be responsible for enabling the applicable license agreements relating to the\n\ Installable Software to be presented to, and accepted by, the users of the Provisioning Technology\n\ in accordance with the Specification. By using Provisioning Technology in such a manner and\n\ making it available in accordance with the Specification, you further acknowledge your\n\ agreement to, and the acquisition of all necessary rights to permit the following:\n\ \n\ 1. A series of actions may occur ("Provisioning Process") in which a user may execute\n\ the Provisioning Technology on a machine ("Target Machine") with the intent of installing,\n\ extending or updating the functionality of an Eclipse-based product.\n\ 2. During the Provisioning Process, the Provisioning Technology may cause third party\n\ Installable Software or a portion thereof to be accessed and copied to the Target Machine.\n\ 3. Pursuant to the Specification, you will provide to the user the terms and conditions that\n\ govern the use of the Installable Software ("Installable Software Agreement") and such\n\ Installable Software Agreement shall be accessed from the Target Machine in accordance\n\ with the Specification. Such Installable Software Agreement must inform the user of the\n\ terms and conditions that govern the Installable Software and must solicit acceptance by\n\ the end user in the manner prescribed in such Installable Software Agreement. Upon such\n\ indication of agreement by the user, the provisioning Technology will complete installation\n\ of the Installable Software.\n\ \n\ Cryptography\n\ \n\ Content may contain encryption software. The country in which you are\n\ currently may have restrictions on the import, possession, and use,\n\ and/or re-export to another country, of encryption software. BEFORE\n\ using any encryption software, please check the country's laws,\n\ regulations and policies concerning the import, possession, or use, and\n\ re-export of encryption software, to see if this is permitted.\n\ \n\ Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.\n ########### end of license property ########################################## eclipse-gef-3.7.1/org.eclipse.gef-feature/feature.xml000066400000000000000000000031031166301720600224640ustar00rootroot00000000000000 %description %copyright %license eclipse-gef-3.7.1/org.eclipse.gef-feature/license.html000066400000000000000000000220161166301720600226230ustar00rootroot00000000000000 Eclipse Foundation Software User Agreement

    Eclipse Foundation Software User Agreement

    February 1, 2011

    Usage Of Content

    THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.

    Applicable Licenses

    Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, "Program" will mean the Content.

    Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse Foundation source code repository ("Repository") in software modules ("Modules") and made available as downloadable archives ("Downloads").

    • Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"), plug-in fragments ("Fragments"), and features ("Features").
    • Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java™ ARchive) in a directory named "plugins".
    • A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Each Feature may be packaged as a sub-directory in a directory named "features". Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of the Plug-ins and/or Fragments associated with that Feature.
    • Features may also include other Features ("Included Features"). Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of Included Features.

    The terms and conditions governing Plug-ins and Fragments should be contained in files named "about.html" ("Abouts"). The terms and conditions governing Features and Included Features should be contained in files named "license.html" ("Feature Licenses"). Abouts and Feature Licenses may be located in any directory of a Download or Module including, but not limited to the following locations:

    • The top-level (root) directory
    • Plug-in and Fragment directories
    • Inside Plug-ins and Fragments packaged as JARs
    • Sub-directories of the directory named "src" of certain Plug-ins
    • Feature directories

    Note: if a Feature made available by the Eclipse Foundation is installed using the Provisioning Technology (as defined below), you must agree to a license ("Feature Update License") during the installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or inform you where you can locate them. Feature Update Licenses may be found in the "license" property of files named "feature.properties" found within a Feature. Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in that directory.

    THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):

    IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License is provided, please contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.

    Use of Provisioning Technology

    The Eclipse Foundation makes available provisioning software, examples of which include, but are not limited to, p2 and the Eclipse Update Manager ("Provisioning Technology") for the purpose of allowing users to install software, documentation, information and/or other materials (collectively "Installable Software"). This capability is provided with the intent of allowing such users to install, extend and update Eclipse-based products. Information about packaging Installable Software is available at http://eclipse.org/equinox/p2/repository_packaging.html ("Specification").

    You may use Provisioning Technology to allow other parties to install Installable Software. You shall be responsible for enabling the applicable license agreements relating to the Installable Software to be presented to, and accepted by, the users of the Provisioning Technology in accordance with the Specification. By using Provisioning Technology in such a manner and making it available in accordance with the Specification, you further acknowledge your agreement to, and the acquisition of all necessary rights to permit the following:

    1. A series of actions may occur ("Provisioning Process") in which a user may execute the Provisioning Technology on a machine ("Target Machine") with the intent of installing, extending or updating the functionality of an Eclipse-based product.
    2. During the Provisioning Process, the Provisioning Technology may cause third party Installable Software or a portion thereof to be accessed and copied to the Target Machine.
    3. Pursuant to the Specification, you will provide to the user the terms and conditions that govern the use of the Installable Software ("Installable Software Agreement") and such Installable Software Agreement shall be accessed from the Target Machine in accordance with the Specification. Such Installable Software Agreement must inform the user of the terms and conditions that govern the Installable Software and must solicit acceptance by the end user in the manner prescribed in such Installable Software Agreement. Upon such indication of agreement by the user, the provisioning Technology will complete installation of the Installable Software.

    Cryptography

    Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to see if this is permitted.

    Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.

    eclipse-gef-3.7.1/org.eclipse.gef-feature/rootfiles/000077500000000000000000000000001166301720600223205ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.gef-feature/rootfiles/epl-v10.html000066400000000000000000000402301166301720600243710ustar00rootroot00000000000000 Eclipse Public License - Version 1.0

    Eclipse Public License - v 1.0

    THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.

    1. DEFINITIONS

    "Contribution" means:

    a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
    b) in the case of each subsequent Contributor:

    i) changes to the Program, and

    ii) additions to the Program;

    where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.

    "Contributor" means any person or entity that distributes the Program.

    "Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.

    "Program" means the Contributions distributed in accordance with this Agreement.

    "Recipient" means anyone who receives the Program under this Agreement, including all Contributors.

    2. GRANT OF RIGHTS

    a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.

    b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.

    c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.

    d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.

    3. REQUIREMENTS

    A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:

    a) it complies with the terms and conditions of this Agreement; and

    b) its license agreement:

    i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;

    ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;

    iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and

    iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.

    When the Program is made available in source code form:

    a) it must be made available under this Agreement; and

    b) a copy of this Agreement must be included with each copy of the Program.

    Contributors may not remove or alter any copyright notices contained within the Program.

    Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.

    4. COMMERCIAL DISTRIBUTION

    Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.

    For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.

    5. NO WARRANTY

    EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.

    6. DISCLAIMER OF LIABILITY

    EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

    7. GENERAL

    If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.

    If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.

    All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.

    Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.

    This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.

     

    eclipse-gef-3.7.1/org.eclipse.gef-feature/rootfiles/notice.html000066400000000000000000000135641166301720600245000ustar00rootroot00000000000000 Eclipse.org Software User Agreement

    Eclipse Foundation Software User Agreement

    January 28, 2005

    Usage Of Content

    THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.

    Applicable Licenses

    Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, "Program" will mean the Content.

    Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse.org CVS repository ("Repository") in CVS modules ("Modules") and made available as downloadable archives ("Downloads").

    Content may be apportioned into plug-ins ("Plug-ins"), plug-in fragments ("Fragments"), and features ("Features"). A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Files named "feature.xml" may contain a list of the names and version numbers of the Plug-ins and/or Fragments associated with a Feature. Plug-ins and Fragments are located in directories named "plugins" and Features are located in directories named "features".

    Features may also include other Features ("Included Features"). Files named "feature.xml" may contain a list of the names and version numbers of Included Features.

    The terms and conditions governing Plug-ins and Fragments should be contained in files named "about.html" ("Abouts"). The terms and conditions governing Features and Included Features should be contained in files named "license.html" ("Feature Licenses"). Abouts and Feature Licenses may be located in any directory of a Download or Module including, but not limited to the following locations:

    • The top-level (root) directory
    • Plug-in and Fragment directories
    • Subdirectories of the directory named "src" of certain Plug-ins
    • Feature directories

    Note: if a Feature made available by the Eclipse Foundation is installed using the Eclipse Update Manager, you must agree to a license ("Feature Update License") during the installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or inform you where you can locate them. Feature Update Licenses may be found in the "license" property of files named "feature.properties". Such Abouts, Feature Licenses and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in that directory.

    THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):

    IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License or Feature Update License is provided, please contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.

    Cryptography

    Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to see if this is permitted.

    eclipse-gef-3.7.1/org.eclipse.gef-feature/sourceTemplateFeature/000077500000000000000000000000001166301720600246225ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.gef-feature/sourceTemplateFeature/build.properties000066400000000000000000000015471166301720600300460ustar00rootroot00000000000000############################################################################### # Copyright (c) 2003, 2009 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # # Contributors: # IBM Corporation - initial API and implementation ############################################################################### bin.includes = epl-v10.html,\ feature.xml,\ feature.properties,\ eclipse_update_120.jpg,\ license.html src.includes = epl-v10.html,\ feature.xml,\ feature.properties,\ eclipse_update_120.jpg,\ license.html eclipse-gef-3.7.1/org.eclipse.gef-feature/sourceTemplateFeature/eclipse_update_120.jpg000066400000000000000000000522771166301720600307110ustar00rootroot00000000000000JFIFHHExifMM*bj(1r2iHHAdobe Photoshop CS Windows2005:06:17 09:55:47xx&(.kHHJFIFHH Adobe_CMAdobed            xx"?   3!1AQa"q2B#$Rb34rC%Scs5&DTdE£t6UeuF'Vfv7GWgw5!1AQaq"2B#R3$brCScs4%&5DTdEU6teuFVfv'7GWgw ?I!")Jh*AZRRʉi *d!I$JRI$I$$I)I!"U6PKtwpWOdؕpCfS%*^; vxmgEml>Klz DFWioZMԒqv 5'.'I4򠅖6yU?I| 2(e>s<;B]NI潡2:rI$S8m>#&fXC Lqi@#vJ:+P%q>[hk?IŽqoMWZ\Q7"ʡuQS6㪵}*R AIJK) qOw௬PF(K^HuJI)LJ_-ExKF)&ۺ^"ւ8gou@g>i?><#ɾE*12˿yڕ2R.P%Klz DFWioZMԒqv 5'.'I4򠅖6yU?I| 2(e>s<;B]NI潡2:rI$S8m>#&fXC Lqi@#vJ:+P%q>[hk?IŽqoMWZ\Q7"ʡuQS6㪵}*R AIJK) qOw௬PF(K^HuJI)LJ_-ExKF)&ۺ^"ւ8gou@g>i?><#ɾE*12˿yڕ2R.P% 1 120 120 1 72/1 72/1 2 2005-06-17T09:55:47-05:00 2005-06-17T09:55:47-05:00 2005-06-17T09:55:47-05:00 Adobe Photoshop CS Windows adobe:docid:photoshop:5dd9930e-df37-11d9-b295-daca1d068cfc image/jpeg XICC_PROFILE HLinomntrRGB XYZ  1acspMSFTIEC sRGB-HP cprtP3desclwtptbkptrXYZgXYZ,bXYZ@dmndTpdmddvuedLview$lumimeas $tech0 rTRC< gTRC< bTRC< textCopyright (c) 1998 Hewlett-Packard CompanydescsRGB IEC61966-2.1sRGB IEC61966-2.1XYZ QXYZ XYZ o8XYZ bXYZ $descIEC http://www.iec.chIEC http://www.iec.chdesc.IEC 61966-2.1 Default RGB colour space - sRGB.IEC 61966-2.1 Default RGB colour space - sRGBdesc,Reference Viewing Condition in IEC61966-2.1,Reference Viewing Condition in IEC61966-2.1view_. \XYZ L VPWmeassig CRT curv #(-27;@EJOTY^chmrw| %+28>ELRY`gnu| &/8AKT]gqz !-8COZfr~ -;HUcq~ +:IXgw'7HYj{+=Oat 2FZn  % : O d y  ' = T j " 9 Q i  * C \ u & @ Z t .Id %A^z &Ca~1Om&Ed#Cc'Ij4Vx&IlAe@e Ek*Qw;c*R{Gp@j>i  A l !!H!u!!!"'"U"""# #8#f###$$M$|$$% %8%h%%%&'&W&&&''I'z''( (?(q(())8)k))**5*h**++6+i++,,9,n,,- -A-v--..L.../$/Z///050l0011J1112*2c223 3F3334+4e4455M555676r667$7`7788P8899B999:6:t::;-;k;;<' >`>>?!?a??@#@d@@A)AjAAB0BrBBC:C}CDDGDDEEUEEF"FgFFG5G{GHHKHHIIcIIJ7J}JK KSKKL*LrLMMJMMN%NnNOOIOOP'PqPQQPQQR1R|RSS_SSTBTTU(UuUVV\VVWDWWX/X}XYYiYZZVZZ[E[[\5\\]']x]^^l^__a_``W``aOaabIbbcCccd@dde=eef=ffg=ggh?hhiCiijHjjkOkklWlmm`mnnknooxop+ppq:qqrKrss]sttptu(uuv>vvwVwxxnxy*yyzFz{{c{|!||}A}~~b~#G k͂0WGrׇ;iΉ3dʋ0cʍ1fΏ6n֑?zM _ɖ4 uL$h՛BdҞ@iءG&vVǥ8nRĩ7u\ЭD-u`ֲK³8%yhYѹJº;.! zpg_XQKFAǿ=ȼ:ɹ8ʷ6˶5̵5͵6ζ7ϸ9к<Ѿ?DINU\dlvۀ܊ݖޢ)߯6DScs 2F[p(@Xr4Pm8Ww)KmAdobed@xx     u!"1A2# QBa$3Rqb%C&4r 5'S6DTsEF7Gc(UVWdte)8fu*9:HIJXYZghijvwxyzm!1"AQ2aqB#Rb3 $Cr4%ScD&5T6Ed' sFtUeuV7)(GWf8vgwHXhx9IYiy*:JZjz ?aɰ?A{ߺ\ ?݂1*h=onS>T.T.U׺u{{^׺u{{^Щ$̓ P]Y*ǾP6Uzz /YZVAZ U>})kbG8"F*UksnG!@^H]:QpߏX?.ecqæ|#E5rK{'I$:Lu߿u{{^׺u{{^ѩ_>c54S9WCˋ?*FVnаT ]G"Z9t?4`$%t,ުU_k ު.L=*;W#M{a7'Wҝܵ䊓]V 5MH{\fxMpFaoWgulJ},~UM H! f;8T=E>^?sVnp@I7]UqmIB~tI.Jg4`OdtKwoPWR<W3]?jgtqzS%\ OTrWcſ&KG'(?Imp<^ Q{ID#\@GOcЕtjֹ @,"WzV!]Y.-æTWЋ:ߺ^׽uҩ9.x#q ipeܑã(F0--e,ORGR>}* "8GSc8֨zuy,POu[tr^iX\-LcT!*2S@t.H}}2l?o_oUb#+T Jt 8AG$dϯGW[*6 j7ΩqgfydbڞF.ͽybO7;<#cĜTiE?PO5{OD+M_s(#?m=XX]CS G)7އt>#nyi2.Ot!5JX?EI>2[wC^c7:0bJ~߷|nJ/CMT%U\bH'P*AV +qȓ"UCFQSzuӬ{[)œQ`uM8*=%P֨='xm N")O}C"@?^TQJFú n udtȺO_Judž\icل Iꥦt~yPOG{n%kЖjtHqP?y~gV~ݨvV*9d @T D$ymWKvԀ:I1ts4T qVTVn)9?{Qj::έ $QuInW3_7?텽@\Sg_O?8HIo?Ӑ OX'=)AQLp~!JCOTvbc&?2;z(X莱nlM_H )!g˯^Y~|ǘ7=rA{ԩFPASBYU8څZiݔ^dtomw,D!-&7) x[']R4i%752{y6%Gˡ/bd c$Zr6T^HּBB,HA#H>;܅z1kyny3| 3$j4+ݚ]DRykܛ9؊Y@~9-S}E[xFw9kNJ'ra%r9c o8$噹7>}['y@(V?ɷoi}D ?S??J"ңb[Ey`_ i_5gU@N>9P#\,Κ }gոmtH5-@ p?>?ν-Aթo}1R58oCNG[7UNZ*ҶU_On 0ǯSO6Zw ¹iBct!B'JZN8ApƴJ@DJq?Ýd[[Zjc?DbgpouqZBq8v#+9$CG~?n]6b};sX6{ǤRē7˴ZaI ޑ9bo<~ğv$^OϬ6-{DƤҴC[EFckSӀpbumo }K",iSJWђ (l 8RS֪44.>y;c FtE-D/N۟t=z ֬ ÌU*l\M>cDq=76o׵Ay@=x.o4 ^;XYVcƻ+S%2- $de<tjSPr ҟχEV] ִC"3"TA_{-ܟ '=ά2mo]-k_֔QOu upkt=QӏIݏ?T%gg=Ǧ)%.~}q괯Qi_Ii}XLiLGp/o?>16767W'~<ߟ'lt.F:s?w!PsфKR:S( [kqkҲB|:~`¾?vȿ\9M\z?=]>n?sAשo}8@S`K}l,ea#R.>~D-7z_0k-ȞH>z4/fϝ⥃w1WM;"Y:xj#/oWdĕ%mh-:S}\햗h܃0+Mg>u{YO^|IѰm6C(8q{s~=W)k?7^厢spit?ub28Qcp:UtFXsTFGϬf' 'I7zn~JeQib{Cjd;U0}K4nOљ:tKЩVfA$, zVᎃ3'kf+ ڨ"x{L?~΄v0 ⃡7Ng2fZG>HO)1@'Ldoтҿ>=b65'D]X?gN;gGG3BXڂy>45ţ,/Ϸ!6Bx;6˫&ˏ?˭_;i&m$ԓQV,ѴSE7n~~u/_[:^zoyx_kÏNǩȽw6Vr MՖAU?0z _сt&ѬMՎD4sJmH} xW\PQ3޾A )~Xdr4xɱK U;I  Z#pm@˨Qtra? k'm\,yH#uRqoׂ| *no~-Eiӂ2i^<JܟZˮ/0j$^j5#?'S5{Ztc :GϤc-$NY}/.\=?t^UvM嚧a^(LnE )7N$b(Ao&z?貯X&ndЪ:=ˠ}aIҩaŭǾdק wS`jx,G(K#\ !Bƃ = UvpRJ%sisQ!E $d\bۚV%guЧu)NOXUT}P!pQa h-2 9p,mo ">_}z6dE|ET^j \y!\nE462)|,D&K) gd O: .O5],%|N2ݻ-QXzeM<4c`FR5[ ǰ=nGEw[]Ք%Xzf?dģzpHUM\\N!'#[9p?ޭ;uZ7UgQzKeR噏*I7kצ P3Љ>?nMSo~CY2"Q%.w:D$G ;PUrǷđhmkI'ʜcSM *Qu0AARbTtmQRƱS¡c(<}v±Ơ*`:&zkI iDwөo}1f G$&?$_N[wTAV= FhS<%*7Lvs&:6כKc϶]Ml-cQM#K`)J kpDKS(*o~}:#I=Ei*H 1ֺԩZYH FG Qs Mz "3U'RO^:S2чozUz=El[Pܑ:C-DJM#K<^I\ܟtW.jz6Ѳta)-P)ҧ3?1o?۪h Wj}zY\vAb#Wi7?װDtaN:ǚ1St4پ?_zOul7G>K>.re}Ϸ>g&?SY{BDֹy\ڕON&}7;>"Ӣz>龽{խ8q_Ffb %n c IH" NI,I44JI'ɯL9ꀑé0y5eP?<=O!KR1hyZiZQ[ ty5SJQ>1]ԥ<. #6_?zV'G"駼'ϨrUoŏI.׷><>*VrzS{^׺eclipse-gef-3.7.1/org.eclipse.gef-feature/sourceTemplateFeature/epl-v10.html000066400000000000000000000402301166301720600266730ustar00rootroot00000000000000 Eclipse Public License - Version 1.0

    Eclipse Public License - v 1.0

    THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.

    1. DEFINITIONS

    "Contribution" means:

    a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
    b) in the case of each subsequent Contributor:

    i) changes to the Program, and

    ii) additions to the Program;

    where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.

    "Contributor" means any person or entity that distributes the Program.

    "Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.

    "Program" means the Contributions distributed in accordance with this Agreement.

    "Recipient" means anyone who receives the Program under this Agreement, including all Contributors.

    2. GRANT OF RIGHTS

    a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.

    b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.

    c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.

    d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.

    3. REQUIREMENTS

    A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:

    a) it complies with the terms and conditions of this Agreement; and

    b) its license agreement:

    i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;

    ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;

    iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and

    iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.

    When the Program is made available in source code form:

    a) it must be made available under this Agreement; and

    b) a copy of this Agreement must be included with each copy of the Program.

    Contributors may not remove or alter any copyright notices contained within the Program.

    Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.

    4. COMMERCIAL DISTRIBUTION

    Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.

    For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.

    5. NO WARRANTY

    EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.

    6. DISCLAIMER OF LIABILITY

    EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

    7. GENERAL

    If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.

    If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.

    All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.

    Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.

    This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.

     

    eclipse-gef-3.7.1/org.eclipse.gef-feature/sourceTemplateFeature/feature.properties000066400000000000000000000241251166301720600303770ustar00rootroot00000000000000############################################################################### # Copyright (c) 2003, 2010 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # # Contributors: # IBM Corporation - initial API and implementation ############################################################################### # feature.properties # contains externalized strings for feature.xml # "%foo" in feature.xml corresponds to the key "foo" in this file # java.io.Properties file (ISO 8859-1 with "\" escapes) # This file should be translated. # "featureName" property - name of the feature featureName=Graphical Editing Framework GEF Source Feature # "providerName" property - name of the company that provides the feature providerName=Eclipse Modeling Project # "updateSiteName" property - label for the update site updateSiteName=Graphical Editing Framework (GEF) Update Site # "description" property - description of the feature description=API documentation and source code for Graphical Editing Framework. # "licenseURL" property - URL of the "Feature License" # do not translate value - just change to point to a locale-specific HTML page licenseURL=license.html # "copyright" property - text of the "Feature Update Copyright" copyright=\ Copyright (c) 2000, 2009 IBM Corporation and others.\n\ All rights reserved. This program and the accompanying materials\n\ are made available under the terms of the Eclipse Public License v1.0\n\ which accompanies this distribution, and is available at\n\ http://www.eclipse.org/legal/epl-v10.html\n\ \n\ Contributors:\n\ IBM Corporation - initial API and implementation\n ################ end of copyright property #################################### # "license" property - text of the "Feature Update License" # should be plain text version of license agreement pointed to be "licenseURL" license=\ Eclipse Foundation Software User Agreement\n\ February 1, 2011\n\ \n\ Usage Of Content\n\ \n\ THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\ OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\ USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\ AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\ NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\ AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\ AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\ OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\ TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\ OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\ BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\ \n\ Applicable Licenses\n\ \n\ Unless otherwise indicated, all Content made available by the\n\ Eclipse Foundation is provided to you under the terms and conditions of\n\ the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is\n\ provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\ For purposes of the EPL, "Program" will mean the Content.\n\ \n\ Content includes, but is not limited to, source code, object code,\n\ documentation and other files maintained in the Eclipse Foundation source code\n\ repository ("Repository") in software modules ("Modules") and made available\n\ as downloadable archives ("Downloads").\n\ \n\ - Content may be structured and packaged into modules to facilitate delivering,\n\ extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\ plug-in fragments ("Fragments"), and features ("Features").\n\ - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java(TM) ARchive)\n\ in a directory named "plugins".\n\ - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\ Each Feature may be packaged as a sub-directory in a directory named "features".\n\ Within a Feature, files named "feature.xml" may contain a list of the names and version\n\ numbers of the Plug-ins and/or Fragments associated with that Feature.\n\ - Features may also include other Features ("Included Features"). Within a Feature, files\n\ named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\ \n\ The terms and conditions governing Plug-ins and Fragments should be\n\ contained in files named "about.html" ("Abouts"). The terms and\n\ conditions governing Features and Included Features should be contained\n\ in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\ Licenses may be located in any directory of a Download or Module\n\ including, but not limited to the following locations:\n\ \n\ - The top-level (root) directory\n\ - Plug-in and Fragment directories\n\ - Inside Plug-ins and Fragments packaged as JARs\n\ - Sub-directories of the directory named "src" of certain Plug-ins\n\ - Feature directories\n\ \n\ Note: if a Feature made available by the Eclipse Foundation is installed using the\n\ Provisioning Technology (as defined below), you must agree to a license ("Feature \n\ Update License") during the installation process. If the Feature contains\n\ Included Features, the Feature Update License should either provide you\n\ with the terms and conditions governing the Included Features or inform\n\ you where you can locate them. Feature Update Licenses may be found in\n\ the "license" property of files named "feature.properties" found within a Feature.\n\ Such Abouts, Feature Licenses, and Feature Update Licenses contain the\n\ terms and conditions (or references to such terms and conditions) that\n\ govern your use of the associated Content in that directory.\n\ \n\ THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER\n\ TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\ SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\ \n\ - Eclipse Distribution License Version 1.0 (available at http://www.eclipse.org/licenses/edl-v1.0.html)\n\ - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\ - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\ - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\ - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\ - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\ \n\ IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\ TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License\n\ is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\ govern that particular Content.\n\ \n\ \n\Use of Provisioning Technology\n\ \n\ The Eclipse Foundation makes available provisioning software, examples of which include,\n\ but are not limited to, p2 and the Eclipse Update Manager ("Provisioning Technology") for\n\ the purpose of allowing users to install software, documentation, information and/or\n\ other materials (collectively "Installable Software"). This capability is provided with\n\ the intent of allowing such users to install, extend and update Eclipse-based products.\n\ Information about packaging Installable Software is available at\n\ http://eclipse.org/equinox/p2/repository_packaging.html ("Specification").\n\ \n\ You may use Provisioning Technology to allow other parties to install Installable Software.\n\ You shall be responsible for enabling the applicable license agreements relating to the\n\ Installable Software to be presented to, and accepted by, the users of the Provisioning Technology\n\ in accordance with the Specification. By using Provisioning Technology in such a manner and\n\ making it available in accordance with the Specification, you further acknowledge your\n\ agreement to, and the acquisition of all necessary rights to permit the following:\n\ \n\ 1. A series of actions may occur ("Provisioning Process") in which a user may execute\n\ the Provisioning Technology on a machine ("Target Machine") with the intent of installing,\n\ extending or updating the functionality of an Eclipse-based product.\n\ 2. During the Provisioning Process, the Provisioning Technology may cause third party\n\ Installable Software or a portion thereof to be accessed and copied to the Target Machine.\n\ 3. Pursuant to the Specification, you will provide to the user the terms and conditions that\n\ govern the use of the Installable Software ("Installable Software Agreement") and such\n\ Installable Software Agreement shall be accessed from the Target Machine in accordance\n\ with the Specification. Such Installable Software Agreement must inform the user of the\n\ terms and conditions that govern the Installable Software and must solicit acceptance by\n\ the end user in the manner prescribed in such Installable Software Agreement. Upon such\n\ indication of agreement by the user, the provisioning Technology will complete installation\n\ of the Installable Software.\n\ \n\ Cryptography\n\ \n\ Content may contain encryption software. The country in which you are\n\ currently may have restrictions on the import, possession, and use,\n\ and/or re-export to another country, of encryption software. BEFORE\n\ using any encryption software, please check the country's laws,\n\ regulations and policies concerning the import, possession, or use, and\n\ re-export of encryption software, to see if this is permitted.\n\ \n\ Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.\n ########### end of license property ########################################## eclipse-gef-3.7.1/org.eclipse.gef-feature/sourceTemplateFeature/license.html000066400000000000000000000220161166301720600271330ustar00rootroot00000000000000 Eclipse Foundation Software User Agreement

    Eclipse Foundation Software User Agreement

    February 1, 2011

    Usage Of Content

    THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.

    Applicable Licenses

    Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, "Program" will mean the Content.

    Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse Foundation source code repository ("Repository") in software modules ("Modules") and made available as downloadable archives ("Downloads").

    • Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"), plug-in fragments ("Fragments"), and features ("Features").
    • Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java™ ARchive) in a directory named "plugins".
    • A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Each Feature may be packaged as a sub-directory in a directory named "features". Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of the Plug-ins and/or Fragments associated with that Feature.
    • Features may also include other Features ("Included Features"). Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of Included Features.

    The terms and conditions governing Plug-ins and Fragments should be contained in files named "about.html" ("Abouts"). The terms and conditions governing Features and Included Features should be contained in files named "license.html" ("Feature Licenses"). Abouts and Feature Licenses may be located in any directory of a Download or Module including, but not limited to the following locations:

    • The top-level (root) directory
    • Plug-in and Fragment directories
    • Inside Plug-ins and Fragments packaged as JARs
    • Sub-directories of the directory named "src" of certain Plug-ins
    • Feature directories

    Note: if a Feature made available by the Eclipse Foundation is installed using the Provisioning Technology (as defined below), you must agree to a license ("Feature Update License") during the installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or inform you where you can locate them. Feature Update Licenses may be found in the "license" property of files named "feature.properties" found within a Feature. Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in that directory.

    THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):

    IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License is provided, please contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.

    Use of Provisioning Technology

    The Eclipse Foundation makes available provisioning software, examples of which include, but are not limited to, p2 and the Eclipse Update Manager ("Provisioning Technology") for the purpose of allowing users to install software, documentation, information and/or other materials (collectively "Installable Software"). This capability is provided with the intent of allowing such users to install, extend and update Eclipse-based products. Information about packaging Installable Software is available at http://eclipse.org/equinox/p2/repository_packaging.html ("Specification").

    You may use Provisioning Technology to allow other parties to install Installable Software. You shall be responsible for enabling the applicable license agreements relating to the Installable Software to be presented to, and accepted by, the users of the Provisioning Technology in accordance with the Specification. By using Provisioning Technology in such a manner and making it available in accordance with the Specification, you further acknowledge your agreement to, and the acquisition of all necessary rights to permit the following:

    1. A series of actions may occur ("Provisioning Process") in which a user may execute the Provisioning Technology on a machine ("Target Machine") with the intent of installing, extending or updating the functionality of an Eclipse-based product.
    2. During the Provisioning Process, the Provisioning Technology may cause third party Installable Software or a portion thereof to be accessed and copied to the Target Machine.
    3. Pursuant to the Specification, you will provide to the user the terms and conditions that govern the use of the Installable Software ("Installable Software Agreement") and such Installable Software Agreement shall be accessed from the Target Machine in accordance with the Specification. Such Installable Software Agreement must inform the user of the terms and conditions that govern the Installable Software and must solicit acceptance by the end user in the manner prescribed in such Installable Software Agreement. Upon such indication of agreement by the user, the provisioning Technology will complete installation of the Installable Software.

    Cryptography

    Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to see if this is permitted.

    Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.

    eclipse-gef-3.7.1/org.eclipse.gef-feature/sourceTemplatePlugin/000077500000000000000000000000001166301720600244655ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.gef-feature/sourceTemplatePlugin/about.html000066400000000000000000000026321166301720600264700ustar00rootroot00000000000000 About

    About This Content

    June 5, 2006

    License

    The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available at http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, "Program" will mean the Content.

    If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party ("Redistributor") and different terms and conditions may apply to your use of any object code in the Content. Check the Redistributor's license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise indicated below, the terms and conditions of the EPL still apply to any source code in the Content and such source code may be obtained at http://www.eclipse.org.

    eclipse-gef-3.7.1/org.eclipse.gef-feature/sourceTemplatePlugin/about.ini000066400000000000000000000016751166301720600263110ustar00rootroot00000000000000# about.ini # contains information about a feature # java.io.Properties file (ISO 8859-1 with "\" escapes) # "%key" are externalized strings defined in about.properties # This file does not need to be translated. # Property "aboutText" contains blurb for "About" dialog (translated) aboutText=%blurb # Property "windowImage" contains path to window icon (16x16) # needed for primary features only # Property "featureImage" contains path to feature image (32x32) featureImage=modeling32.png # Property "aboutImage" contains path to product image (500x330 or 115x164) # needed for primary features only # Property "appName" contains name of the application (translated) # needed for primary features only # Property "welcomePage" contains path to welcome page (special XML-based format) # optional # Property "welcomePerspective" contains the id of the perspective in which the # welcome page is to be opened. # optional eclipse-gef-3.7.1/org.eclipse.gef-feature/sourceTemplatePlugin/about.mappings000066400000000000000000000002551166301720600273410ustar00rootroot00000000000000# about.mappings # contains fill-ins for about.properties # java.io.Properties file (ISO 8859-1 with "\" escapes) # This file does not need to be translated. 0=@build@eclipse-gef-3.7.1/org.eclipse.gef-feature/sourceTemplatePlugin/about.properties000066400000000000000000000017011166301720600277140ustar00rootroot00000000000000############################################################################### # Copyright (c) 2003, 2009 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # # Contributors: # IBM Corporation - initial API and implementation ############################################################################### # about.properties # contains externalized strings for about.ini # java.io.Properties file (ISO 8859-1 with "\" escapes) # fill-ins are supplied by about.mappings # This file should be translated. blurb=Eclipse Graphical Editing Framework GEF Source Bundle\n\ \n\ Version: {featureVersion}\n\ Build id: {0}\n\ \n\ (c) Copyright Eclipse Contributors and others 2000, 2009. All rights reserved.\n\ Visit http://www.eclipse.org/gef eclipse-gef-3.7.1/org.eclipse.gef-feature/sourceTemplatePlugin/build.properties000066400000000000000000000015071166301720600277050ustar00rootroot00000000000000############################################################################### # Copyright (c) 2003, 2009 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # # Contributors: # IBM Corporation - initial API and implementation ############################################################################### bin.includes = about.html,\ about.ini,\ about.mappings,\ about.properties,\ modeling32.png,\ plugin.xml,\ plugin.properties,\ src/**,\ META-INF/ src.includes = about.html sourcePlugin=true eclipse-gef-3.7.1/org.eclipse.gef-feature/sourceTemplatePlugin/modeling32.png000066400000000000000000000045561166301720600271500ustar00rootroot00000000000000PNG  IHDR szzgAMAOX2tEXtSoftwareAdobe ImageReadyqe< IDATxڬW}l{޶MGL'Yܔ9$fKYE "p7ee٬ f(ks6%˶==<FhAԡk$e! ć8b@t3lF=?!+xq\͐&)\y XJP,A8/g54ř4JmUZ-|n`%/HpĤquB# LH0EsB_ex^(yH0 AƬ/Yeќ9P o4bmdٷ?§0,F42,BLa6nX~}O}a@]Y |^ C^$jYfӅNc4*Mt4&ɲ42E(r3*+Z}{[w+r }P# -p45z ] Ma[ʔ'}{ţ+7oߎK,Ob8Nu<$|Q%Pi&:MǛg|o?Z7o ۶;w+ se:Z9OF'y\!C~*G2wdh u6/u(zF>z{1[<󂁚x /WJbmԜ`rݚ&uޒyfffjn%QkAb,dG/D ‘}._)2'/J_>$ ҆8mٲ^?E~ zAhit&{;dm6k$S u_{%m-KWW֬k%=zUXKs6#!"<26Tyx}8/\0}7詇H&쳯ѥKYiuϞ~};  1t#W#p ::Zܾ}G<o|a߾~7soOӮ=J>v~JŲLAWtq~78k]dXOo_]]뵷4+y4OѴ(0P.XPc~n\`4| g\# [h5nk+Лc轡Zª%,\b>474)݅rvF>ᑑhOpx`jHƺ3\R0 U_(Б%6,sGQgFvJrꗽ@\2+4AAxB `F3pM&n#J27Oz+Aj_ ʘWvoIENDB`eclipse-gef-3.7.1/org.eclipse.gef-feature/sourceTemplatePlugin/plugin.properties000066400000000000000000000011611166301720600301000ustar00rootroot00000000000000############################################################################### # Copyright (c) 2003, 2009 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # # Contributors: # IBM Corporation - initial API and implementation ############################################################################### pluginName=Graphical Editing Framework GEF Source Bundle providerName=Eclipse Modeling Project eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/000077500000000000000000000000001166301720600202255ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/.cvsignore000066400000000000000000000000531166301720600222230ustar00rootroot00000000000000bin reference buildDocLocal.xml doc.bin.logeclipse-gef-3.7.1/org.eclipse.gef.doc.isv/.project000066400000000000000000000004451166301720600216770ustar00rootroot00000000000000 org.eclipse.gef.doc.isv org.eclipse.draw2d org.eclipse.gef eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/META-INF/000077500000000000000000000000001166301720600213655ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/META-INF/MANIFEST.MF000066400000000000000000000004551166301720600230230ustar00rootroot00000000000000Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Plugin.name Bundle-SymbolicName: org.eclipse.gef.doc.isv; singleton:=true Bundle-Version: 3.5.0.qualifier Bundle-Vendor: %Plugin.providerName Bundle-Localization: plugin Eclipse-LazyStart: true Bundle-RequiredExecutionEnvironment: J2SE-1.4eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/about.html000066400000000000000000000024631166301720600222320ustar00rootroot00000000000000 About

    About This Content

    June 5, 2007

    License

    The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available at http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, "Program" will mean the Content.

    If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party ("Redistributor") and different terms and conditions may apply to your use of any object code in the Content. Check the Redistributor's license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise indicated below, the terms and conditions of the EPL still apply to any source code in the Content and such source code may be obtained at http://www.eclipse.org.

    eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/book.css000066400000000000000000000000461166301720600216710ustar00rootroot00000000000000@import "../PRODUCT_PLUGIN/book.css"; eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/build.properties000066400000000000000000000010401166301720600234350ustar00rootroot00000000000000############################################################################### # Copyright (c) 2002, 2005 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # # Contributors: # IBM Corporation - initial API and implementation ############################################################################### custom = true eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/build.xml000066400000000000000000000114271166301720600220530ustar00rootroot00000000000000 eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/buildDoc.xml000066400000000000000000000020731166301720600224760ustar00rootroot00000000000000 eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/buildDocLocal.xml000066400000000000000000000016031166301720600234470ustar00rootroot00000000000000 eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/doc.properties000066400000000000000000000010241166301720600231050ustar00rootroot00000000000000############################################################################### # Copyright (c) 2002, 2005 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # # Contributors: # IBM Corporation - initial API and implementation ############################################################################### eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/gefOptions000066400000000000000000000035451166301720600222740ustar00rootroot00000000000000-charset "iso-8859-1" -sourcepath "../org.eclipse.gef/src" -d reference/api -classpath @rt@:../org.eclipse.draw2d/@dot:../org.eclipse.debug.core.jar:../org.eclipse.compare.jar:../org.eclipse.help.jar:../org.eclipse.help.ui.jar:../org.eclipse.core.resources.jar:../org.eclipse.core.runtime.jar:../org.eclipse.swt.win32.win32.x86.jar:../org.eclipse.ui.jar:../org.eclipse.debug.ui.jar:../org.eclipse.search.jar:../org.eclipse.jface.jar:../org.eclipse.jface.text.jar:../org.eclipse.text.jar:../org.eclipse.ui.editors.jar:../org.eclipse.ui.views.jar:../org.eclipse.ui.workbench.jar:../org.eclipse.ui.workbench.texteditor.jar:../org.eclipse.osgi.jar -use -breakiterator -splitIndex -windowtitle "Eclipse GEF API Specification" -doctitle "Eclipse GEF API Specification" -header "Eclipse GEF
    3.3" -bottom "Copyright (c) IBM Corp. and others 2000, 2007. All Rights Reserved." -overview ../org.eclipse.gef/src/overview.html -link http://java.sun.com/j2se/1.4.2/docs/api -linkoffline ../../../org.eclipse.platform.doc.isv/reference/api ../org.eclipse.platform.doc.isv/reference/api -linkoffline ../../../org.eclipse.platform.doc.isv/reference/osgi ../org.eclipse.platform.doc.isv/reference/osgi -linkoffline ../../../org.eclipse.draw2d.doc.isv/reference/api ../org.eclipse.draw2d.doc.isv/reference/api -linkoffline ../../../org.eclipse.draw2d.doc.isv/reference/osgi ../org.eclipse.draw2d.doc.isv/reference/osgi org.eclipse.gef org.eclipse.gef.commands org.eclipse.gef.dnd org.eclipse.gef.editparts org.eclipse.gef.editpolicies org.eclipse.gef.handles org.eclipse.gef.palette org.eclipse.gef.print org.eclipse.gef.requests org.eclipse.gef.rulers org.eclipse.gef.tools org.eclipse.gef.ui.actions org.eclipse.gef.ui.palette org.eclipse.gef.ui.palette.customize org.eclipse.gef.ui.parts org.eclipse.gef.ui.properties org.eclipse.gef.ui.rulers org.eclipse.gef.ui.views.palette org.eclipse.gef.utileclipse-gef-3.7.1/org.eclipse.gef.doc.isv/gefOptions.txt000066400000000000000000000035461166301720600231130ustar00rootroot00000000000000-charset "iso-8859-1" -sourcepath "../org.eclipse.gef/src" -d reference/api -classpath ${rt}:../org.eclipse.draw2d/@dot:../org.eclipse.debug.core.jar:../org.eclipse.compare.jar:../org.eclipse.help.jar:../org.eclipse.help.ui.jar:../org.eclipse.core.resources.jar:../org.eclipse.core.runtime.jar:../org.eclipse.swt.win32.win32.x86.jar:../org.eclipse.ui.jar:../org.eclipse.debug.ui.jar:../org.eclipse.search.jar:../org.eclipse.jface.jar:../org.eclipse.jface.text.jar:../org.eclipse.text.jar:../org.eclipse.ui.editors.jar:../org.eclipse.ui.views.jar:../org.eclipse.ui.workbench.jar:../org.eclipse.ui.workbench.texteditor.jar:../org.eclipse.osgi.jar -use -breakiterator -splitIndex -windowtitle "Eclipse GEF API Specification" -doctitle "Eclipse GEF API Specification" -header "Eclipse GEF
    3.3" -bottom "Copyright (c) IBM Corp. and others 2000, 2007. All Rights Reserved." -overview ../org.eclipse.gef/src/overview.html -link http://java.sun.com/j2se/1.4.2/docs/api -linkoffline ../../../org.eclipse.platform.doc.isv/reference/api ../org.eclipse.platform.doc.isv/reference/api -linkoffline ../../../org.eclipse.platform.doc.isv/reference/osgi ../org.eclipse.platform.doc.isv/reference/osgi -linkoffline ../../../org.eclipse.draw2d.doc.isv/reference/api ../org.eclipse.draw2d.doc.isv/reference/api -linkoffline ../../../org.eclipse.draw2d.doc.isv/reference/osgi ../org.eclipse.draw2d.doc.isv/reference/osgi org.eclipse.gef org.eclipse.gef.commands org.eclipse.gef.dnd org.eclipse.gef.editparts org.eclipse.gef.editpolicies org.eclipse.gef.handles org.eclipse.gef.palette org.eclipse.gef.print org.eclipse.gef.requests org.eclipse.gef.rulers org.eclipse.gef.tools org.eclipse.gef.ui.actions org.eclipse.gef.ui.palette org.eclipse.gef.ui.palette.customize org.eclipse.gef.ui.parts org.eclipse.gef.ui.properties org.eclipse.gef.ui.rulers org.eclipse.gef.ui.views.palette org.eclipse.gef.utileclipse-gef-3.7.1/org.eclipse.gef.doc.isv/guide.html000066400000000000000000000026101166301720600222070ustar00rootroot00000000000000 Programmer's Guide

    Graphical Editing Framework Programmer's Guide

    The Graphical Editing Framework (GEF) provides a foundation for building rich, interactive user interfaces which are not easily built using native widgets found in the base Eclipse platform.

    This guide provides an architectural overview of the Graphical Editing Framework.  The reader should have working knowledge of the Eclipse platform.

    The GEF component is separated into two plug-ins:

    • Draw2d (org.eclipse.draw2d) - the lightweight toolkit for painting and layout on an SWT Canvas

    • GEF (org.eclipse.gef) - an interactive MVC framework built on top of Draw2d

    Notice that "GEF" can refer to the entire component (2 plug-ins), or just to the plug-in org.eclipse.gef.

    eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/guide/000077500000000000000000000000001166301720600213225ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/guide/guide.html000066400000000000000000001525721166301720600233210ustar00rootroot00000000000000 GEF Developer's Guide

    GEF Programmer's Guide
    org.eclipse.gef

    Overview

    Draw2d focuses on efficient painting and layout of figures. The GEF plug-in adds editing on top of Draw2d. The purpose of this framework is to:

    1. Facilitate the display of any model graphically using draw2d figures

    2. Support interactions from mouse, keyboard, or the Workbench

    3. Provide common components related to the above

    The diagram below shows a high-level view of GEF.  GEF can be loosely defined as the region in the middle. The framework provides the link between an application's model and view. It also provides input handlers, such as tools and actions, that turn events into requests. Requests and Commands are used to encapsulate interactions and their effects on the model.

    In MVC (model-view-controller) design, the controller is often the only connection between the view and the model. The controller is responsible for maintaining the view, and for interpreting UI events and turning them into operations on the model. These roles as they apply to GEF are described below:

    Model

    The model is any data that gets persisted. Any model can be used with GEF. The model must have some sort of notification mechanism. Although not technically the model, commands are closely related. A command is how the model is modified in a way that can be undone and redone by the user. In general, commands should work only on the model itself.

    View (Figures/TreeItems)

    The view is anything visible to the user. Both Figures and TreeItems can be used as view elements.

    Controller (EditPart)

    There is usually one controller per visualized model object. The controller is called an EditPart. Editparts are the link between the model and the view. They are also responsible for editing. Editparts contain helpers called EditPolicies, which handle the much of the editing task.

    Viewers

    An EditPartViewer is where editparts display their view. There are two types of viewers provided in GEF. A graphical viewer hosts figures while a tree viewer displays native treeitems. GEF viewers are similar to JFace viewers in that they manage an SWT Control. Viewers are also a selection provider, and the unit of selection is the EditPart.

    When can I use GEF?

    GEF can be used anywhere that you can use an SWT Control inside a Workbench. It could be an editor, a view, a wizard page, etc. Most commonly it is used inside an EditorPart and sometimes in that editor's outline page.

    GEF requires the Eclipse Rich Client Platform (RCP) and the "views" plug-in (org.eclipse.ui.views), which provides property sheet support.

    An Introduction to EditParts

    Editparts associate their view and model, but they also form their own structure. An editpart maintains children. Usually this corresponds to a similar containment found in the model. For example, the model may consist of a diagram containing nodes. There would then be a corresponding diagram editpart which contains multiple node editpart children.

    The parent-child relationship of editparts carries over into their figures. The parent's figure will contain the children's figures. Or, in some cases the parent part's view is a compound view composed of several figures, one of which is designated as the content pane. The figure of each child is added to the content pane. The end result is that you have three separate hierarchical data structures which are approximately parallel to each other.

    Connections are the exception to this simple tree structure. Connections represent a link or association between two objects. A Draw2d connection figure is used as the view. Connections may be stored in any way in the model, but the editparts are managed by the source and target editpart at each end. A connection editpart's figure containment is also handled specially. The connection figure is added to a special layer in the diagram so that it paints above the primary layer containing non-connection parts.

    There are two types of editpart implementations provided with GEF. Graphical editparts use figures as their view. Graphical editparts also add the ability to support connections, which themselves are graphical editparts. The other type is a tree editpart. Tree editparts use SWT treeitems as their view.

    The responsibilities of each editpart include:

    • Create and maintain a view (whether figure or treeitem)
    • Create and maintain children editparts
    • Create and maintain connections editparts
    • Support editing of the model

    Note that maintaining the view and other editparts implies that the editpart will be notified of changes in the model. Usually, the editpart hooks a listener directly to the model object(s) with which it is associated. When it receives notification, it updates its view or structure depending on the change.

    As the name implies, editparts must support editing the model. But first we will focus on the initial steps of building an application, which is to display the initial model.

    Creating a Graphical View of a Model

    Once you have a model and some figures with which to view it, the next step is to put the pieces together. This means creating the editparts that are going to work with each model and figure combination. GEF's implementations are abstract and must be extended for your application. But first, we need to set up the foundation.

    GEF includes the class ScrollingGraphicalViewer. This is a viewer implementation which uses a Draw2d FigureCanvas. Most applications use this viewer unless, for some reason, scrollbars are not needed. The next step is to decide which root editpart to use. Each editpart viewer requires a special editpart called the root. This editpart does not correspond to anything in the model. Its function is to setup the viewer and provide a uniform context for all of the application's "real" editparts. There are two implementations to consider using:

    • ScalableRootEditPart - provides the standard set of layers and supports zoom should the application decide to expose this to the user.

    • ScalableFreeformRootEditPart - similar to above, but all of the layers conform to the freeform interface, which allows the diagram to additionally extend into negative coordinates (to the left and up). This is the most flexible and commonly used root editpart.

    Now we have a viewer and its root editpart, so next we'll actually set some contents into the viewer. Contents refers to the base model object that seeds the viewer with the graphical diagram being displayed. The viewer's EditPartFactory is then responsible for taking the contents and constructing the appropriate editpart, which is then set on the root editpart. Its figure gets added to the root's. At that point the contents editpart will construct its children editparts, reusing the viewer's factory, which in turn then create their children and/or connections, etc., until all of the editparts and their views have been created.

    Implementing the Contents EditPart

    So the first implementation you will need to write is the contents editpart. You'll also need to implement a factory which recognizes the contents model object and constructs this editpart. This part's figure provides the backdrop for the rest of the diagram. Usually it doesn't even need to paint, but you still need to choose the layout manager and the figure type based on the root editpart. To control which figure gets created, override createFigure(). When using a freeform root, the contents figure must implement the freeform API. The FreeformLayer figure will suffice. The layout manager is often the XYLayout or the FreeformLayout, again depending on whether the root is freeform or not.

    During initialization, the contents editpart will construct its children based on the list returned when calling getModelChildren() on itself. Editparts should override this method to return the list of objects in the model for which child editparts should be created. By default, editparts go back to the viewer's factory to create each child.

    Implementing the Children EditParts

    The children of the diagram, sometimes called nodes, usually display some information to the user. Their figures may be one of the default provided figures, a custom figure, or a composition of multiple figures. During the population of the viewer, each editpart will have its refreshVisuals() method called. This method is responsible for reflecting the model's properties in the view. Editparts must override this method based on the model and figure they work with. In complex cases this method can be factored out into several smaller helper methods. Later, when we start listening to model changes, this method or its helpers may be invoked again.

    If a child of the diagram is also a parent with its own children, it needs to override getModelChildren() in the same manner that the diagram editpart did.

    Adding Connection EditParts

    Connections are special editparts that connect any two editparts in a diagram. An editpart is called a node if it can be the source or target of a connection. The connections are created and managed in a shared way by both of its source and target nodes. Each node in the diagram must override getModelSourceConnections() and getModelTargetConnections() to return the model objects representing the connections. GEF then checks to see if the connection editpart has already been created (by the other node at the other end), and if not it asks the factory to create the connection editpart. The source node is responsible for activating and adding the connection figure to the diagram.

    A connection editpart's figure must be a Draw2d Connection. The connection editpart attempts to set its figure's anchors by casting the source and target nodes to a NodeEditPart. The source and target must return the appropriate anchors or default anchors with bogus fixed locations will be used instead.

    In many ways connections are just like other editparts. They typically have properties in their model that must be visualized. They may even themselves have children or be nodes to other connections.

    Summary

    So far we have focused on just displaying a model graphically. This requires that you extend AbstractGraphicalEditPart and override behavior based on each part's model. Here is a summary of the methods discussed:

    • createFigure() - this method creates the editpart's view, or figure. This method does not reflect the model's state in the figure. That is done in refreshVisuals()

    • refreshVisuals() - this method reflects model attributes in the view. Complex editparts may further decompose this method into several helper methods.

    • getModelChildren() - this method is called to determine if there are model elements for which children editparts should be created.

    • getModelSource/TargetConnections() - similar to children, but model elements returned here indicate connections for which the editpart is the source or target.

    Editing and EditPolicies

    Once you have some editparts displayed it's time to start editing. Editing is usually the most complex task an editpart performs. Editing includes not only making changes to the model, but also showing graphical feedback during interactions with the view. To abstract away the source of interaction, GEF uses a request. Tools or other UI interpreters will create requests and then call the various API on EditPart based on the interaction. A subset of the EditPart API is shown below.

    Methods on EditPart which take a Request:
    1. EditPart getTargetEditPart(Request)
      boolean understandsRequest(Request)
    2. void showSourceFeedback(Request)
      void eraseSourceFeedback(Request)
      void showTargetFeedback(Request)
      void eraseTargetFeedback(Request)
    3. Command getCommand(Request)
    4. void performRequest(Request)

    The first step of editing is to decide which editparts are involved. Usually, it is some combination of the viewer's current selection and an editpart calculated using the current mouse location. The selection can be trimmed by asking if each selected part understands a request. The part under the mouse, called the target, is found with the viewer's help and the getTargetEditPart(Request) method. Not all interactions have targets.
     

    2

    During interactions, especially mouse interactions and dragging, editparts are asked to show feedback based on their role in the interaction. An editpart is considered the source if it is the part being acted on. A target editpart is the part underneath the mouse. For example, when dragging a node around a diagram, the node is the source, and the diagram is the target. The node is asked to show source feedback, which might be a rectangle or some other modified representation of the node. The diagram is asked to show target feedback. When reattaching the end of a connection, a node might be showing target feedback instead. Some interactions only operate on a source.
     

    3

    The command is what eventually changes the model. Editparts are asked for a command for a given request. Commands also help determine if the interaction is possible. If there is no command, or it is not executable, the UI will indicate that the interaction is not allowed. If an editpart contributes NULL as its command, it does not prevent the interaction from occurring, unless of course no commands are provided by any of the editparts. To indicate something is not allowed, the editpart must return a command that is not executable.
     

    4

    Finally, there is a generic API telling an editpart to just "do something". This is generally something that does not immediately result in a model change. For example, opening a dialog or activating the "direct-edit" mode.

    EditPolicies

    Editparts don't handle editing directly. Instead, they use EditPolicies. Each editpolicy is then able to focus on a single editing task or group of related tasks. This also allows editing behavior to be selectively reused across different editpart implementations. Also, behavior can change dynamically, such as when the layouts or routing methods change.

    When any of the above editing methods are called (except performRequest()), the editpart delegates to its policies to satisfy the request. Depending on the method, the editpart may stop at the first policy that handles a request, or it may allow each policy a chance to contribute. Refer to each method's javadoc for more details.

    During the editpart's creation, createEditPolicies() is called and the editpart should install the appropriate policies. EditPolicies are installed using roles, which are nothing more than identifiers that serve as keys. GEF provides several identifiers for commonly used roles. Roles become important when an editpart needs to have its policies removed or swapped out. The rest of the time it is just a good habit. GEF also provides several policies for use with these roles. Many of these policies must be extended to fill in the missing pieces that work with the application's model. EditPolicies are discussed in more detail in the section on interactions.

    Commands

    Commands are passed around throughout editing. They are used to encapsulate and combine changes to the application's model.

    An application has a single command stack. Commands must be executed using the command stack rather than directly calling execute.

    The EditPart Lifecycle

    With respect to lifecycle, editpart implementations typically only have to worry about extending activation and deactivation, which is when the editpart should add and remove its model listeners. Still, an understanding of the entire lifecycle is important.

    1) Creation

    The first thing that happens is creation. Most editparts will be created by the viewer's factory, which is invoked by either the viewer or the managing editpart which is typically the parent. Immediately after being created, the following methods are called:

    setModel() - If the constructor does not take the model as an argument, it should be set immediately. Other events that follow may be based on the part's model.

    2) Getting Added to the Diagram

    setParent(...) - The very first step is to tell the part its parent. This gives the part a path back to its viewer, which it might need for things like accessing the editpart registry.

    createFigure() - Although this is a protected method, the timing of when it gets called is somewhat interesting. Both the parent and the model are known at the time the figure needs to be created.

    addNotify() - Signals the completion of the child being added to the parent. At this point, the child will do the following:

    1. Register itself with the viewer using both its view and its model.
    2. Create any editpolicies that it needs.
    3. Refresh, meaning update first its own view, and then construct any structural elements of its own such as children or connections.

    activate() - Indicates that the editpart should become active for editing, meaning that the model might change. The parent only activates its child if it is also active. The root is only active if the viewer has created its Control. An editpart should do the following on activation:

    1. Start listening to the model. Subclasses should extend this method to add any necessary listeners.
    2. Activate all of the editpolicies.
    3. Activate all children and outgoing connection editparts.

    3) Normal Use

    At this point the editpart is in its normal editing state. It gets selected, shows feedback, and returns commands, etc., until it is no longer needed, meaning it is either removed from the diagram or the viewer is being disposed.

    4) Becoming Garbage

    deactivate() - The opposite of activate. Once again, subclasses should extend this method to remove the listeners added during activation.

    The remaining steps only occur when the editpart gets removed, meaning its model was removed from the diagram. If the viewer is being disposed, then deactivation is the only thing that is guaranteed to occur. For this reason, activate and deactivate are the commonly extended methods while the remaining methods can usually be ignored.

    removeNotify() - Signals that the editpart is about to incur removal. The following must happen while the editpart still has access to its surroundings:

    1. Make sure the editpart is no longer selected or has focus.
    2. Call removeNotify on children so that they can do the same.
    3. Un-register the editpart from the viewer's registries.
    4. Remove self as source or target of any connections. Connections don't go away unless both source and target get set to null.

    setParent(null) - The last step of removal. The parent and viewer are no longer reachable at this point.

    Editparts do not come back from the grave. When a change in the model is undone, a new editpart is created. For this reason, commands should not reference editparts, and editparts should not contain any important state that must be restored on undo.

    Tools and the Palette

    A tool handles most events from a viewer. The EditDomain keeps track of the currently active tool. Applications may use the palette (PaletteViewer) to display multiple tools, allowing the user to change between modes such as selection, creation, etc.

    How Tools Work

    Tools are implemented like state machines. SWT events provide the input to the state machine. Based on the event and current state, a tool will perform certain actions. These actions could include:

    • Asking editparts to show or hide feedback.
    • Obtaining commands from editparts.
    • Executing a command on the command stack.
    • Updating the mouse cursor.

    A tool is activated by setting it on the EditDomain. There is only one active tool for all viewers in the domain. If a palette is being used, selecting a tool in the palette will activate that tool.

    The Selection Tool

    The Selection Tool is the primary tool used in GEF and is often the default for an application. The selection tool is unique in its ability to delegate. It obtains a helper called a DragTracker from an editpart or handle below the mouse when a drag occurs. A drag is defined as a mouse button being pressed, its being released, and any events that occur in between. Events are forwarded to the delegate so that the drag can be handled differently based on where and how the drag originated. For example, clicking on a handle may result in resizing a shape, or moving the end of a connection. Clicking on an editpart typically drags that part to a new location or parent.

    Ironically, the Selection Tool doesn't select editparts. All mouse clicks are handled as drags. When the Selection Tool receives a mouse down event over a selectable editpart, it asks for a drag tracker. The editpart returns a tracker derived from SelectEditPartTracker. The tracker also receives the mouse down event, as well as any other events, until the mouse button is released. When the tracker interprets a selection gesture, it modifies the viewer's selection. Trackers even handle events like double-click.

    For more on the selection tool and trackers, see the section on Selection Interaction.

    Palette

    GEF's PaletteViewer provides an SWT Control allowing the user to select which Tool is active. It can also be a drag source for dragging objects from the palette directly into the diagram. Use of the palette is optional, but common.

    The palette can be placed anywhere, including inside the editor. GEF provides a Workbench View for hosting the Palette. Also, a custom Composite, the FlyoutPaletteComposite, will manage the placement of the PaletteViewer beside a primary Control. This composite is used as the editor's primary control in the Logic Example, shown below:

    The PaletteViewer displays a Palette model, which starts with the PaletteRoot. The root organizes the contents using either drawers, which open and close, or groups, which do not. Each grouping element then contains Palette Entries. An Entry defines either a tool or template for the User. Templates are described below in Creation.

    The Palette provides several display modes, such as icon-only. You can also provide a customizer to allow the user to modify or create palette content.

    Types of Interactions in GEF

    This section discusses the various types of interactions that are included in the framework, and which parts of the framework are involved in supporting the interaction. An interaction can be anything that affects the model or the UI state. Many interactions are graphical but some are not. An interaction may include:

    • Invoking some Action (usually displayed on the toolbar, menubar, or popup).
    • Clicking on something.
    • Clicking and dragging something.
    • Hovering over something (pausing the mouse for a certain time).
    • Dropping something dragged from another source (native Drag-N-Drop).
    • Pressing certain keys.

    This section discusses the participants involved in each interaction and what they do. This can include:

    • Tools which process input.
    • Actions which are invoked.
    • The IDs and instances of Requests that are sent to editparts by tools or actions. ID's are defined on the RequestConstants class.
    • The EditPolicy roles designated to handle specific types of requests. These are just constants defined on the EditPolicy interface.
    • Any EditPolicy implementations provided in GEF for use with the interaction.

    Selection

    Tools Requests Edit Policies and Roles Actions
    SelectionTool
    MarqueeTool
    SelectEditPartTracker

    *GraphicalViewerKeyHandler
    SelectionRequest
    DirectEditRequest
    REQ_SELECTION_HOVER
    REQ_OPEN
    REQ_DIRECT_EDIT
    SelectionEditPolicy
    DirectEditPolicy
    SELECTION_FEEDBACK_ROLE
    SelectAllAction

    No interaction is more basic or universal than selecting items in a viewer. Most of the interactions discussed here operate on what is currently selected. Yet, selection is a complex topic and there are several steps involved. The Selection Tool was briefly discussed in the above section on tools.

    Let's first define selection. Selection is a List of EditParts maintained by an EditPartViewer. Changes to the selection are made by invoking methods on the viewer, and not by modifying the list directly. The selection is never empty. If the selection is cleared, the viewer's contents editpart becomes the selection. The last editpart in the list is considered the primary selection.

    Closely related to selection is focus. Focus is a single editpart maintained by the EditPartViewer. Focus is used when manipulating selection via keyboard. By moving focus, the user can navigate from one editpart to another without changing the current selection. The user can add/remove the focused editpart from the selection. If focus is not explicitly set, it is the same as the primary selected part.


    Selection Handles
    The editpart is responsible for showing its selected and focused state to the user. The viewer tells editparts when they are selected, focused, or have primary selection. Typically, selection is shown by one or more EditPolicies adding selection handles. The handles shown here on the LED and circuit parts were added by ResizableEditPolicy. The black handles indicate primary selection.

    Because selection handles are related to how a part can be dragged or sized, which in turn is related to the containing figure's layout manager, it is usually the parent part's editpolicy that installs a policy on the children for displaying the appropriate handles. For example, an XYLayoutEditPolicy would install a ResizableEditPolicy on each child of its host editpart.

    Connections may (WireEditPart in the Logic Example) also change its figure's line width to help indicate selection. Handles for connections are contributed by both EndpointEditPolicy and BendpointEditPolicy.

    Selection Targeting and Feedback

    For selection to occur, the Selection Tool must first target an editpart using a SelectionRequest. In rare cases, an editpart is not selectable and targeting "falls through", hitting the editpart below. During this continuous mouse targeting, the Selection Tool invokes showFeedback() on the current target editpart by passing it a SelectionRequest of type REQ_SELECTION. It is recommended that most applications ignore this request since showing and hiding feedback as the mouse moves across a diagram can be very distracting to the user. For this reason, there is an additional feedback request sent with the type REQ_SELECTION_HOVER whenever the user pauses the mouse over an editpart. Often an editpart will display a popup shell similar to a tooltip displaying additional information about the part. The SELECTION_FEEDBACK_ROLE identifier can be used when installing policies which show such feedback.

    A benefit to using these feedback requests is that the Selection Tool is smart about asking parts to erase feedback. For example, if the user starts dragging, you would not want a popup message to stay around. Also, selection feedback will not occur when other tools are active.

    Selection via a DragTracker

    Once the user actually presses down on the mouse, the selection target will be asked for a DragTracker. To allow selection, return a SelectEditPartTracker or its subclass DragEditPartsTracker, depending on whether dragging is permitted. These trackers will modify selection at the appropriate time, taking into consideration the SHIFT and CTRL modifier keys.

    The contents editpart should never be selected by a tracker. The reason being that it should never be part of a multiple selection. Therefore, it should return either a DeselectAllTracker, or the MarqueeDragTracker. Remember, the selection is never empty so the contents part will be the selection when all other parts are not selected.

    Other Selection Requests

    Editparts may be asked to perform two additional Requests that are related to selection. These requests are related to selection in that they are interactions associated with clicking the primary mouse button. The first is a double-click, which is called an open (REQ_OPEN). This interaction can be used for editparts that can be opened, expanded, or may display a dialog. The other interaction is called a direct edit (REQ_DIRECT_EDIT). An example of direct editing is when the user wishes to modify the text of a label. The user must first select the part, and then click on it again after it is selected. After a brief delay (used to rule out a double-click), the request is sent.

    Selection Actions

    GEF provides a SelectAllAction. Given a viewer, this action selects all of the contents part's children when invoked.

    Selection using the Keyboard

    Keyboard selection is supported in graphical viewers by installing a GraphicalViewerKeyHandler. The key handler only receives key events sent to it by the current tool. The Selection Tool forwards key forwards the events necessary for selection.

    Drag trackers are not needed inside GEF's TreeViewer. The native tree handles selection already, and dragging of treeitems is processed internally using native DND.

    Basic Model Operations (Delete)

    Tools Requests Edit Policies and Roles Actions
      REQ_DELETE COMPONENT_ROLE
    CONNECTION_ROLE
    RootComponentEditPolicy
    DeleteAction

    The only universal interaction that all GEF applications should support is delete. The workbench places a global delete action on the edit menu. All applications should register a handler such as the included DeleteAction.

    The DeleteAction sends a GroupRequest of type REQ_DELETE to the viewer's current selection. All editparts should have an editpolicy which either supports or prevents delete from occurring.

    Every editpart is either a component or a connection. A component is a basic editpart that is the child of a parent. A connection is slightly different because it is owned by its source and target.

    The COMPONENT_ROLE key is used when installing an editpolicy on a component editpart. Applications can extend the provided ComponentEditPolicy to fill in the commands for deletion. The RootComponentEditPolicy should be used on the contents editpart. This policy prevents the diagram itself from being deleted. Here, "root" refers to the model root and is not related to the viewer's root editpart.

    The CONNECTION_ROLE key is used when installing a policy on a connection editpart. Applications can extend the provided ConnectionEditPolicy to fill in the command for deletion.

    These editpolicies should handle the tasks most closely associated with the model. In the logic example, this role is responsible for the LED's increment and decrement behavior, which adds or subtracts one from the LED's value.

    Implementing the command that performs delete can be difficult, especially when connections are involved. The command must consider whether the object being deleted has connections, or if children of the object being deleted have connections, and delete the connections as well. But, you don't want to delete the same connection twice in cases where both source and target nodes are being deleted as part of multiple selection. The logic example's delete command addresses all of these concerns.

    Creation

    Tools Requests Edit Policies and Roles Actions
    CreationTool
     
    REQ_CREATE
    Create
    CONTAINER_ROLE
    LAYOUT_ROLE
    TREE_CONTAINER_ROLE
    ContainerEditPolicy
    LayoutEditPolicy
    CopyTemplateAction
    PasteTemplateAction
    TemplateTransferDropTargetListener
    TemplateTransferDragSourceListener

    A CreateRequest is used to ask an editpart to create a new child. The request is identified by the ID REQ_CREATE. Creation can occur through three different methods: clicking, dragging, or pasting. The request provides the location, object, and object type being created. The object and its type are provided by a CreationFactory. The request hides the factory and provides access to the created object directly, caching it in case multiple editpolicies all need access to the created object. In some cases, the request will contain a size attribute.

    Producing CreateRequests

    The creation tool provides a "loaded cursor" mode which will attempt to create an object at the mouse location when clicking. If the mouse is pressed and dragged, the tool will track the size of the rectangle defined by the user. The creation tool can be placed on the palette using a CreationToolEntry. When the mouse is released, the tool will either repeat the process or switch back to the default tool.

    Creation can also be performed using native Drag-and-Drop. The drag source can be anything, but it is typically the PaletteViewer. A palette entry taking a template is added to the palette. The TemplateTransfer is used to transfer the template, which is just an Object, from the drag source to the drop target. A TemplateTransferDragSourceListener must be added to the PaletteViewer. Similarly, the viewer must have a TemplateTransferDropTargetListener. Since a template is model-specific, the application must extend the drop target listener to convert the template into a CreationFactory for the request.

    A special palette entry called the CombinedTemplateCreationEntry supports both the creation tool and drag-and-drop style of creation.

    Consuming CreateRequests

    The target editpart is responsible for showing feedback and returning the command for creation. GEF provides two types of policies for handling creation. One type of policy is specific for the view in which creation occurs, either graphical or tree-based. This edit policy corresponds to either the LAYOUT_ROLE or the TREE_CONTAINER_ROLE.

    The other type of edit policy is specific to only the model, should applications wish to separate out the portion that is shared between graphical and non-graphical creation. In most cases, any kind of shared logic is in the command implementations, making this type of policy unnecessary.

    A LayoutEditPolicy handles the process of creation based on the container's layout manager. For example, if the XYLayout is being used, then the resulting Command will need to associate an (x, y, w ,h) constraint with the created child. Layouts that don't use constraints would require that the index of the drop location be determined. GEF provides abstract policies for the basic layout types.

    The TreeContainerEditPolicy is used for supporting creation in a tree-based viewer. The policy is responsible for determining the index of creation and showing feedback.

    The PasteTemplateAction can be used to create objects without the mouse. This is important for accessibility. The CopyTemplateAction is added to the Palette. When the user invokes this action, an internal mechanism copies the transfer so that it can be pasted in a viewer. When paste occurs, the PasteTemplateAction retrieves the template object, constructs a CreateRequest, and sends it to the selected editpart. Mouse location is not available in this interaction. Paste is only enabled when the selection is exactly one editpart.

    When a creation command is redone, it must restore the original child that was created the first time it was executed. If it creates a new object, then subsequent commands will fail on redo when they try to modify the originally created child.

    Moving and Resizing

    Tools Requests Edit Policies and Roles Actions
    DragEditPartsTracker
    ResizeTracker
    ChangeBoundsRequest
    AlignmentRequest
    REQ_MOVE
    REQ_ADD
    REQ_ORPHAN
      REQ_CLONE
    REQ_ALIGN
    REQ_RESIZE
    LayoutEditPolicy
    ResizableEditPolicy
    ContainerEditPolicy
    AlignmentAction
    MatchSizeAction


    move interaction

    resize interaction

    The DragEditPartsTracker extends basic selection behavior to allow the selected parts to be dragged within their graphical viewer. Dragging the selected parts can result in three potential interactions: move, reparent, and clone. All three use the ChangeBoundsRequest, which extends GroupRequest to include a size delta, move delta, and mouse location.

    While dragging the selection, if the tracker targets the part's original parent, the request is typed as REQ_MOVE. If the target changes, the interaction becomes a reparent. For a reparent, a request of type REQ_ORPHAN is sent to the old parent, while the new target is sent a request of type REQ_ADD. When the CTRL key is pressed (ALT on the Mac), the operation is always a REQ_CLONE, which is only sent to the target part.

    All of these requests are related in that they require the target to process a rectangle and a mouse location. The LayoutEditPolicy is responsible for handling each of these request types. For layouts which use constraints, each part's original bounds is taken and modified by the size and move deltas to determine a new bounds, for which a corresponding constraint is found. For index-based layouts, the mouse location is used to establish the new index.

    A ContainerEditPolicy can optionally be used to contribute additional commands (not related to the layout) during ADD, ORPHAN, and CLONE requests.

    Resizing

    Resizing falls under the same category as changing bounds. Note that when resizing either the top or left sides, the location of the part is also changed. Resizing only makes sense for layouts with constraints, such as XYLayout. The ResizableEditPolicy adds up to eight resize handles to its host. When the Selection Tool is clicked on one of these resize handles, a ResizeTracker performs a resize on the selected parts understanding "resize". SHIFT and CTRL key modifiers can be used to constrain the resize operation.

    The types of handles available on an editpart depend on the layout manager in which its figure is placed. For example, parts inside a table might have handles for adjusting insets, padding, column span, or other attributes. Some layouts don't need any handles, but four corner handles should be added just to indicate selection. Dragging these handles would be the same as dragging the part itself.

    Because of the relationship between handles and layouts, it is recommended that the PRIMARY_DRAG_ROLE editpolicy be installed by the parent's LayoutEditPolicy, which defines abstract methods for this purpose. If a container changes layout managers during editing, typically the layout policy gets swapped with one for the new layout manager. The new policy then replaces the stale PRIMARY_DRAG_ROLE policies on each child.

    The MatchSizeAction matches the size of the selected parts to that of the primary selected part's size. This action is implemented in a way similar to manually resizing the individual parts, and it uses the same request and type.

    The AlignmentAction uses an AlignmentRequest, which extends ChangeBoundsRequest. When using a ChangeBoundsRequest, the part's current placement in the Control (in absolute coordinates) is passed to the request, which then returns a modified version. Using this pattern, alignment is able to adjust each part's rectangle by different amounts. In most cases, alignment can be treated no differently than a move. This action aligns all selected parts with one of the edges of the primary selected part.

    Connection Creation

    Tools Requests Edit Policies and Roles Actions
    ConnectionCreationTool
    ConnectionDragCreationTool
    CreateConnectionRequest
    REQ_CONNECTION_START
    REQ_CONNECTION_END
    GraphicalNodeEditPolicy
    NODE_ROLE
     

    The ConnectionCreationTool is used to create a new connection between nodes. This interaction requires the user to activate the tool (typically using the palette), and then click on two editparts supporting connections. The creation can be aborted by pressing the ESC key. The ConnectionDragCreationTool is similar, but the interaction is a single mouse drag. This tool can be returned as the drag tracker from a handle or even an editpart in some cases.

    The process is separated into two parts. The first part is defining the source of the connection. The source is a node, but it may also include a specific "port" on that node. The tool uses a CreateConnectionRequest identified by REQ_CONNECTION_START to determine the target editpart and ask it for a command. However, this is only the first half of creating the connection, so the command is not complete yet. The tool will not attempt to execute this command or even ask if it is executable. This command is only used to pass information to the target editpart.

    The second part is to define the target node for the connection. The tool uses the same request but retypes it as REQ_CONNECTION_END. The command returned by the source node is now stored on the request and passed during the second part of the interaction. The target is asked for the final command that performs the entire creation of the connection. Any command can be returned at this point, including the command provided on the request, updated with the target node information. At this point, enablement will be determined by asking the command if it can be executed. Creation ends by executing the command.

    During the first and second steps, the editpart being targeted as the source or target node is asked to show target feedback. The editpart might visually highlight various attachment points or simply indicate that it is the target.

    The source node editpart is also asked to show source feedback during creation. The provided GraphicalNodeEditPolicy can be used to display creation feedback. This policy will create a connection feedback figure, and set its anchors using the NodeEditPart interface. This mix-in interface for GraphicalEditPart is used both during creation feedback, and when the connection's editpart is created, to provide anchor points.

    The "source" and "target" nodes should not be confused with "source" and "target" feedback. For feedback, "source" simply means show the feedback for the connection, while "target" means highlight the mouse target.

    Editing Connections

    Tools Requests Edit Policies and Roles Actions
    ConnectionEndpointTracker ReconnectRequest
    REQ_RECONNECT_SOURCE
    REQ_RECONNECT_TARGET
    ConnectionEndpointEditPolicy
    ENDPOINT_ROLE
    GraphicalNodeEditPolicy
    NODE_ROLE
     

    By dragging the endpoints of an existing connection, its source or target can be changed. This includes changing "ports" on the same node editpart. This interaction is called reconnecting.

    A connection adds handles at its endpoints by installing a ConnectionEndpointEditPolicy with the ENDPOINT_ROLE. Each of these handles returns a tracker for reconnecting the corresponding end of the connection. This policy is also responsible for showing the connections feedback during the interaction. This policy does not return commands and therefore is not abstract. The reconnect command comes from the new target node.

    As the source or target endpoint is dragged, the tracker sends source feedback requests to the connection, and target feedback requests to the current target if there is one. The tracker uses a ReconnectRequest typed as either a source or target reconnect.

    The target node's GraphicalNodeEditPolicy is responsible for showing target feedback and returning the actual command to perform the reconnect. As with creation, the target editpart should implement the NodeEditPart interface, which allows the ConnectionEndpointEditPolicy to snap the feedback to the nodes anchor(s).

    Bending Connections

    Tools Requests Edit Policies and Roles Actions
    ConnectionBendpointTracker BendpointRequest
    REQ_MOVE_BENDPOINT
    REQ_CREATE_BENDPOINT
    BendpointEditPolicy
    CONNECTION_BENDPOINTS_ROLE
     

    Certain connection routers accept routing constraints (typically a list of BendPoints). Install a BendpointEditPolicy using the CONNECTION_BENDPOINTS_ROLE for editing the connections routing constraints. This editpolicy requires a router that takes a List of BendPoints. During selection, the policy will add normal handles to existing bendpoints on the connection. It adds smaller handles where the user can create new bendpoints.

    Each handle provides a ConnectionBendpointTracker. This tool sends a BendpointRequest back to the connection editpart for showing feedback and obtaining the command to perform the bend. For existing bendpoints, the request is typed as REQ_MOVE_BENDPOINT, otherwise it is REQ_CREATE_BENDPOINT. It is up to the editpolicy to determine when moving a bendpoint back to its natural placement should result in its removal.

    This picture shows a selected connection in the Logic Example with a single Bendpoint. The ShortestPathConnectionRouter has inserted additional bends in the connection to avoid figures. The handles for creating and moving bendpoints are labeled with the index that the BendpointRequest will contain. The index is the same as the current (or eventual) index of the bendpoint in the routing constraint's List.

     

     

    eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/guide/images/000077500000000000000000000000001166301720600225675ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/guide/images/connectionhandles.gif000066400000000000000000000036661166301720600267670ustar00rootroot00000000000000GIF87aZ1 L  $$$4 444D,LLLTTT\\\dddlll pb, > hb2ɔ-3Ƥb:D$m֨I͆K[ô|wĜL ձMum =7,]v5evȽ9;pWۿf! \y'V}d6^7=S̱aT9RMXχ̼I&?+".#L3BS#3@)eϑ.M 5j] 2:e3pɗ}ϗЈݐ)JysR&MRhn"1o: 1p&!ɷR|'$2̢ (41*̣D.ˤؒ!Wjǰl-1t7)WStK9UoZT'կNNSTX8 |{DUϫY5_XU{#;eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/guide/images/editing1.gif000066400000000000000000000336031166301720600247670ustar00rootroot00000000000000GIF87a41        $$,$$$$$$$,$,,$<$,,,$$,,$,,,",444,444<44L4L44T4$<<4D<4\<$4<<$L44<<<<<qZ ݨz-JL3ɦ.A`Ң-j*]) a 4KHMdlthJ7 |e v3m_:0_tS $^Q JJ74|큉Cȥ kO7NhBb [HŌ"u]7AQ0._1~Ƹ~yOY0 D92GxHZd ,`e 14_@-nڱIY D hax`3DF=)@-2 "z8h`Ȯ p'tQԤ024a(G8S~VfAVjB a?\H@ 2`ș+& ǯ1&XfH әO!5@`!1 и%\QƄN_; NCsbJ0d0d .+h%12fFD" ^M&ɞCaC耞gD*+54|DIJڄҕMεaQhݤVCI]jhjX $z,:DG4",r Ltl@bzTMb silA|F\ Tp.w%A"W!xBv G b b"]6 `CʃtP95`[kE$rT +$V,nHV해m [?.D@ wΡ h 0$ 5XAlŦ=y0/8$TD#^tJ:Q@5L:ϋ^$0 AP:np@_]5. rR3X RA|c"CGP"A-#pU4QdIa~~ޙhhD- (E27>@H|G] w|Ϸoaj`AP 2 02%ܷma P`~.fcWWJGnnPyPUw (J0) gQ|'7PAo'@M)P&e 8"͠qV]Q(qP i@qW u aDwp)@o xF`J`{P Wd[ /.[P $(60 F55= 0y'+e@iksT(t 3P x،8 `*ـ@$12]T \:p8 9%MisbK0P f0w@\`idԸPi&RSj]1͐uB<IΐL9pl@ PS`X:p38 @ O!K>?qS!@ Д6oRYaG۠ 35̓ af=b#=e qM^ &d Tg5 8 q Sk> ^V< p. @7ww e@^! XL$  ԥIMP`0)S4 2hР ^q!x$)Q#H&w ;gyf!{k;k@]a0V'geV QуG: Qz fCG<L83ڧ^QΪ;ዽ; }:kdkd} {w ZTЭ *>K_ kRN@'i`*2PjIP bfzw ϣL$̅0# \+-4*g;#0 P,̚z++Al )?L9Lv35\% ct% w' pW crH~F |8 бܧ܌ ||̙*+N`erY`q.P䪓*$`Lc~gLP{@W 0% ]Чl{g|lg/3̓poɰ,氣Y;OOPK̆:Fܠy0): K XeS S^4T7px%q"g0 2༃pӅ*ۻ`|?n)AIԘ= PkJD_p t{wTRp<Иg׋ …K: x;P :P~:]؎%]٥ I4A fE pZ08t7cW݂&E'<ǷIi0)@ s%~zv쎝 AUN>2UA2} uqJg_wUPM@}M+:I!QŮn !GiLa0`!0 PZ RQMP ,xWP ``(f%5g㪣y@` 9_&'0Up|о`@z` 0JLVRP,~B0 3@* Ca QP}5P%+@4|// /mnF4qS/@oΐRwfa o;RI D@q & paE &Xq!g#= _! ]t@5mSN=^dePEEjɹAM>UTNK%Ú̚\G|:AM!V-HIݾ|UEn){0lSR0)sX wJ;b#3'mVfΝ=觭j숕3W;6ڴo}v̟3| /a~۴6Xa' SpUnAЙoͿe*RY="ײgvk~iI(Kz;$MkL@ ̄x.ǣD#(0E@>t/ a?wQ-r`JL1^0B:c.d.C).10@iD`2XM7ߺcG;ē?8JȵL 42(6CNȉ)°K/ rBI=|  x3UU$OWb_vo7On5]uM$ ~7a1Jac~: 8`KI\FUeUq͕Iz9M KҾ4a#+ *WX*K[.I"H(@iȠm%MdW^%(V9;ˠe+[l<(жB@IBE@\q֠4Jz{ݼ%<} 7p&;EMt:)Nt+c+. hZ@8M&L+E 5S3s8!a(4#@:wNm!BrPWU ӟ@gɂy) 9 ncCH -\e4]B 1`Nv!ܞ F(2Hcvnv 9V(`3ࠅcWE 4Ur+tB #M6ƑAp c |i@qL5 "OP>t8C 7+ 'y d˃؈M5 RN`.hC(iM0.sY$$ ! Ňqx ^Ҁڰ2 /qp9@ ^"VP la-2A r-3| '1iyr&< .kr6¨D=4 [q$95C*}#@$1 C VVn/g0j@͜-W5^b`G1HC5 I)5q e8X%p_wnHXv;K %{@( THVMԑ^UDb#Iy?*-P6vp4) |O .!'5Jc [8 * Igx#]cC?X.>3H#&$ ǏOY8 :52O )*<2-{̝L2 q`6k sEE; l'H~lϐ!l6EKWLPf=rWi$4ЌeҬ&!z[2;drf$`|6[ (--*Tu$|7(͐Bl.J\ ' &r'>T\@tau8i X5E 0fA~bidB`mE:oރHoPfKxl0kqtM@ڲÃIȨ˓ΡWoGd"iomv&9@ABUToY.;N h q% Q ]S2Bej yC.d%8'qFdT<@Ua-oSq{gR.@ta;舏贾 |몃؁i<@ྖJ+f`-:rЂ`>`a8 ؃?!0Èpj406gK@xNY# qA.Ff@;?h5.,AzZ pI9CˉRytxV<*0>~`*87'&3%uPE,r g-h)4+Ć9؁J.t kR쾲…b0Sc4{ A8_;pbL, M0 Kj/1PC󌎳uk)Z 15.ȃ9@>uC+,<0C?6LY9 OEcE8Ȁ @(Fyk8 ! nI1hć33D!4K _P GZ(bsGrGZ@S"VG7A H`d`k_`JSep } sh[~?G gPH+\ޭ XCϜ K|c;HЃYcM@HRshV\7 `D(  p1n[MȂYh dy۫ h(*<2:G73(J`P^(n` }E(&{dњ7Z 8QȾ3a-j>iA@ne9iv -\[vs>ԅ [+hkMP ĚZ07\0xJ8 !~JAXHAb`^l^3P1^f9ޚ[bTXp00ܝ+t%×X淹*@g򨴫^HE@k; phK@?uзx3b[Y[^^e&nf\]%kŦ银cTY^nЁ*hE*J@$;auΘHU53z 0]mEȀBm w 2؈ J^]Ч:l~e\.f啮li QV_im$Cv ÃjGf@@A^,Ex "} 2 }5b0A߶p"Ax[0o _[i7nq_cnb26c-~$a2Z>kX+Np 0DPb`PfQ&`K2m!jL-@T .ck_`vc_^fȶbi<,0TD&=2.gtM T ?dns(~xvPfu wX~Ռ[eTC⭩^;iS@]pmb7>% /8?bU'aO_PY0n8Y \(ۣXs^G`Ʈ:%j(- M뵶pyYP<Ȃ3`e pgZvhu.08h >H8唊Jx^U, < Vh]腶v[@ePxUn{Bz  X#+3%'tEPy^LA08U V~>X#8 K} U?%V@I^mwJ(S%Ng۷z^=fpK„, j@Pƌ7r5Đ"G,i$AH%̘2gҬi&Ι&Y@ rPY-E&b5⭜=L+ذ j,ڴje"X{ U(*@ Ua( LkĊ7'SQ@ p87tn{x/*KREV⵺a p&:d)7uK;/KfÒʗ$'P%=׹"=PTqcMdF-2Jzcsabd)n>JiꬵQS>H01)hFZBj fp=P( %SP+Ϋ5D a=6ek| _&P[+ sF 8FA~|<n;]+&g+YԒ0xM'26N{jVJ< i7Ybj' @  D x?Ap)@ p(:Edb)6$3Qa׻ޅI v9ut$ aFH 'I_4C`$k"P4jq U6^D،%]BWё l,pC(R pCSYc FJx&Amw @I (#VFxO$ hPB$(:'%B,!(y cVHiTN9"S~,缌 Wȵ$"FKҢ؅&)9AP 2 80$W(bGpm}7bvN0caꕭBb>Iq[r`0P3d4C&& 3=FʏΣ6iD:RtQΘ O)LE@S 4[BCuPDP@* #Z8" d`9yPBIcB8R(UV’0BlP)G \Pڈl B Ѕ-$ `BR KQ¦:p̤dd#Q0}S1b9eL¸R)BnV[q7!g‹ SX&\xՁCG` !àAweіpFVn>=@ɞ1cB3.   0B@sL%,;.X8_A>y)!Da0 P.BA9Ybn89.9FG4ΪY43ZAf o J<@Фb @P1PpCqyrrYӚ#y^\;@rHb x(3esl<,mj־6jB+`0 E N&eer PVO~}LmFp頍B,Y Q@zsy s#3` @3`eBD :v6 TY&xO,P'Dni>s -Σ.u@Db lT [$cA`AAz#%4w:iE(E$=rQ2`i<0߽=zr ~:q vx`9HO" $}m>s'" :_t0Ala Uݚę e<VྍO$ڡʯ4qF͓ҝ`?!X5G#5 DZ*@ki+5&HA;TS%V 7ڤ0BuH~ uh4!p ;d3\MT]3PP :T" @H/ PM=AI-rX*h 6} d^1m%1Uiy¾A[͏X"ABlkI S[*#as4iOv d pA\ M&;t#3\A$?#@)ܳҥо"{WHa܆0Z}ŃH`XkPIB>;sAo3Al̍M7*#V4 ,Fmmػ%ƺP 黅<ó[|n@ʊ0`@H!F w cMގyC4 .0oմa' u" a~P ;!4KH! M?[H`5$'" ux@Hl!WDO6JUD|Fb.թiY.n@/Hx#|Ym`&l[ m8p(!Xvf&. vy6 Xъ9[!Af bt®B: Sg(Hj@< ^A nptQZҧH &ە+[:Lx0`-jh f3j- 6c$(W" 醾BOBX8.62VJ墀]+Se'RA2AZXւuG+At)]R!B]D%#oH` 9;&S" C)b> l"@\$ / mUY7`ϐAA,!6^K=kfJٕ0 MШOB4VBgdHhrjh,nFU 5RP%+V0 KALISE ~Ɔ"(|4pشhqVP!5PhH0Czxe&0*G3i㑯$ ӌH2'*r,Ѐym(ʘ\K&p% a _Ʊ ھ^-̬r jMiҖhݮ†B8UW\#ult`N&v0",&Ha ގy kb>vƋ6*A `4|kU6jr+ʪ3cNGi_a-&7XE!݀4"Y&MrGY[ T @5Dt+4 2k?O\ f8H:ZB1?IXZyMi€Q;Q#cWys@XUtǙt 3x-nt9}x8W:|"`9 @P/ R Нم=}tW|G.Qw< IB=P^pBv6EJv cӟ;,m{v TKZXVOڈӍDgF7v|\>GP ~B r}sN WEtUjgWRRq@V_}1D`vai X?r#`E0b'qװ:H zp@h7S??VA?,!JXEǀ=?bEJW7U4cXzP0F&6('gol>PxA z u 3# puPahex$+bPUsU BP@ ?@50 ]۰UfU5"p>y QQ ~im 1 @A  -zVP 8v(r)xWigI|!s~ATCCp0qM VP 40 0 0$9!4!ibv2@7.p4}1p]2HSp#( +Ptw!k燐FnU9J:iT4/iոk --/`Y `4FU-A:>9q~rҬ~xva ӊ;1v$HIbv뵞jT +3* -w|`ҡf  {@0p%ЃwHtVw(Ddqe$ᤧ:~ʋpQz#1&4AP.br) fJ +ڳ0pKf /*`.ִ6nm$7< \BFҡ۠骤  spRZrk4Ca=P 04  f^dѪEH8+ (WNId4q(}H- l㩓T wtz* г 0 г}+  FH=V493vO{@ho#=AC .4-@#rz@&RA|?HpzX<вE)@ґY p^0  } _#_J ~4~X%3;ڳ0>o7%u0_EMS (r޺;  ϰK@rC :7+ʷDL[j@\5#g($O4$K1BO4և0Zo - ̰@!I9Uyp -ٻ f?KΛHQPADĸ3+:huZdLc!0۰ژ#a wP}4QtP `-" , 9  <g+70 A4bnXʫƪc6B.Fݹ }#f `#86fL0 ,?02ڳ00VC0C#E"%gNpbRkhC#@9 Pf Ҫ9 =: 2j 0 Pc+@4` ЀIΆl;vu2N*Jg% N ԻQr u(;*q`2: Y 0`- > 4 Ѐ?R7S7A[׽DZQE)\Mꁈ'x>P5Q ܠwP̰J&!C񛙀.B 0D!QyJf GD%H a@: rXI(w ?,HWuCYC+`R$t_CaY>@U; (Bph .8C )`DËЂ85aKtw i[YЗ_ 5&lcm+P1;_XԷ` \lxB׬lYHXtX3)d[0(ř0*r-0 : *Fx 6X q#NAHƁQ L~lJ쐲{(@ ЄyG؇?A+`%)Y [1D,9R8#u C @yrx"Xb8E [BHFRJ+%S :",MmB!2fS瘎 TnuBZ<Aw4#B[%"MNt p"GP `5Gi . t pC$j![P֖j BÛG" Ql<(Cl;]\YB0Tmz=`C^IakY.dA!FErݫwč 03ࠊP.v@ڔ6B2x!mS2M΅\.ߊ 8ăai)>0 OJ h 4 7^A( DZ<Fu  81d8 AKpFdJ;C6}G ZIP8,pY! j<1,H} P?<œ6zH -^Z[7g;K cu g Όi-GI r Gc/BZBjPAvARSBe`s2h 1i%pGxtH$?C`:>80 ;eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/guide/images/factory.gif000066400000000000000000000510541166301720600247320ustar00rootroot00000000000000GIF87a#1 Lt  $$$$$$$$$,,<$,4L4$LLLt/)<,$D,,,,-):t44,44444<,4D<<,<<4<<<<m ˟?t0+[25 tRfnb lW |Vg*ńfly]6c m . t@7E\z&$ؚa {ZB%F x;Fy )t qkHy\F\Z#٥E\JR]~y'*Z&zA8}rS$!M& ftޘBa*:+y`#-Sz`Z+UwRWMޟͷkrM8A:lTXH9^+1Q:QΞoYJtN)p:l 4!Nx@CAiEpK`a kd|Fy1 T`PA |`*# E\E T`3.q  ~ !UD@,CQl8P$ @ڀ60#6D0;N?`FPD1) "@1 0LFpFȠ(ؑ sǻ1tPB4(Rl$@q} `( k+>Id %,Iq H%I1JB"KI[  ,d3JqdnZ%"g,@7 0C׆dBlp9DiVQeȺP`? &hU^T;۹P""JQLCzG@X(JxGDP2 PX*"t'b0X@A _o% !AQtvHAXTaP]xE0@НJPc=&H%:a 8*RçT< 9i,2hcŠ֠4@0b @@ jT#@PWVgP!o@T=`U7#g#Θ ԃ-5VWs e[`RHkaNo`q)N@(NhBʰ ּʨF7V 1]Ӯ`G2 D\(TcˀaNL )b˫N($J4 z$ _IW0,N NUw݌aU`[*cj0@]o _c`Ge c-.{`l1W!#"A>(W胹c X*~tm ~+(y=M$:a  (rc$` hh>9؃A8d3çYs7k &vzH|p]YsFgc3(O< 8g ?x~dxxXlW |~*8}#It&V8a@pB4u ϓQpy"(z8Wp}׍ޘwz(vHQ(n"0Xxg lZq[0EGwP lT  \qm " vDPh$g۷F ϦP 7 O~, {vX>)q)!mYv"_Eq3Gz& (Ch^ / tpuiY)A X0zi|iҠ I8V 8U4zv3b簙d M9)Lx` ]WfY\(nzD~[q6kopkik텙0 9 ֐oMP Y lY   SPD y0`8 ifB˩F[`H9 y`Y йݹMy\9ė q\*ע.J n3] p=OI~*Zl ɠlZ@lU 9}Ed`F`Y4h(Y EZ痙JJL1uIV 9' 'h@1光Xz jE\p* pdy$?/puט z(njej:7LqTzV9jւz})8eSZԚu S!Ī1Ԙ]da Z]V Pa vA%vŏ`1g}GaAuQ5-5UYw[y"5ĀlZ-/KYu#p5v?Ql' (@"#,a!%#Y" a_+ uOA;RuTk- ѵ=b0t%Q# um+rouq;Wvv{'xѷ ѸPvPk[`Qw[2K+w2#y{Q*q,NQu`[ q+k/]ۺ"!3;RXkqë+!}${ Q2R1lk+n;;10!b综)*1vKO!YG(ᶿWڿ[ "`{7\  u"q !F[ {k*2,1 ,&(Zlp[[&%ϋ#5|}w?+ĆKġۿ-A'{!LN¼ ҸN2WLsXnpȹRZ\Lb Zȅ\Tq&\Ț_S+>&ɚD)nnɛL ē,*!Gʏŧ\'`!̭<Ĩ\+ .T[~̀4k AfǸ,"An ' (|mF\ `!˫'\K[f€vϱ\\7,7Or;T1W z&<]+ŀ&KL[&ҋ^0VQV ̀!)컵c\] r-(c% 8 < H@DPB >Dh"-ZFv,XK*ڀA7Y(A_9@;A(%ETRM>cTN%-*թ@E,hCJ@7W$sfͲ0sڼ0KK}J1 }iW "pRbJWkFKvZ2Yjy'.䇌r|Úe i֭](les\sMR X…k g킌F0#G sխ?}]{s 2V_N.>y6a@W{+]~dL9aɁ# ,LfPpBGBOLDz?VN8golHEEpH"D2IH&I'nJ*ĒF+mK.?/ÄlL2D4\M73夳<0< PAmj*O@A4QEeQG4RI'QEԤ*J7SO?R5TSOE5QQr^5VYgV[o5W]wuU Wa%Xcw`eYg5٤Z-E6[m[o7\qVr-We]w߅[s=qx7_}l W=_ -Oo\s߀8WĄ0ʭ [آִkb[0Dowȧ}.S4V=s_k3CYbzyLIRp ]Qd"*˜8oNsSh}d3_{>v: 7!ѮEp02ër0ɷB Ax7?D4x{.|O`wSw>*o0e`[ =o/F ^YaD^z - AbSy<ۻZ ]3它68oB3Όp:+;K+SX뼔k#F;mXs?8)Ⱥ?j ?^:kGX3@x0 ?,@$:sw]>CA  ?@B+ 7Aab⹧ (B]( KF8tBȥ ,B泹",x(\ybHC%@x߫Ad $[`:N:B[a/<@A=8D\ 0 5DH=() FxSp<9CB;8 $= 4Ջ ۊ$?h[mEF4Xhŷ4EK\sQt>4@,cDN;ĴC(2VjupSL;m6[{G4N {4`lp:؂))pGB{7D A tFBUL#p~ l%LG8|W<א>c )(")2UcPƽ7@_S@@E =xCIY9ȀlFVtb bHI;T [M4*9a:3-ІE{Ɔl&Y>ҐL$4bhHLB#;Ѵx* H膹;=Ђ dHK:ɦFD8PDaCsXX?HcSX,}@8ДC@< L-h8lO{H8HhJpӆu, L*H4M0dd",Xq!`pN[#ص-8dHO\O4O\N,GC܃lXb̃@gϙc8m2BIk8SR[`҆ŀ=ȿp,-.$ƅ07hCxDΪцsQ@ΏN򜊓@:}Q$@ V;{7˼RӴT@ii']ұ:#$K%LT@O TГRI@U;xQMPUOL<2r/^u03]8}l\@{@QBӵS=Q[c>a:ѼzpUXUUeKt5Ustrs}XNMMbTJԟ*--hBrE0am4cb3LɍQ-Q5nȋc`Db}ߤ`=:e 02 h0w[G-()J4.B6deU~HcGNbX䢳dfC<♻͠ 7T[nه+ei((b K]8DB]K"KoV1F՚nn[ V C# 8cإkD[64dBak~hSfċ f5 ku䨈gDѫH8姤ّg&S0vj.Pio~d2bch7@Dc= ֌?_&j(eFh!k謦D94xnHDV뤮w>hj:cI2`J_3J,r놫cGd=HZ.鶆~onV& hhZ4p"l= F2(dPnCm`8 Tm_5k vl7РJ9 DEDivƑn& Fq6bS(;t_Ꝗϑn)nwf Ʈf6:X#(};; iNڮCD$(Y"p Vh"ƌ1*h#Ȑ"G,i1Pr&WlR"I^v#y铤)Cj*j(6LS9bDjCrS`J٘3]B:Ξh}@4)^^R4v.ɷ`͢0sn,V'O+8s|LQeYd 'nxӒUˮ2?Ƶ ϠSӶc _*Mֹuٸ[Vw;sv>'nX FufN;Um3|}ogٽwrgwwEwuE_T7}w, 8bQ2S9NI8|f8~3jI)~l@"l"{]8׋0F'ؤc8cI<.@hOT6bYOLBSgR%%I^dev%|ec%IkJiZ+eHnuFA' VY 顅jK:P0Ʉ)Ug79֞7zӟze&&FXpS\ʨHjm| v:i4KN *@hC0,#q,+TJ {2A+[CP; ;V-˒eC̹$I7{X<1E"tg6b 1{{$({+k0b&u[\1B~yѳ$ IJi2yO øju|1]0? qhI4j'VHL<2$R`6e/ supȩC>ط^ʇa ɊMU"jSRڀ@ZjĮ+ @V+c0TX9W(֡d0 Tuq-p"@ԡ)X#ZZF"$UG)n@(V X,XۗDEdXC3p fq FmK,UF- @ 0̷2yeKg?(i Dӆق p`b Z؂ Új#F݂gyE8|1-羋g7;@yxfƖ?dx&aDX-HS94%ԫ{"1{d/[X*\:l!9EYV b40[  @AVu-`,@8LE0s !`ހu4[#|cԨB2Z]׾5 84ϸj)E2\3TA 0[IYp0mT Hw,زj6Yt}7uQ1(u #!U^S]"!x nTzB˜o{uHwgtdBEBzm|-9#L A p$/u,znA":4jD0ÂPOdk\Pd˫@`: [P9}l c2pjAt+LIc %iwHxQr6b}y34i eK\ќmﱼ}KgH8)jz/l`V@|TBf1GY | wyC HHEfG-𥞞TK3 [A~>X_Z/mm+B PImӼ5DEdߡ|VA`qք_M1t\A*dꌙRq͉D5h4LDTqaFLz9j G`*YWqa1@/DD*A _HhQ!ȏz^`Tdaxl!f ep+$B/0\aMKMDaDSavO-L^Z)QMݔM"blASL ̡|((Z)+l@L7|Yd8a$L؈MO$o,J\<)Ё 0ah!qXh7#-smؼ әMȣm#II)\APYbSAB}4IL1@;EFֆF‘@ IVIA$M6@M@W$iCԉ$A WvW~WzEl$HP.e`O6(%6EbBY0TDvE`i廥 L-B[n+E#`].ApUAN%*"gP$g9 ,IbbΉ__UaT&&%RΘg~&7ҏ[U\ M M fm"mf&_tq \&lD$s*yL4dBIUg@|xfyj.VoV6"MU'"gLIB+y[@Ȃ7Dufp@ZwC6hb>E/@wq'>L!!b ï@aJ 8IE(AAp:$ =VШnN(/`zafrJ6c)vEҠ>aE2Y`@'@DC,x6Dy&#HAM2YV %Bh!T@D,i m!UUDpBpD$pЃJ z"EU-ڡ*jX!B"xCAAM7Y nԪ2)FM(*=Ă= +"+"DCFĴjaHdTlbtLYy`2@Cbfr {dDl(k4p% lah=@-j*;]E4$!E'Ǯhb q%%*ƟcA>Ѱ@,줦a(-e@(FV@]$Y Y -_"(i*D, X&nbm#魜' 7d@L7̘8'Dh)*^EpݒB$Z#NVwoyA$@,DC`[윶kwMZ"qFoĒϖʴqT+/#7V@%w.FgB+Nʠ+  ( -Z07,_#,ѲXfQɎ Ce.r'%Dth Ǥ23gMy=wZT2`0t=2/f鶆-M LM\Mh##U$kD.cA I4@I@@*31&g5g3π@)s6cuE,N<(MNR >@, `A&,("!F@bE#@-,F|ԭ'Qѣ)R!9Sf$b)q3:Be0hQG*W+ `1eRWfպkWX!!Ey"^N;nZ26e{p^fTʔ)[[c-FG#iyR[4[TI&lSJ V-׍Ƴu$=[pמwX@SOkqǑ%6_hծhƕugEB҃V=!+b[R<fnfrΜIMٖ*edk5n A>" Rp/{7Hmc6mI as*XlE#jpG>';,N#ƈ; 7X٣7ޠ>%alIHLL'D\PA@4 C!-Aѵ jD4>mjpQE2'$,ʔpQS("H+M= ( bRJ+RmIkSj-ix!Zl;<3C20IqS 0b?['Q Vh AP:Mjqi҅gU< `IЄs!xF 4B'2"e.~1(9|aL  _V4~1Yp_-a]x55FK|UDJExCH*zy]Wآ`;h5A"E0#"Z,^5{Bb4ĔBHr"d-l] sAz7ˆ)O IsU\5t&h2 BT%l @pB|s 01\ו^0`y/sil#T騃4u{N {t/Rd F& e6[p:l:ѐ=29ru) 5CrA`u,*[yX+e 27uS~ͥgy[HS yjH8[Dxc4Shrﶀ7$ݨF7Ao$} J[}ZfD Ro D2ihEuu'!2C?u0iPhtCh21h,agǦIkgcC_T+g:!ԝ24faܾFP I*=C&rMzĐRDx åkoha4%$1vcoED"0r)9ʝg}@..GĹ nz $1Vf5#8uw!T+]>po5Q|D$#y7d c3"S.l =CB[_:e`(RH6adk{|H8SGADN=WG 4KDc'k}O'P12C^\5@ 9abOBgK,b؏z/)~&kJo`Yo5nlccB+ / cA}Z-MW+i !@rjHߎI0fO P"Pj&G`S ӏ-o"x*}$q 0"Ќ ``[vL k 6`TfP: "q!gdBff"Qܯn:">Q!DAt H`  B0B33NZh$AR(~Z! 7Q0v(Q ab*& ?~fd^1 p + R$[rB PAk?NB`dE &9%7z*+X #2*9G"&1rJL(&!TҌRol*KR&C)yѣzx'`vh"3p*R!2 *%!WA~)pf_DR.ۂ)*Ҳ/Q-Uc}|18q 0s5/.nLb2a,)2!S:-?sقtdj ^Ѐ j59*O%Azx '@$cR71 5s37ǒ@-La6 z/:!=&"a;SBѦgL!l77G=qAO* R󋤓S5vG@'~oBKAAA5C%4(A|OT5H| AIM<ѓII[+a+KG#juh~LH2/qԴ M-BI5IFL` p F6m=,St3PcT"FpCNjK"nTd~TfVpt$!\tɦ(0uUGi4V\-!Ma.RIWWq]Ac%Z%6>lb~z'ޕbYPA PrVbvz6$`N.ejh+"!P@'-34_V$cЦ4Lmncik_–NںFgr\c bgf!pUQrOLaD)dMvNzWt+Ho r0Ւ=U!RcVhlkq $~\Jd`OLfxad8WMXF7XJzUWtWBX>taHBL!k#p#T"  !U?$!fڅ AT0 l)e&`r@ yzQw9DJ z7OWO{WpVt7WZ̷ڗ RsuRW/j 7r8ewePB^%J]xe €>Рx?k U@f}c!>iGDBA!l0LyCuXfĆ5(frfngx'tMkuWuSvU!\V8uo^я_}ؖX8hb'nladnwFRo2wZMbɘQX!xZOB"8wGuu\iAcvLvpGwD׀x,~5Y#Г_}6!ָ}GXR_<ևw,~X\36C%eYTVs uHK#jy9ӞYEyb} tpH|(d ҭY}q!}I=x:[阳ꠙ=9589! ?IqI4Zmo9AvV-l[حGWc"Q ԨtYc 3!+lڰUvD2u]Ha7E:[n>@d?:$fmӪݦa'!6̳G0WK{ &NTRzhڹ 4zlp[a$YWZOH~c{Ig[kۦ

    `b𧑢JLuِ* f);++b 0۷+rɄuL_D7(RQ4lNM<@ @@u#5b_{AQK!bF&j;,MƩOY\'r oj20CL_׵(,ZQl|Xp# xEv|W\, M(0=b|ЍӴʗ{Qm"`BeFK4$2N/F}[a|EDTI w]g}c7`H3߭mUDRE|3΍F[G>p;~H>EB>ρ=yej,U~o>{^:Q=>vU^Ӂ^9灯й=C>~ |a~>|33PC=4Ҍ@:ԩTZVYz 6ʮbb$k6ڵbѲ}ܹtƭ޽|s/ ;l)Č](Ȕ+ol'̜;K\u3Ѥo.4լKn5ٴ+ʮ=ݼ{ <ċ?<̛;==;eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/guide/images/gefmvc.gif000066400000000000000000000560371166301720600245400ustar00rootroot00000000000000GIF89aC1$$$$$$$$,,,44<44<<$4<<<<ѻyN |!4F}8! .~`ze{G}+`[4x)g(v٨[(ΎW  #XS͗1)8*R#:G@Ƞz9ȥMVdg-fB qD !$O|i饩cV68MB@8).]'ZmEM믚P&,pRjk-+@K/5΅)Ke/RnX֛S8t! ˷m_kR,Ѥ1 -l3) )Z¥He7c@2*80H.[0 {ъ<@%3s#? X0!mo°$8 $LЌPmkK0$6StԝAELl`q6'[0 !ȠXQkM߁ 8 lB1 0}-'K֢hN/ B  9D^'80!7>WA2~7pokg3t]>-6ؤc:P~ヨ=F " @.ϋt@z mI_( c}th:NV3Dfx0x 6] $8Aی& ?ܜ[֦?$Bou ˜v/t pxCpH"UQ1h(;qnkK ECTqw>0f ^jEΨ/qm!HV <, &gtbfd!9asT?!f/IĕR IY w@uRnKb!]JXf#]|+ia+xcG=yћ3!'ϝL:qw\ 7&w&m@)g E`]W)CŜ(],yuꪆ35( B:@  k4[T/{J%XQe %Ѫ?mqsj!z5XilY \COBH4G,rыF uD1H0x9Y ­oi5"HVz͐:ŅbF,ՕJlk%HY2MhwVALj4Vl >BpsK]RVEki-CINĕl\+I! ZT %P겺5b1چqWX&.RڊSqDEq X*7Y1_>i89Nr3dFǘf% .c(p6VEƏHiu̳ ]>d"shI¶:=q46k2dIyut!< 7;s%Խnc$߮EQo*%6k(P>1iT,D4tʂ l̈\W/spcaOX9sհ0  }S [R8VN ?໓Ƽw^<[Lj i04 B__ڀ(fAWqbS|Ƈk`26fB'CIwBDzԗ-qzϒzgpw3_VN5 *87PJRՀe78~wx ^Drss-Ty4 L+B&r(EPX c˴D.bЊb(6?4c/H:vt F7Hpx;ᐈL$"ǁR S8H ޭ̤&YG=2O X j)>V?x,gIZ̥.kR2Rt]ILL2K XjB̦6Q2hٞhrL:9V<3\9IO\2]aK7p@ݤς1O|FJъT$aC-J -JҒjtF9-e MJӚJY+PmJԢ)Ow!PJՒԢzSRs =*9ժG%jԴJ.^uU>aP\ʦ{xU2nSo\gJrwͫbәV̯T`3SְϡhbYlu߂ld)5Y\6hJκuDHJkBǷ}Mg¶ƥD |-x[6*~ݛ"8q]^uG^`7/gc+_YV*:hP04-VfvvjW\b?7 E# 1K1KRf Ӭy6}3 uu# G]KRʢX@5E2_:b>WKyťM U&R1e[tn5Jzd GвWc,[٥AvT] vĝv-ojSֵuyؿP@Ǧv>g * h[[oһ6-.|_7ʵh X[Vk[ǂu3m8 *+4us4=7us^gxq@ykC}Oz<q@/֫ufCbGgnd]gWh+ۦw;ݳw'NW~Dňq~sC"-5CMo*mǬطzuo /=uc|9:cW '#,gd:LtGOw#G=^XSgW7z)nH8P巀kNqzxhWz) y}Ϧ^gy$X10W6x*8L=xw|'CH'qgyݧKȄ@tzpv1H|TX~X}W7tw[ X]:#&`K`d K%`FZidžч^`Glp0pBtqpK 4Y|ڴp2:'8H8ؘPxg) :Zjz``5K;`PK{k0[k|<ܬ -=MMp}] 0N^NyPణC >}") .B)|1V`) !̊XAXF!.j)3H-#Zi%3V d(Θr5s4ԩQ52\nZh8I>@@w &h; PU࿄ iB+B&bb+0! =\bp Z,h` ȧz! =eqf޼ZSfZ;GfQ [OQ^DeLbD<4S,ē7` ++&kT# !  ,\i!LYJZܒOmVSӇQȡ2yam2FS@~cNVEf_dZ`U^ (RWu}+`Jre_)e+ CN $(b` !rˀ0@ ,ft6ˆ!zĊ#rbr^hAUP Ijz6jեI LD "q%E|%"f>~G!D,79iv.0e"HcWN!)r'mtB}'Kgn0iF;\kYJpV_o 3puijlXq{oqDz9y$a2(wߙ E tvصK G>=o#9/.XZ54L:ئwWf%Z5> XUv`׺Dy2X tnfn;S텎E;KNb{o?zc5za N7 _x܄ +`w0NX@o!$2BiOpʜ!LS*QPط= G-<"q GnX56PlҰJWޏިB$$*3跚,2CDfpvFH){# . ')($ `s}1F9/ (:ʈC0݀bCH6%+$,RB`pʣKj2 -`9rq^R)ANJ$-`+*gxQ/bNGf)DF ,MD6`$ϙK3\yӚ&sp:& t 4-gAyo !?yO/䳟(E)1c FGΏꭡ 'IgQ22eE+Q^œhHzSB%&O~-}i6Sմ9=hSRQUzpfը C*TAԁ>cj~ :5`ꪶHrUE*MJPjzZ?ֿJEukRI+^׽FvZ`+аlE=NŮ$_yvX3)kj}bkY2V-mT"m-s{ͯraAa ])V1o!;\eWYښM֞-FO6Eviuy2]/S߫]+I}+V.{]g6E/\ pxћޏ&kkq8\wBgY lt]eLn (;Y<OOWdٞ[ \K䛎gzfTW6P^MFilWfS]o f;+ZчƟmHG+FP3uAІ] 7Z7AHN㼫my֣pok{g>u8r|c-Yǹ+ε,:r@3rL1lZ#.wLmY).\(o,BdjSq"gVs+|] 'k k+<gJe43BZdn'߀,x-8}pfk 9geo7TƊ^Zحֺuס tdF3!^s@|]%hN遆!Ԇ |wZY߻Zwn~c-µN+B^?,8h-n䕐Jf,pC90+?xW(&\bWCjSuHR jј8Oo r_Eߺ>߮z U$3z&S} (4X )893V9B7 o'B|ǂ-~Mv:.Hw5c &zxzR J -#' J!Cw ͡`=ofA)l"QymVdm8А|6hΧk2W w 2`8 'X!aق-2Sq @0 Fwƀ(|s uxVy{QG'I |REb808P @}ht(h2?06uƊ"PU$ E03 ب!;6tUGX[wψIh VBы|.aB)`狙@ 59eV E<燔 &ыo y- 8B=yO )Hv8( 7Rp/C'/i@H7 ;,B,'0>JҶYC ZwH7Z(@EyvR'ᗋ \(1Ȃ'f!. WsHuNчL (3I!b ɓllPSp,xrșIr9'ye0'pRn e@YJ@6i9k0p0yӉi|WI: |Րw͙yϩl!ɛw0kpV'0kJ pV pp&PY7PR:B)j[DS џpJCg'P9Z7`pFYB gʖ> B*HZPp*T|n [*CƢ9FN%Q0Yu J:kQZWH L9kWpG gic:eJVߔPijw7PrJ,R K:jo&ZHʪw| E?@YenZѩ ։z7iJ 7ꥋʨԐrJu9 ۙ9kRvڪ YZZ00W 繮GJ7jYf˝Td`C Z:K< g9HƲw3K I*ϧMZ`;J!I" &{K[ pJRZ˵2K3[HtvȰ]dzMr,Xz'P0:kԚC`? x{{lC)˸d[fKhCikળ;۶dHir+QypJ1[$Hչ'HhY!>iKkKO&`ƛk9;Sh\:gLF|;* T9d @:D & FK϶l"PPf3s݋Rp e 0clj RR2nFUL-\C&[@e>P|_9 ĪrwXtr'~l%̺+5*LQ-ܓ`5rF@&#d<%SĪ?K!Ī Q?:CpTMT\̑_n[cB o@اL֎*Raj9>}u=K:T 4}<8ŌwlqfɔGJFeCVZysA:Kg2?u M ; ObCOT_o!\D\na턛O]LFf=_G`M>Dф<0%.2F!F_6PuRKxg! ,.b{qCݍ)7 { Sݐ=#U IrՑ,O/bؘ@~fffB  Fa za0 !E zE!|h`6)MYBSLr&`x`F_suc\U[0Fdcy"/uq5̭MA;sk2-y'VJf^վ邃^9  jR'Zhd""*k ?Wjl5* z*+8s€ p vZJsG]?F-2L3~2 hV za붛`4.Dm A<^jL$jF^+d$.%I,2<'3Um'L:j2+E#Keʈ* 4KMf͞m tmc[` T ®(m B|F]zA`g uzYdJl;v]7wXΰe,~CLHNqʽCȘ{#0q/f+#:5 &.8@ T%tQ'@Ows]إqYp^k !Xo*Bp{Bŋf1{R uib#w8y|N8e\p2,@.b2=]ݝf;C0dz2HvX: !60<햊(C Ʋh#$&CR$É+c)uG+;) 1&g/74-?u[iA<-%ޕLCkP#. p-0M12LYI] "N ˔EV9>O,QBh)"A-ń%0t _Jt &CɅx hDәyTH̱E,mm'y.I|"<:5l}Yb3+APe[zַʃ66,/ :unYNAHc9dz*[,t]4("r%d^I%qvD&2aSIfD@Ƭi<$*Obdg?쓮LFW+ƈuļN%LHݨQu 7-j/}fL(9#s8L skʫ",X'Sy?RՊQjՔu8WSV׌ p]s.lẍ́(<㲐y*w) mz礮aZƱHv bAJN~KV KɵoEٯ _2jINOmoZa\#D<*; .&E,qm0DzA"&`Wz1wޟ/p1}@2"vd2G\tgήvyo*!8HΦ<5heЃ@_|^^;.1/-Ѕmt`MsBr̖%Qj!_)Xm Vm%[cQNB4hBBU MOQ~c_r%Ijq497TBte08~ *`JԝY})޾xyF- zbXkY!( 0l!9ԧ#L^>MВ~9cfyZ]*8.{^d>Х^5,UтHާN(x1s,,|0C~Āz"B#oa,%+)=˧?|mv m} @$~ ݉qF! # $`/C1MP}!f'kiֻ$2c s`O|RfOh# E~'觀٢~O{/Gp"qfV#H%2$8px ȂA{hlV X@5XT0tFN{6.1 p.]0@&ȄMZK(pw-H6286ȅ]4 WN !D{A(CHmV0i`l uhBF*hU-Цhha cH,B8T0lrJx艝Ⓜ>x)Ȋȅ{xg8a0q!H"~{ q (6؈Pp)=hH-{8˸((fXqxiD)&Ȇ s(X~訐 9dv|8 (h^L< Hmq8*hfIO2w #2Ž(Hqd6utу$ُ"9|$!(i6Jɋ 1Iw8 79X3{A1)C9FHP9u.PWY{9Dz9~i\^]HV!ޘ!ɖG dvI1|9-!Ha?9NY"&"i5ٗa$Zii)d~Ei~)y(ɂ#;Vgj=ɞ g )Ðމ9!o# f90(7) ʠ>Ĕ2 iIߨ ɖ٠'ڞʢx0-H XXɍ$ J (J RJ-ʤEA0z3~5X:/<:> m`E IӤk 1RJr*`{X!Z '0e0!cJ jJ+ʦ9Wpte X2`@vk|ڧ 70p P٨)2/9 iji@w0 48g%Z Spd` 0p 7 Z7`  J@j ' ae '0?@q);1Z:T*:#F)x J0PʋzJgZӚ7zC0,0e76k 3;:CpC;;;jjONİsÊ0Q  Qd)wʋSP'p Jз){epy {෦B{RpZ { U{WkX1L P`j Fo`[8 qs;DK{ { SJj~;={F{+I&Ѳ &X0  #0j ڻ  A [  =1*g(l ݻ[ݛ)k Z(NKEPtkp;[ [{i+ 2 X) [ e˻SV[#a:󍫡0}kw[/J 07\9LK7 kF)L,wB)) clL @^'IlJ9+6#lZ[;LӚpΫΌa%9 bH|'48h~]mR0K֎֤#sC_d\)o( F~䐊JVwNn9}BsAwD'_ΠE.cg~dk=]  5];.˺5#z|~΢e^I!-PB^"!44 @>0ΨVzl-9ꃞ^Ue`.>yδp뺾F֌N! 3}"4>Y~>@bAbL3N^Zh.ޛC_i-_I:Q)a{ IZ99 {A8q{9"4򞢃,&O* C o ! \ƮxCLG/wLiPᕮg<Y`2 Pj kCޒn?<sv_Yz| D p8}2ɨ< <~夯 xLXiyb9Ξ`QZ 4߻5m<#Ca@2c))^)8) )L  #̩2 L^TeTTD%%t韦}IHŋQV͈;MYN=f`*%;-*.Bɳ'Ox糨QPMZȴSKZJXjʕVG_i&ܴS8 3%i1M11 Ll>o7S8aJpOx޳g>JLy !srܵϠy8:S153YPk@VcsT6츸qs@ %z9Ϳ*KT`77ͽ%vɣh]ˑdS&a( ed-XEϗbrg.)zb 磕8gi'a(;Ui iO(@ dwb:jF7Z*s,jlOJ,Е&Ec˚3,u- fk(H{>{I[ծ~-zv,)E`*"\ջfɞp>>1[>l/~~o,LpZ3M*3!ƫ: :.${aqvkEs99w=LBB+g4`4/oO}t\[35R_7e1Wk+26gП)E$ Vo6W3X4PLD7Ęuqd:;ͱBy xg e ҆pDŽZ9Mn241TDm/mLL0!~~d'7V3ϤQB 3x6;<2@0JFxi,.43k{I52A!-KB:S}x 5RJ!*c)AJЀ>  g`B´t&0XFB >#Т4ZCJ(Cm:<xQ.(! y0[3 qgônth`2m.I 78Pd;R=4hMw,+ 0>_^'SJE͝)%4ĿP x E4:v(;QP|UmPBkHq4П]Ԅ4|Q* ||1*k(Z./ذEرа!ᰈM,b Ҡh z5 ,dkXF0NqUnlYKHFx` '`>20Yp51̷^^١n`DtVUȰ /Xfǻ~6EOD^UЪ$uź.]zT#7ohj,h2\*ګF1E; >Q^sR饎,Ju# _8-1ԫXx!~/{[舱 .@" {p07Rf a:yS=23OVL8-bۚA˵$z,o0vxYђ@=3,l AN)Dt㶅{q$BR B#%, *mзb͠g..?# {6_ $tgej-co˻K#[}4a_x'P)^t"VDmT|}HKT6/,$v!Y$4)-(Yz*'']HK''o7'7$pF)q&,ׄKɔs)f&yt6-@6o3%'#8EɗG9rh 3R|i  F e@i Bvx5sr$Qy '7 nGJ'7vUƙ♅)NeDY'`PvD[ )D,8 2 8~" @o`PRy@͙j^֘DVHxB!o޹)qY(}WwY \ז5LWqٟ@(pТ 74z@jUj 'IA{h@ۙ sڐC_1DzEyڗاc}~raUʀkh_cCEXbfQ T[snz:n|ڧhjh.VZfjBIcHz % ګcj"ɫj7G`Z¬pNjwbIޑ p ڍ!𮰰خת`: . , ;o 9@PEKEPǠY1=*[s6k ..dE/f`_oB C 4e Lˡʳs=c@o^*-|#tI\0 J c 8HXhx)9I xIX`0dj `04h`0T;dB h5y .Rn> E_oߟO<  府;{VV>]S:6Rx{~TdD[BUr+{6VYeQ;N:4rRG [vze߮Z.fy$ſiCEڟ`;I'sw&; .ZR_cW#@2UdMv_qL"QXL|8ف4 yIN:7Ӭ@(@ .#x E.2b}`R/uuK E@Q(Hfٸe&g֥?]o.7@HKb/JL!diL0#fΤ)[6vsIYj}kʆj8jP4kJӚs+jl:l> ~ 2$x ֺ->Ҙ ӮnHn69>%hs7@ .a@ o /0j6I 0pl.hAT- c@l,07>.?FXaO8LrBw#-P?'m̀/.L`@<` zAo_6kK\-KCm =P<T6҂्,FLl8 ۏ_M3=]O ̠rlK prXP9`9=\[/53ӫsqͮ{Znws7;d+O?/ !;ytcy{^(A> )KY~V:o#|3! To| ^l50eN]#vԳ@f?(Ak\_iwyoL r xo Qvo b;>e\lf=qQD A2ڍ= ¨>myXZA ?LLhtl 21Fq{cv?&0rx/ĝꅰ5̑.,f8:6 {8G;o,ˉ˗9H'^]c! M͘\X,KmsAꑃ͕Z?=f,҄Dɀ @<4CnsfT1며b٣=0ukZ $GStuAf [fQN=֫圎ӨJ&>mWRk9D&v-S-Y I%5tEqe觱zּui'տq-N: Pb Ⱦrl4l'IR:˲%4YϪ& m_ڠ60jWLXMm[vmwuqm`iBwߐt?w%"y]8℺݄{ PweyK-")t`+x* `Ex[`M@1au:#^:+>G4~q]87Y ih"PN!!JiQq9'u(d{ ӛ.#~{%ReQ[B&)%xIFoz!Lʺ.yJ4j}({%v$2k_.n%*ʘ {!<2ɭki[tl:0֪p6 KoQKqS%+4L<#ԃrx.l^lfB>5jfSXƋ] |a!PhA 77BxuDCFqY=dfN.Va Ҧlv6f*ݯ*] ~;[G%GNMn%`.XQ‡||`cp|U`9N?>[mBtZck X%!YgX 5+FcHRIaJ)_h=V&X/kj c(Cx%:b@d,'Wv8 ] f:!jl*D! c7S5 8(1\x* wؼ~%(Z$#G#!99#A?h0Dgv챑T3Jrl$4 Mrrd )Jv\rB$*SOrrle_ Pd+gHJr)o)|a*,%0i)d&|&Kd2t/mE&6 pB<': Yh;yғ&'>}?Ёŧ@Ѕ2}(D#*щR* ;eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/guide/images/important.gif000066400000000000000000000015451166301720600253000ustar00rootroot00000000000000GIF87a 1 $$$$$44444<<DDDLLTTTTTdddddllttttt||, ++$  **%* !)&$! (& … ')׽ )""ݼ#+{f)@x` P J邇vK"K: H}Ps2GK4;[(ԼTXPs%9wbCq 臚*Κ&T%XP32p 5! %F%PD^U"  h`'%ax-!58%sRQ2XGhЁ݇Ȗ6t"Q<^)*H ʁIIW %P a-XH 4]H#I ;eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/guide/images/interactbend.gif000066400000000000000000000171771166301720600257350ustar00rootroot00000000000000GIF87a1 <\d 4 D,4d<< <  \<<< \<d$$$$$,,,$4,444<<,<<<<*]ʴӤ@JJAOjʕkTHJP?X]˶mǏ!ÎkٻxE^u˷ߞp vݼ˸cJG6J-EbbrϠF{Xr,G@8zиs=yloܑ`խW"G~uJ*iǖ.sZس-JCA/+v픷}7Lrp b<LjƩZ4 8``/ @j'W|gbhx6^ 2@j:jŨ:IBw⒍bxR(`axp^{#䙌9";V%tMޔFpy_n)&ldhڕ RzhΆFh4裣AME)me)訢I^!z>\&mYfgJIFښZR9IHfj֖dڦK Mf E/H;X3+ 7G,Wlg+-TWm5LÔnO{dmY4a=P׆)L]%( %xmK-PgnRMlEo wt{-S{c7FL ⠇.i3xW]m aPB9ܒoaP{(焏.c+8[ob TIRwmS/;CM'pLk#?}y`v|/@wk| M&8AqHr;{<po0`E"(6 0|lI `G͇`g? ‹as?$:1tJ\"c*naVb⨨.bac|fD/1iX 6*idl60BF#H4}c 8H@-F>푎$$')JR$&7NrRec!G9?Rh<!x򕟄,cIYvq(fJB$0Ia"$*H@0дe4)jRtn7qӛ'H֤#HPxR$.m3D*PԜ8%lHwx!I[la(Fώ2 ZPrD)9О-c%_0 Jg=9Sԣg(iҢGm)CL  'Q !fуP? +H'R"h5R_H6Cȓ A"zB)XSbiMb˹e6h2$.[w1.;dv(aGӱtMmb 8g$]AA⵶Ol_JZ|VYڄMrTֺ|(&H~xuJ!ՍTyK^|6uxg Aox1>Ï0z:|GUp:ڞkG޲]O $:em;{^tn/tE9۽6kzoڥ֍|v&:[Eg% R~lwuo0x`|'İCkwodߕo$W`xsw&GruVu'hvLoXʇ'ExF%cg6fzhfuр5yM1KTftJ6fTjRbghrJ^;c M64#g''Ճ?6E8HEJ)TpXZ\PxR8(TxUͅaKE%guoikEm膋qshEuhyxncȄ+Pe)xS?Yx&({XEåR4PjG(@ k 8a#(G*Dȉxk(N؃p8;7=x>I_|Uܠ_W}F38J<HKLTtLh kp,Pp(q}7ggeg #}G'$})pD㍈s LR?$HdA#lh lъg vw;:%)y9It)4N gx 0 I4(4$QH #0" " /0GCٓDɓF8rG4II URUVW`pE_B Ce< y{w 7يFxd ДR#S9@1d3 >>_Cy7`yp;:G3{ As 1Q9:i82Nќ1Nc" ҩ<ÚDCF  `y } IA`0]yy]QIAY62? ƀx :iE 8'?s_1[T) әE#Z&ژ<ڣ4NN iEQ K )p DP0njF>:&, ڞyTD:HTgZpE9Nz ѵzH:Ae*:X @P  ЩJ p4Ji0 }PO j꩝Z3 ]{ JN$ `@Ċ z:ʬmꜘZj  })? 0 :皮ڤR z0 ЗSDܚD:@@{s蚮 밤 |{񺢈@uLٱG4`"Kk`J+ʬKQwXcCɳGԝ Z:j  j.Rm%Pm 6K5NP`ٯc!P @ ȹ +xx ȌG ǘ3DClx[y˷X[a ؊~ a#k9 lp   Ћ @fwq7yx7w% }[5 !?򙸊K:<`1 Ī ! ;  ! ! /` li;)9qɱ?9JX 94'pO[ecY0D P\ͥ0̔[ڮP|LjYEzڴެ༾} 4ͥJ ܰr S˳9ιΐEۭEY -Z#7<5DIQѡ\E> 5ICҍcH$"9&}(}5 @B-9=UD5=7-uGN=AB>X vyvRԏ D)#a ZMlkzc'3Q6ANR#"J/tսo Vľ9 (T xL׸̳s{֨vJw?kA~=Ag6po-?m՘ ` 8r8HKP3v=3Vo}@59tz ` 0Xy7t铝nAOT]݆n-q) 8 B g iBlsxG]}ܡ >νփQpr :tSY=ݙD'}r˩ %ɎHӕ͕[mmᔀؤ70͘\CF\ޢ|4)5]y4')=x5ƄLdndp娎Un5W^ 3%+N_g"Y5qMvzet΃Ij;QKI虎}Vn62q~xEB V~~Fp@i9aԳB]5Ѯ~jp@ E3^Dz= ,/ڂ!(?4vM x ,? i1jpk9ttsnC3?5#//4 hwI{O*5fj6a(oxsg{4G=7N%~D4$^۞ էCׇkhZ?Z8K]>׌ט>KNttn4f?!}6/>]랥W/<-9O%KS_^َϣ:E64^O<5> IhOjO< [ӿ}M?<\*o4Џ4Ãmo5 RO @ …0D@]==bGbEIʒ-]S&,k HaH}Fs mQ'SքUTU^ŚUV+qɰgev,9(FI2t\uޭUWa~`V0ڞk7Ix?^J|c6VYUXdҥMsyA{TpGƝ7e0WnMv6؇fzj;8`9(XmDzvݱVmR0cH|fs>uS/` ε4¨<;!%I8F(* $KҶ.krB;B.YdB4)Ɍ3;[&HɌHF=ӷ?a L,%[ fp Mr7tIN+uJ}iZdB{**C+`Ċ.1MWsmVQX>SԞuՙ`]枋nTP <=U@S{5\I(vsW&x 4b]2vaj8#8[b eh8e>.)/Uy.Irc~ir9Y]h#薒^jN7aa^fU"B"&ꚛ魕-9.h"[nўHkfF‹8kp7H[Ue~{Uu~+ ~VO7I!|mUR-|'H}z@ 7<~ug' Q%>{Xm ]. jtcJ,pxD ɕp5/*D׉œ#\OG|u'ݐCPD<)rptы_+ޖ8õqbn83DMx71 "XQf(["Q,|H5F-~$$CUf& IQғefD9JI N* ,OIK*0YV-eF\fѐ=C,I e3XbR9MjVӚf6I>J$q& )HmӜD1LR#T2bJ ?Pd4Y)cyq$*rNЀQc@!Y>~,@Cj΃J3\g)aЗJ,RȓH<-vT$#-gII Tm UScJ""uʇ  N¤A rU_V:֑_jYʚ0KPS `+vVpijUf [1j`2mduTv۲⬳C,ִj**@tSa3[L˭Oƕ8/{5-mh[6+êr ;eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/guide/images/interactbendindex.gif000066400000000000000000000122301166301720600267460ustar00rootroot00000000000000GIF87ab1 Lt|,4<DLLLLtTdlt|tLtt4 D, ,,,4 P444DDDDDLLLwխ^N~ǿ_o188=BƗ_ќ }ٗ߂ |O`E(& g v!#GljH8wƸ tEgEو#r:x܆n)(drpb_Ȥ% #XvGFTEp%/%Z%dAgŹVfT&dP@PĞcr"f)b zL@X@~ZC 6( )Yi|C]DꚫmpD$G>06*H+ 7b2.DA!WgaJ w+kQK ypq8 KqQq4` +f 0_D#w & /B)v*vkqz躱5ġ@ kM0k!B񀰗Cp X}[9AtƱ^C>4 @xe> S4jpuK"䓡7z< 8僿^QV[~{}lyDE\A&p4裋Ocr[gz,\S1GAEҲ/nE}iUr bW=0}Lق&Pdm@P=Ջt-bԈt" ]2CXL Sҧ}` )s,ܟ`]c >p P~.9P 肝;U"#e`$@Ы(eS(. FbFPD62GXǧhiԂ ( `#n 9beJ%GшI(GIR$$&R  $R3FB #9pf [g@*r t(1IGϐl{I\SDpr`;Y#a0lKBz4't:wuA=`Z/8(89X0r!H5 g=UZ$rŞ͋(#18+8hC&3=NxtRX'C$L A@r<3y`!%B @ɹga*M"U$g)7)b80>.A),4@0Ph^zq ]9 bqlA4;U>6r dǦqNkrժRAqUc6%6z8p"Ch҅\``^'dq_*_]dcY }hv^B8b@ @A-\ІDq˕ ЄYN \RdΌw2| b$3CpU :d'Լmψ9a᢫z0 }~xC"ĖR!5FW6mpq/R; pjn*ГI^9Ygj _.xE-|XA2eIfqphO 3OqR @d 'P1˷/dy]՝F͍PiN̕vcK;PEt X KWA:ލMzRʓ@Cp@ ()/;QREG%et6@fAp@3t<ْݐh1qu"LňC@^\n9 >'2%3`ըyFfC# |uzcPIT/Z_0ȗ$R]S)Q4s`!PzqibF`6V`^~xI(puOWvqhVtZ7o`a7U36M0O=q(/Xya9/1hL3x@qh`V9(q8FEhKGhPtM4dXJgQlVxe;1V(ņXxpP qScdօ-Duhmhe@(m=胉Vz6MS"$,=g6\ U`Z&APPva,-!ԵW-^/PnXf֌H[h);؈8Xh8HKHňiE&y2GPZ *X"H .fcȐU,a"e̙5o\ =t2 [6͙V}enonwW,>Pja$^8Z=dkVɖ_q #51d/hl!H .^lddH Ҡvqߊ߅~ z%Fk4^N'lň:KZ1LXJ'UPQ#;:a !vcL')FfiSRڏW򘥎bإ_^x]vN!ȧlB/"~ BFZddf*WpPiiX`IɅ8z)rHLKKg%rujJ,1mJO6SϢ^kҭB*nhnOVn^Wڛ*1 LplG,Wlgs ,rBl(,0Op4l8s /<DmH'L7t=, 0 Xg\uL- 4K@VwlvMX3؇ͰLc-%  % ~SM-Pn7jMsEww|=SჃ~8FW 騧4ܔWzr p=p書sXzO8%KNyXoR TI ҷ츏Ms;ƛ-wLoX}X?>KȴM&H2=ܹ~dk Lg8 $K 7AptS ;z\Bpp1EJ FB@@!%dwFp SP F"bE,zQu &'m SkS E81kr6.Ύ$&A(+~DyHEV2$vtLC1{|h<gnʧώz !g M$T1,!4DKsىh㚺/Ҟ4#mBvKlvGDK (5FџZ"U';8)TsPⳛĪZT (<] ܴu+%Z$RE+'MbXj54L\rs%f7ě0!a˘L8@4TfQyzq,mjw~{m#M:YĶX-2uַn+(Gn[^r]uD;PW}y]nW1وo|%a V x)ޮrPoZk<8&0L}[ gؽw{PB),Huk]W1 &36̂'\/1ucְ#dld$xĿd 9p: -@\2_0g63;噤X+6L|0`Φ[`πfs V ^ ;`Eq9@[:m cHz NKY0eA`:Ȣnolj]48[`pt)?@ R.{Cv'"wJ:P!Q^'yM᧯.̵V+د=AOuBsd|}O~?g'Ts ؀8Xx'~6p8"X$x&Knt[sȳ*X(x67X3ZeLUNAxNy2h7:8Jh ȃCHPWT1(u5;Є4@h8P-8Fp60KsR X5* Ѐ8:ɓ7y6ٓaْ//x_4E6Hs*8찏g'I|ـ%P4)e `蘕Y>msMC~8,ȕ< hH@HUecHx3 N$F6qycٛi(slc<雐E6y̹x>iH4ɉ,Pԝks4zwE胞j 57%Cj3р0w29D85~rX$m:Z P!  &z*J ,ʢ 003SlI@5 ڡJ":%z&+ڢ1 4Zw]#[壼ZZ*CEjILڤ6j$\ZcӅ;tZ; cJMz i*IĦ\s5p:^rZv|J*h,ND٠s ʡYtz@_Jf p`0r<5h]Iʥ\  &  :KN`٫ ::F !Z @ #p `  4WxFp=L$?ۚ5n*jCvh?:"Bzp  3p . @`WSopS v=׳;vXakꩨ#kZc+!jC 11 D 2  h{ 2p 2 P `qwKI]c6TG  1 '*d fj lp+t7~VmVO}W@ NБMK Q[ =p<ì% *˲m6+v:[q1eE+W:mn5aMC\h6[7;C۸:TMgx>7>D>K[#pn3oS!!˻ ڢJʶp[ Nc#< C), LN8\KYWBĥ L5X595 u!:Glj<:R,T V,#HJLOlP#d |l4t5@ƎKEy8Mܽa:yS,45 f,ɓ|45əMɟ\45 9 5[݅ʋ45ʛG˾˿|>@sYʺ\ʲ\4qEaXɬNz4، ׊^̐Ͱ4PCJӌIww<0 wABG\ 44Iˍ͊DD[ ACp1qlluk'l y80==ӖIP6Mӯ4LFDmGmM /WfA^ Y% ^ȝ<7Li;mX^ѠXn>18>@F(\UCI AݨNɪnjFsR 0.*Y| s픠ڎ .ŮnK|@>P_SO0 Gpݞ>@Q<J_쟔^>> nG3lcY [ .Yh ~Qmp8rs0>>OYp [{ sI13maH}{+!OB> fKL O\>N؍G00>"3DHi/[@DPtmaҡ m&0USU/:d_4(郀@ OaFva%F2lm#lK_G r ou_w܇bEb Wkn/ .H&]ܿ@Jh`D!A-^ĘQFQHH%Eb2I-] L5EL&A| ӠAN /^N$?ViAJhklkW\A'^/eҌ p_8$,(͠CtJ2&LPNz5˭a>}BwՅ[G!UXȟ3}i1޼ycuHrF@_nlݽϾ{07o4QE.ߒtJEM;D0Ah6p[iڳ z K3i?xYt QC!/ ?IETh;+F-GmB"$"]pH"9H&?E9O?o jLCl)M5;äN>'`0%>S+LB -QԚ}J)033Ooŕ PkTRT$T %VZ.RFKsMsZk6[m[o7\pqdWA{_(6&57dXd9e:űZMqtewuI^drʩ|\/`0 aPx=dRʜsξŸe-5Iԃ8&uѢ,{l}]@ FwC9Xeg:aIfKE:6i¦:l@k te7iKy)-n[):FꗬQm p-bEe,NpPUP-㔁a&EDq(t;[PӁk{x(:#`dOיE}Q Z`I^{}荋6dZinPhDd|J "ܑ;cIطlB"1h.W- y 2:x/q-,ϰ ȵ.r⿅D 0!AxB $ hRx 0EL Dr @KCGĹ$HLrF4s򶷁t+IA:8чd[ʆ>6*ll" hFY12/f{ILI0DtdB G/*SUҕ6d9Kr4!ӸK^̗f0IGiKϤDc0fTu3F,4T]=ل6 D v(9{ds.lC>9ss0<$OzsV~|>5FF|1eAfL'pO@꓆Z/(Z.]jhKry8BMq Yzl!>KmjH{:䃸R˚F]Rѐ ejRju)*XGg+OS!o%KSGSCNbTW vh_-La@Ev{`?GmNl{5k!u mMڵ F&8;5%֦uhBs̵ ]v׻oxś[Dxջ^weyzxn_G/~`x,;TϘ. fCaIN&1|@ 7re%~cb5ƱNncX=O,d6CY0ANN~ba| |_h\.1b\5ș_…s'͛"l,|g>RahPy8 7 ;eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/guide/images/interactcreate.gif000066400000000000000000000201371166301720600262560ustar00rootroot00000000000000GIF87aZ1 <\d< << < \<<< \<d$,$$$$,,,<<,444<<<<`l*' hRh`$[/a)Illz!,Ɉ8vO:wKVuٙ(F"I%HxSbIy$,hrG+ޖ5)|g|6ymK;+Ҍ䓟J7^9gy礴zz}^d2<(ġU$G`W<@I&Z\֪my!g -rvVRŚ黦뚻+\\.a'< ?Uɵw ,$l(,0G4l8<@k DmH'tclTWmXg\w`MuNLRlp_ML$ zxy@i߀.xsA7@wsf&5ݝ7M@(T~yN?q.褫]$#nS1GwMc^;yv;Uw?^ gL{kBgDA=(?ot>V@QRH~|ws;P7<@ovP_c'9rFؘ{ 7'уx+L"9$C gHCywa2}zB s3aEtǷ:~vHD@#$Ǽ6r þ hL#ؤX6Pp#FQxc6G'J} $5ƽ:NM"GCZ[$9HșOd&VR&P4NwqIQe Jݴr(.KY҆T%ni1q MY^K@V9LMnNʙ gܤ9 jV&+@@dk7j@FZSd9yNLorHAp xBD L]6I5bD~b2Q`)ђrtJM ҆4]gL Q4k(Eéz O: PHk68X{*T&ը>(gliz^cL.ê12djSJUZmu*ViR I&UV*`K"rVQHb5{R|ZVlf1Yr}fBZ^'ς6ml[+vuI(SZvka+6Nmט[dtK*w^#s[׺ /u]5w|gohbuNX4.s'NMג Ma96荱A@yE|9{ƓQgǚ8!Øiٓkِmdȕƛ [)I4-\w\U\U\:Y56HZujI[)tڹٜ?9){(6VfYIKwY4WUXU~5XPXʠ)]nuxz{jZWZ' Ȣٟl34Z,CX#7` ӝ4_Ws 7K ?G ' Vj1\j ^a* Pfj h%^ .7XM )9Uzå]^*cjg6q3s0(xzZꧧ*dJ` }6uqX(pV0ڧꩦ JIo3t7nꪰ:(:ꧺʫZi%Gp#ʦ]7Ȭ|1pQ :JXhPr6. qzJ10Y J gG )ns78V:@:CB[&qP 170 Ҋ ) `h Џ>d@2I{Ip7X3T#TV:9в ˥P` `     'of$iL9XL+ۺb3 7L0 "AQz][V:01 ~    p @r&QLSBдɭ[utvJKP 1P|0˥K˺ K旷K[N0 Gʱls~CzK[Z(1P0ej˶к0xictPTh[«57W&fZ$|KZ3 u9> qT9ӃxL1t @''ۼP3ꚫ к+秸av7HĴpvcjZ\[9z1[,], z kOƑƎ6k‘&ͻɜɤ +bT5 fǯ,i,@f[[^{b ک<< ӯW{dfd=Fdn5&`<5:u"Z<5L8vDjt X B|5)e }Dm58!R %5s5PĀø/=L-&mWv)]5q*8R3}R3MR=SmtӣJζ5XL1XU+8Z^MSO]N:חpKSY6A;a~Zg}X&XVs(Jؓ[37Pْ]fzKG:HT9ט*9]MydN:X`p-uu=mTHD > EUlw]*' jmW ݦG:Xt@ p \۪Tߓ}@ߒ=wMx/rP 2KHTv+@~+7խ_iYe`詁i}P:`@x $q=Ք0eoI ɰS~iu VEuQTYn\nYo^ǥ5#>upp-7+-}K9 2 8 DU wX隂[ OWo|YMIM.cK^Y5` : `ZْJf> ߫̓X  9|7YY}>Յo Hp :%Еtmٛ9w3ך~CC#Bװ~n P붞}$ P=VcZ; 8Gm=5>nՎcSz4n>Mdu;[X` O'Mj?]iY3oY66q}ғ )ߍ/2O:i\9)I^A6L{lcz0=LNIԋ#O;7T_WoK >J/g1/@g1z|~?_{$&;L*/Gh=`loHP @xcΒo!O%~G`8>P o@oL_:\CHx@`RO_ek?_;+ H@ NB>QAᩓCOԙfj<RM>eʉ},TXU+iLVWe dڍ;~ 9ɔ+[>|3P14&F|Ԩ(lլU&? ;f h6=IҤc.agL (TɄM8B=vW\9TF^Y fݬϦ5,O̟z.k{J(8 n(Q?~ ^.T  ;'A.li ?a[z-&xM'8FoǞ ‡ H$Ȫ*(#%3#RDII"8|?1L2pH6͈T3NRk-;K*1ʻLqspIOs^ꅾ BKFSLK4N#J39G-(N=u=U52g4?d$L?lz%@t'xȧRa/=L4l6lVȯ$Z..[SU'\q 7PbEb31YY~i^g Z}C[ .eX݆dMw,7civ_Z. (K.܇fFm7{7(cq+ߏϩ@I6@fi:j~:ϜHp޵kX{A]HTm7*7k6(-{mCoy׽D|q""g{￯yw>,{)|g~zˮGm~ B kʎЁdB%uh!... R4/4xw=kv`gڧf(?a3܀i-daA :s(2Dp hF3x"piH<&"#}apݰEgh hF8]@R`HXL:$6s$1YQ! D #J8hhd: ‘ 8*' J䒛&%qg$ir@2ne$Ct_/ M sUxCR##ayKk:2&8'N)>ԑ/ (Dgp%2s{ېVzϛ^d7'|޿}@[4hD[]*q+QKξo~E_խۋY% e궜O)^ /F;<_74?QR՝. Ѣ5 XoGޕjs4!dɂeȓKMoubjtC0:6ͼ\7'te/{g=bsDjĖU2iJWҗt5D?f7=jRԜt jpl>aRZk5͖j|j33kY&u'k^ {P .wtMkp~vMֶ~}nvwCov[nAjmiOg!D+.8UOb4Ѷ T'9OƳ񅫸w}B`O+ϘOR;eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/guide/images/interactdelete.gif000066400000000000000000000327071166301720600262630ustar00rootroot00000000000000GIF87aE1 4 D, d < DLd<< L]dl44|99Y<b$Jq8<@JQRDT\@!AA J9XHVNAe  ř[P%bDVD ś[9^NL&*蠄4D!_w1DiJt&"ib JiFY]Ji$ ZIN部V뮼ѐh!ñȾl`dŦFv&!f-b~n!&R b0I Z-t LϦ0"g&&{ ,$l()/G~5 8;hR82[p0-䆚MK,t @m*=pJ;6 ;[0gCˬj\n',̌7rc!lNW?xQJ9蛧.Jf`xNհ!{.Sx: W< ^qN"\\/o9c?FOA$ज)_8}LJ@綅vb`0;.ӝ y'BOctw~I@C! 7H e`1%"pA[" a(h`c` $Bz` H2hLF0r d gAu3xP0P]R ?Q hr$F>%#%a`I2Pd`\IWҥm$DGґ aӂHZ_,Ji^I|#!?Ќ4IjZ̦6nZ38ǹ:yd8ǩa%! Bȯ2,=EOs'< @#,@9UP `\AE 3).\Le3t J?ʂ0s }hGDJ !0K82\.}i\ZՔf>3:PTJժZXͪV ` +P%1XJ&n j @54a\־0BP°vDb(C[P6mȨ? YNJHmY2 eZ? 0x,Hۢ/xt_Hd['VN,B+ź2 pKMr&׫vtKN tCteIFw \vg]Vw h vË^J%.v;!vox!Y_noTڅoy;]W}_Kҷ&8ESK_;8L(NW0W@8αw@2?π4,BuH.ѐ'MieT δ7N{ӠtRԨNWVհgMZָεw^f}EbN-QQЎMj[ζn{MrN]?,kMzw~Nܯ~;ěp[ϸ7}'fGNrS(OW /'8yaNܟ"\HϓnWL8z C Dz!~tCj瀞 PmNwVw_ޅw}Z{U_u'޹NN𩻽ThvDxo^EwwjO{=_h7 ッmy۞׀VPuW|Es7PVOw~i}ӄt1Xx~jp]tu$ćl׆o%؉WTn z'8v'VvWtgv'}{R0ΈV`W{HvWx&XYE80X~W}7}Jty}Xysxhqݸ2؏|8sFX7t{gǨpҷɋafzhr~%wau<^=ЄwXq׊U珷Gyy'](V)ZYh 98\7p`lx9Iv{"oPTh GPv3`~iGe~}E8sUy(`Zk8{iȇǕЧ9Ljy}P灶z蕤L V {ŘrُU(yy阐ٓ `9ui8Zx)Wpa7vdWO뇍hYmȕ$8mОs )\ x?H ؏ꙚFjX&(vϗoytu)U?HR9)7ԉG8S(v؜!7s, (\,4\yuuOТ.*V@o@ ՞'zpEoMuvSz}}k3 =<;0cB,* jI¯61\tީӧ @(l(.307pPN{uρKף۸HV]@ǭ> N0 |fM|G@쎜ں<kк]@MBKN}툎lMH *nz@B{(x 0PԖˠi}m0؁Y ˈ=$ijy@< B;MOWjrp(0H_M13.z xa~`p v|  <`<@Empb!/$HRz2m6:MiJ(PM,"M`?b_z`*-qF~q A/? \/?pprN=rtPU\ަj\Ϭ]N?r˺n{ίB?i  prFXhxxVTARظ *:JZjz R$fvYk{Ki+ L))|ٚ;k\m}MN,-Kގ͍]>O_o~N_۽ t ݿ  hM+51|zjk̩©F ,[1̙ G+g妕:ݙПAI3u6y5ԨV驳';DAfQxMk;ёkX+T0b޽| 8 ܔZ;~ *s\QYZ5dY">ۮϕ0..;X⧑{G|eth_29ݔū)Y)SM/ _r,Uؿֱo$_>Er$sE3uBW7^Q[mu^I7'5\G*GOVW^yO3EPɝm;fdۆFgZHbKB&Y GV^9V@-ZՈc$wg[z)a7 GM@tXRPĕVfePtV&d(EiV^iB8$FE‰LrVgMB7@e`؇YBlׇt1g!xūh7]imJ'jg'Tq*> NyJ"2y %-cmc`bql:n{ntx d pKpoդdkp#pŽ0)q^hq`{2r#$ )L-ߌ?|2>d3B?¯!s04 " [gJ/aZou^ vu"]#v M]OfݫS/k>^H2)*ԊJc|#`w`[n 9aPӡ! U 3@z |)p&V PxdBIhfUB>m<(nb `GyȎhNjm ft/<ʪưxqLFB& ‰ …!v_TDPqBjkI33(V>¤GqGC"eP|CZL j*###-\@f3+agP2p|㛃5R2 x$J.Afkx\a @/CyE0]PW&wxrn2.|e.7Zr8z˄&tjhL!6ѷ7Rd,aBVgh^3pbPV1$i ~t-Ε-pKCYB~e ]hCbG6@lf@wi =Z;h3ǴRt[ 薵/m y%(o";8{  Cx'$nU<8Ǒph `K.cHA 13;}.|4籓\Jg:˛CNzF- >hRu145'P* }s;nǝua:`̄Mau"?Av nurA_v:\ <Vxގgw}_[wd޵/pɇbx<k"  =TD8]^ۿ{gbmC<s>*Oypi?@vjuR'yi|G\Uzbr}ǁ聰w6A~+{:||aoy{3| vewy{7x?xY|]d>|EHz1Y FsBp[!%@ygvixzFxx4v0{P(w{tPbyy@]P:#Xw6+"?g~ x Hy~AC87Ihh㈐(AxaF8wy,j0LJj7qSxxh( Xtst爎騎Ȏhp@pp?& : }-3xyW Yh} زD/g{0xmnnFUv70!זl2 J4I8wM)$مYE]W F HYJ wLcؓ%F_ZuWx\yLX0`vbY'"0x.z)e}gI[iY~pIl6)41ɘI)Ʌ'' x8^Itbɗȗ~w.~)'q))ȔP—q(X R}%y $BYYRXPI&G(9)ĹƉ5I܉- : 'Eji7W⹗ -x9}9~YY3: *s0iɔ闤 /٠ɓ9Y9*Z'ɹi5jj)G "!  9QYy+irI01j5 Zux:j/@J)Q)i' Ĥ,2@j)a)Qz}iMo q*sJujwy{ʧ} pڕNZ/`ʜˉ(h sMjʩ꩟ *JjZM0iyuRFZHJʫ꫿ *Y/ . ʋʦ:j׊يŊuA j[Vr3LP6jְI&J`Ȝ$t0Ec7N^x{IHGÇV yM` =hţJLuؗ,j*?`BEHfX\fZMՌNjZ6. ^sEI(^{xO<}5爡 hM.1q |b_%R@qiә ry{˫~m`-?;zm?i~xۿ_P=_?VGT8p6m`‚>W^~RH*,uTmH~bٝX ya" BIdFdJ.dN> eRNI%J8(Hv8QWbZwqXߘnW&$qSb fo[A!FtvybB#'z !2 ̤"(R ̦RGP3.J_tjԥjb^:buynz Zǣ{,zkNk ޣ<| .KnnP.+[+Zz okp$*>~Ǧ7߄|}~'^4\F2/o Tˮ`;90@=)Čzg?atX;G,E"g{ MDS DȻ7ooFikvG?OdꟁX}#672C蒨a{> E)! #x)Õ1:+bbF%jK.tˮ`”Q/G"?hZ&O:N BHrPh2ANbcp^`d3妍-%yB/y{υn;R|=zod!tn8ȾEW xB.ck]N4Xim~u u50qx NbPz 8.etj9ύRuC_w eìp^ekdDu8t{S &52΁ ZVGޫ_׌w?DyUdzqiB#p{v`J'G5!ƚ,;Ykvuo# nܴW=IcG C#ZoB DB=ΌHAi%[:*H*_e^$6}{8)w%=mhV̋"<QJ $ޢum}\ ^.q'd7cŻy> Fpt6úmrybڭSi_ _Ǥ̆7ӜfLÓcZc(yJF;*$b9#\[)ګ::_%s\>tt|CKI=EݬS_9{-tgD['GSD&mpRJ;"cqS&qaVwsnw ^xC}&Fq-GrǤ'<2on3PQfѭ<Ԃ[? l[ cW[;Y|t @4.oD E ,Ȓp`;鐴2+Q*FnRi:NK9)ZY P•\ɖErm qI|2ubryɗ$} .Ivɘ汘 I1q,əN 7Iyɚh ;eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/guide/images/interactmove.gif000066400000000000000000000215301166301720600257570ustar00rootroot00000000000000GIF87aE1 <\d  \<Ldt< L <<\ d<< \<dddLtTTtt4 D,$$$$,,,,<<,*kx䕇G#N7 "!H*1Ӂ("7 "0$hyVf;pIf-q*]q;!jhko\:Vo X \3O  =w ,$l(,/,4l89N;u@y砇>u NxMO{$܋;84YNcy٢zn_> +E4dw5馋%|7(/%* P+?w 3M(w<0&HAt78Oy{( >^3ѠP"Xmw=@/av9r$r t %O'gĘS"یog\60QmeOm:@kv4G@vtZ5&*,|IF:#$'II>zMc$ɳ ̣(OQ9Kn,{'F7jZ.ZFmf0(bS &0c:hUA6Y.,VKJz,/icBә̴0hNuL#0iXzEn&fVyPLe@PU%w}B#̆"["A6pd )HG*Ғ&M)JWҖ.VKF(C!*sj(EJԢU h!_Yϐ&PiT*ժRZ>fSⴝ<}g2ԣgM4*"V+\*׺fujEÊίvUU+ZLMSYcSmQ4(]'Xʞ[^Y 5,35~t]i#wkDLa+[VPLiVEhh3yص2p#K-H &d]*]Z"nFzn0E{QRJ=@"oj@@ 1PAb\WӚxKaw\K(-]Wb9ԖzM [ 4 Yfp$Z|Mu`֙LgLxƞ=1 d2 lIJmR-/r)TQŖ6dW'}Wggx xYf[Fhv ~.X5ք5PX@o%;ܥDfP 5nFuWg(Fx~FFJ=dTӆdpuh9ć~8PDž8dkԈ۳NE&5x7䐉h P@{PCfX胠^ )~(MHWX0PE/@4T؃Z@(mF8Hy|SLȆ(nȍ2AB@>@z09P<@UDV>U^(#X:]Ȏ#(&HX~(kėѴNsɋ5A@Ys>B=99I9 Yؑf'ovxaRLx|HX 1As 9Vl7xfiu))70Nt8d3M ={A]8$t q D1zS7xjgye؀Ʉ1y)y/G*g.؞ڒe87QOqr- HZgz89hɣj K?ʉq9ZH枖iOQZ3HQHXzDX+*0C vzxz(5J"jm o*\GEv8ɡe~ik5XMqFQʨz8::ԩGXoc g o"*j(jZjZ*ULj _HaJjɚ1J5ajh(i~zyƚ=Jډ*G4:Z WFڮ*)U@R1BoZK4Pv zj۱ ![ ;cYʰk  O@3[ =B9#Oe6D+NNJPh08;Q;U9VE rw W9pڵ)iAa!"7Ѫs!K|4ٲtJ` J;D$A<By 3 * ˹NZ5$@ va` gyʭO;PK` P[ #}9ey|{W0:'p7sY74qMYEʚۿó K5m@{sƀ;wQ@B -<5  oo8äSW7e+T7lIuB =k<^',*5-o/ 0ar5@HP줯7W;O5S\o9 W_^L˴WO0=<1yJKlAGkZsosЀKP[PPdfl +ȃSspk o抡V4˴,j{g<ʤ4ʱ kp0rGKΌKuB즦,5qjvk.Z .Zh/Jyfj 6X v,ڼ5o"[cTt@%X3c_cl|rd`Pl >@P P,+<#ɳrm-VS}E~AFKz6I>p  2  2 2`  |)|@;tnn&7 lј1nG} 0 ocR^쿎+&|` I_{CBa0b`hSK0 1'^y M`Ǝn[#CqQ oR|3r$mrP i$nn*ZJܶL\C8gEa܀P|C @er0@ n8NT ݽM0-l}rOPrZp` Ӈ} @?|ޕT@ 0vPm?O"uUM@7SC 0Z?MI-}ן} 5H@ B >CI` 9U"rDT,/-g|LUl4EJQ={T$D#ETRM>58@IDH(VFrVlAB, Q r4J\uśW^}*ҫo% d`a?6HѬJjq*R=Zhу~%drС!Ӧm%ǝI\hSg[Z 0rmĔF[ý8p>zÄTI+'f' _iN#iT9>U-B 'm? /?Ŗk. k A2FaN`E_| g>SBTaCR kE )VhF'Ӱblhٌ;@(1 Jƣdj& oT @+>Dh>2K#"$&-ʐb:AJS64 ED Ԥ L419Y6)L_fIH&u8W~IFs!AoPw9?{h}>vQR3#U[61ZH& V@:1^I_6xm5e@xrO=蟍&nA o>f^:.IuZnu~Dm=  vyd&Y@YvuMypiq}]}{™T\^u'nNEÓOzaF헳WeGfHoV2Z|Gf6͕ Ynܚ&0 =*ma> l 9`  Ic\Dng!Fؓ4F~F8C!YqҮy! GC"J$7bsņ$Gs/>Hobj(7я5erKT4H+ d ,2%R0f6stf=J_҆e$bLy2^M${WM+^s HќC~$8{9=P*4dY7]I &)|3)J੍݆ۖ&u~fPY.gCșufߒ=ѭO(ABJŦ&}HCUK=n|{@oڔdZS6D Y)R6QulSRBDQTZUԡHg$՘j*ckKŊSwV<Zk WEHVzή[R`W ؼ:2+{"T; J1ZҖv,jBD`@nآ,@¹K\VMmO3>\md{ʖkmhHJꚲ .TJ+mnxmFWt$$5z0_w ox{_7e5Wk2D/_*8"-KEp_>5'\^ p_7wa7q^3 I|_!1fyA4 [d "1 |3F'l %Ysh\/jprf4JJr|=ØKst爠Xc @ ZElD0r8J@X4'ѩh&4IC+UW@"1Y# MW];(V[mG3D @2v\7%Gu4%R {l4хYaXT NoӅ+[βm{9XƬmelj2){,Q}B"Ұ24Pvz.oy<`,>G۰Y+։؅ ԙ~*m^0&%i@C ]| Vh{W65lcvnXRĤt?Q`Hav9{uN6ZN%P#wߏܫ=

    /˹>5NE?wGMy^ƞnu+{Iҷ= !-s?ħ3 M:H 5/+TP oM|׾joLjl1;}x @6ӿY?§x p?@3@My˜A?໴2?#A $tLyR@l[?b>4C?:A[@Nj@?ې?K^뵫D !35y(kd9l>śo-">˂/07;33d '668Hѽ<<%9 :d#(,="D>4̠DTD&@3=C.|EJěFdGϓDʝIQRDM;9RXDW<&9# HQEBRX YE;G\E4DVz{|zjF|a[ŢdefD"Y$s<tuFRy$G9b2G{vlT傐b (0H25۫LJ, ot1گ=&TKrH$IݒتٖH-jz ,I ;eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/guide/images/interactreconnect.gif000066400000000000000000000170641166301720600270000ustar00rootroot00000000000000GIF87a$1<<<<d < < \ < \$$$$,,,,,<<,<<<<qdY`Ó/wGހ^_%iQg2Px  ud8̉^`a1Jkށ)|F_ 3~x@n݇&~Wn|[ P2v,wD3&Hx9ٜ@71g̍&J+b킵'C}!2'Zn lG!ix%K rW$#>`˖#bF4wc{/񎀋9S#VpFB l# 6=&n{IȃJ@kd2IKQV`Rj唦L%*WV򕮌%,g)ZR~\$'7I^V(wD2eֲ}3KNRӚf6M@`3s(/@tf:שvRr9IL'>}Ӓ 8s@!Ά24T$O󟕼(F)~C8YZ>By؇*uAOܒ.}Cgzhzn?uSvԧH RD ʄ.NTiʈNըVծt,%IK'}%`V$5N-hRuxվի P 4VRzvJ P`jHc̢Qfj\1 hW rV3j*y=Q3 FF-=%L7[ _6+bGP>Zɬc޲|#h/Zz x X6b-hIaT2n_Q/ tVm}Q,MN *eڶ}j`GFؔ w\e׎uhHP֮=}Ҟ sL-nR:{*c>o[2sGoew[%'2~QI7׍v2.t;iB%#c7 Ds5k` 'v fL@)V@@>p|ӅF˼e0iv| 8 t(TnrnΧs*o~D)OnrOoQzΛg;u[޿DvwïnWFܗ>KOTLyQ <ARÁ#Bg{ifi'i'i9:Q1}S4{{v!h~rvG426HA88kƂք?{lDsATFeFOT2h9[d]PC(gAcgb`0ȆV3|؇~~82&qvHx=z(\hkmkx=Ȉ刍dX=hnkGH;SQWT;T6(@WzG&;h=E?_ 6A<$AX)ø;Ũxa8瘎h57TT9TzUw`gaMPa8gpʱsMM MDMĐT ^03P 119}g ȣsGu@ u(w/KXyRL8e 41cN)8}0x8zӓaЇᓽCW#C)aFI&0` 0"zb|x`^eyoD'`Z~C`@X 8wc }7i~LJxidٓF阏H$@H9aY =< <f9:;؊P DiWXHCSq)I.d nB?# -7;n0YAY;qo3)F  DCH$sH7 yGvG6=0D Ā03 ( 8꣦ B:PE1'6)=p0=q2J`':ʣ;@:Dj=K=i1lڦlZ7[ʥA꥛a:1I5e=0'%808W*t \z wz*GyF ]?Qj2r:tF/D@7s , j: Uz B𨨊y RA ]#8 m:%  8zpvJ:d@h=JAU੷z4 `&c `$X@ ^G xEqwqOF`N;j30%3ޚ 0 p  P p `'+ ηzG+z]7ָ麮z H='k312 X  :А l   " w]s?5ѧV`4%! z2 Я9jh j˶n p+tkx)'4y@S٬P%*@&[\~pp2W0 2K6os0cY5iz8ADa`dP'x۹(U9 밢Yx dW] FPP#+:; 滻[2* pK*1a \0:*1P%@*?z\ʧ:W[Y1 nl@è]0nnp p&(K,K2lĒJ*UK!kYݻ '\KU WÊ[35 V3|'|\qsLViŠrł'8 qo,직WC6C`Ċ`d\v5\[#ʊ6'Мx|k$3[ʠ5\ Zdv0\X6 9YV He7:̅{ɘ5L j^jN^Ö\C[cnөlB <<y8AA:;o 6KG6 MGLN\LХ;y ;D@HX{>R'Gv6muט,ɐ@MCݐB] 96Dф@O=q X ]]V@V HW:ɒLxրs1w.FMp8dc}HZkSD @Q:WL]M_(M ppxV96u<_ݛ׵؀gݖYK =DVMX ]M}`򘷼 ']Ъm?ڡױڲXu ]^oa=E&<`|iEɼ[ݗ]ݭ 6#{  @Վ==TYy94q@x# hڦ[0nM~tp-޳|-̀LMqs@Т6 ̥(DF$pL tp `j6n)ap0p *a0 Q̠Xnp^OG@:nmZYKqg.d C[>t+ae]钎Bs.a0 ÙpP>꥾.N]NIc嵎 0Ɂ>4EEt x:E >0N^N 65n0 yߎ@?^65{ ţ8n<a`g@||jn $a5P41#La3 DY-n153?- 6.:/<`^ڀ ~ /]uWWPZ7\1Iھ `?j|.ٙwO+QOSYq8]HUi}{PS%6p٠z?z[y9} b~v xؐ!XԘxGx?.}/2;6? àۊmFJ@9@)u6mo~}6P Z*H:^]B#9 2PD-^ĘQF/XgH$yCJHd`ΤySΔ(yr!B4he m4*TP=^ŚUV % :dϰ3_I_MkkeOeUʒDEoD !زcSYMj^YW\=/5HhFkHUCٙa_m.ϽIU\_[˅L[nqtĭ_?㰮%W^sJ޻:vj;9̳t{:o#@$@D0AdAȂ>Ï< ⯿0DG," њB 7,)XC=o45S>_dQqDҽqV,,RВ%kI}Þ:r#D3-벹/{ 3(*4nMRI9%N E#]4I+s8=w3,) kPBkؑ+fQg `t#7AU&BSCtH8"$.w#xþI!!hk!21(_@b%Fi"m$B٫QqI{JýjpTtF`"zmHdt9E;ǂɑa$ M]NZ'?I75N3Pu3P:ݭ6hk`# wO|.fBrAhBP6ԡ5&GP\hF5cb+dz%5CQѕ"GR,iF[ѝm1E*osq )DzҜ>PJԢE(E)JUvuYjXVvc5kGU"mjvhژW%i]zDF6+b'5v=,^_Z9lҏHV+7X~2 ;eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/guide/images/interactresize.gif000066400000000000000000000204321166301720600263120ustar00rootroot00000000000000GIF87a51 <\d<<<<dLdd{tqg=mD1yAyp]uf{-O/X`/TB& C&Ĉ``s&4ˆ0Z[Jqgw"Mw^kމjۍJՍ$16 RF.(#zMe|[~ˆHѧT٢2&?rc#Yx*m],iip'H^{%k|^#3rMKæҴ4n> 8eYGf4:`Nve;N#'/g*HP=BЅ:}D#JщZՄ#ռy4ͣi)pʒh'>Nz³(e;U{tLZ4fP`@PJԡ &xHA2թxS թJQeIKJ3/] ttdiM)]~͘d(*MrҨE+^׾fN@7K>5,bmVKNͬf7{ϸm +A5G̠|M-iUQZ3mc![6-d)KYr 9=;׀uD B sZIa6q{>ޥmn+[?.mzaIOBS<-\o3ڈ.D?jZN uZ2MM`󎔲E,{;;wz(DqP"#$@Ls,MC0gLﶤ^[a.5t- jPʬ-0`c\.{7g ;auuŰ)  018Cqtgf7j2ड.p{ ڞ11Er(N[4ٿQƴ]ijYK]FMRԨ.51Vpe4|Z җ(sAlt׽6%k]7ÝN_j$8\h1?;kGWM1mg;pF nڅ}Q_l:;\]^ cZϱ•Zf?-г}v'}XFmfY 2Nr~Z5'nhc8⦹K~Qތ9$ vdRD7zfZN^V#݀}lܚtA`D%vH1Ls<5/]WEU{]  JGv:ԥqFb+>2%3-g>1i5co/ t1Xz~豽qwOxVoK|;$+y3rgo~wA>bI#&={ߣȿ~u_wxgvywg}.'2Gp}hV }X }P`@Byg|{yHH{~q8Fzdq|'-`D,0 X|l(xIB'vGIz-8}/X}1{3x751PAz>0^p8nLM>L;l8%CX~"~+XN{.(f0j2k4HWH3 ` 3pA<;P 3ai&4X~y|t f}ju8uTkX 9@X<@Eai\@ƀ4:w@~aug}hW x=xH88[G%qw*y({ȀMO7X8h(H8X?2khD8wx8vv?q7}2SX<0=\# )y7xx8{Lҷ~(Hz:AB1rwXv bthhw4SXU#J9O*tGv)؊eTIkDu<0@rƗUɖD;a9tRvɘ䘃vou.OY)iGv֖9nQњ|`9oiI4 ?Ԗtu9hy0,鍧 ORUـIh99ymvYḞ"P8ݸ󒖉Bўߥ9^j ْ) c@RrY%隌堶% `YyP h@-DCCjT! ^E;ʠţ:@2:IM=M4Ebxֆ8& UZڑ|TWTSGUTkmtZjyY e h@0@~ qQ8Hh 8@ɡkꁨݔUdzHلN3کٝie' iZ ;rfjZy40zӚ4ZȪ)j+@44)1S ̺ʬ*Ȫ D69 := >A4: ꨿Zڑ ȉ Zi7y˭EJG??j3 kjHT4#cÊ!|7!ˍjNr7p? A;S&kMӳqï#x zڝVkz4qе wzG;;ѴqX 1D_;a[xz{@ps]4@)CϹ<ѸpCNu 0S[˹[Gñq#JP V[«TK4yqk `I N›ڻtF\7dstkNJ J˺ `  l pL m q30A Av۾4YkR˿\o ml/k  7 6r{;I k <±$M*T\Tܿ ,4\ l8 ibra+JUh5V&|z KywM\mxS|:/2l4 cڷ+6b6I ;4L X:pȈêŐ*[2Ṁ 7bAȦ+9HF߆WȬqL68*jP`5OqKa3G P[ܟL VlŮ,10a0 \|At[P>DMrC_SI ƃ@l% .<17 <0 -<0 3eʥ`XSE#b ](5+7JѦK o>Z-[A-` p 02 r @ ۨZx85* 5d&+7P]Iջ [I& ^j.[yaM{BP1/Ű` ڭ-  ЮzZ:t!HM,7p 7kM_@ݯV *ٸ P*\ҩP1 \۰-۴ڷۻۿ ZJipq4=&65 r ψPݠĦnUNUp-@1a lp߶ۺY J(q6ˀ7h5 Pm U TIRI>$!@ޯ 0]۵=u8;=dJBɲS>.,l͋ "K+̿f1,~^Lr#.?s?!Q6CF94` sc O9K07~\s"?7u5{ +7|.B4s8@:FH 2ْcCOo4Џ'.7R?` njlXczQq`uIubmz/K6jj2_VKJo:/A&E_u2E*UP@ռhhX-FX̎tہ R6U0ErD L7*w ?.H\uY+,ZnG?մj{;pvmui1$F 39B.Si*βQ(&ĨCEZ+e0Fg ;*QG!-[Q>4dIoJM!d) J-y*TI1$SC(Qrˬ2@D͜tS.]2Iʢ<*Ξp&N8<EНCD/TER@vaAҡ<LOEuMA.AIuR"\sM;WUJYEIiM!̘fmY3x%QXGQUr87]je7FlJRgV)pÍ!_hvvLV% =]oօ@2N?ݮtLԜ ⎫$cĘ aRcMN e&~ : .Q`$=FMf1= dG![Qy+)Z(;)fz+ eeݚkqgj7N.µil[ ,n{BDѠ]\Slq Jrk#>;l{s& p7w,7eȱUym'lm@G~g'~o'ץc{ҽ{ ziM\E_>OqT1?-~ V/hUPZ E~uj@:t+ꪅ\/-`7!ȕЄ^ B&փ bp[xJTF }D5щb h*XAyQ`O0!/_GG>яd 9HBD7qqSǝXD"87Б'R$r{$$1YI"2H&wH/}d\/iJ[. /߈"_~#f1vLį)j(IhJS}.lꙦ;>l`M`gDsT8&_Qt F( M.ܳ1'Lٍ uL1?(CPd CQL) g }Gq (0"'K'[!Q+"q,:Z9@AAT@D=+92$RUxE%(p"ܠExЄ6T W,5WB2 у(uY٪îѧ ט9>`80 nP_֑HG ַ2V+5Mv3JB X?[gSEʮvOɱVxE~\U]" E|[_ZyүoK*Wh:`O٪20XSJY #< Iſ٧YPW&0Md1&]'@a@ Ɖqs|ǩ$ y f b 1dguf.'yq@P󝥜BZ ։c)s@ʍޮP@ ]^K3?Z̑~l#-44 e)s2As=4-=ǪS1L(֧q>5[u.XkDZN3q3 2 U\)g8rt| IE.e)k, mߜ?NJρsp}d%ϜXΣ$u4Q#hkNxϻ'Ud cn.<?W0`ȫp2 b<>glZgl _*Ό_E ^ "z+2L}.rp=e<~_:џGA_xAņC+HcW|~c^l {Z|G6pPIbGtd}GH7Xx؁ "8$PH" %6'x 41- hL0EKgd  PFX א-`V@pF @  4wO̐ h#ucPS(_o e;](rӆW:TVXTXnhuP [xP~p X;R }WȆn8Rz 臭}xO[qhȅ0~yhX x؋8XxȘHp+)"+@EȌxn+X7*pvB-Ž- `AP_ǐA-LpXX.rp B iYp I&)&fP_qّ-LC% 79*6)C:IYPR9TYVyXZIؕ^`b9dYfyhjaɌEJ2PF2rḗ|0  Ry٘*`~ !𘘹)9Yy.@ Y}p)pyșʹٜ999j P霝uН9Yy虞깞ٞ&w0Y9(byIy01ȉ  ~ y Р``zڡ&3$ZC!j,J(2:4Z+< ڣ>@B:DZF ##ꠠKʤN#V#]q`b:dZfzhjlڦnpr:tZvzxz|ڧ~z]CzڨA' (SL~ ~4~kH XLGΐ=mW* Gȸ$lX-{ [(lɼ;ġ,FLK˱| ʖleʳ\w{ʧɫ||;ʥ|ʩ\ \y|L|ʰn0p~LšȪ<, |;Θ\"wK\ `*,m̱'Ͼ\:MWֻ |˷|J;`}#`6̉4Lţ_܋|L[Upb F֟߬pt}I05]@[a Rݻ]ց;ْ=֊ưl#*+чʂӁFL. +ښ8, BȲ<̬ M~{^M|͗ٴKԩ];\H=]NݝB߽ޕLƘ߻ڗ̬#`M>=~]| "^>&~(Z*.0{4^6~8:<.;@B>D^F~HJLNPR>T^V~XZ\^`n?f~hjlnpr>beNz|~>}>pB焾>B>>N难n~ꨞꪾꬎ N]hAn\ 붑l]>^N}|@~P>΀OQ`^׎ |.Ϡ @]a/_@ ` YՐo0 w ^?/14_N[ln0 o 0 `1 JE @I~ ^ QW>D^@ )_h L`N6xo8N+?0 0 O +K)r?ِppXa`d/f ]h h N^帟E^#?C FOH厏*Ϗ`Dn@ O +A QGnw%C  ?S Lu >CPB >QD-^ĘQF=~RȆ5 <*4I™!@x<1"DEhQ -T,̚ |f'V:Zu4jĴ 酆^:ڷ_>Lbƍ?YdʎMK2iڔdHh<-Z4mlګV0QqƍH$qDl򰀜9D֭!օWgٺ;]G͟/;a`|'D?!ʟ_Y~2ҬbBe m4AĴ@5aۦU2|/D魪J[$K!|x`,D.l"s=(irK/3SZ$r,4 + s+Y7=mŇL(q(Ji"RRdžGvЅI2S(1+iN=PD5UUWe1@U1$b^^A|(VE6YdtRTy"(}•EeNCR4dg$4tԳ exm5_}߉^ͬLt Il@CJ0VscW47~7rȕC4QX#gĠ.agr5{tg7h&_̂FLaL}fjL0&kzdi R^ %mR o&[T/92L.o-*pY2@Zi6`r1߼ )B_]qFœ .ȽKVH i鄐LC xj֡Xa6"$ ?McGw秿~Oew ^Յ0@|H)@"eg? VЂ*3Xd<ؘ~Є'Da + L*a e8C jCЇ?Bш5OD&6щOL8E0Dbauы_c8F2:BZD8!쏩$Gѱovܒ0>яR`4?kd#%< 9C$#IN#<}LBGRf,% iHVNi" c;#.3K*d/N"4EˉS"d49QҚ\3 Vv$H,# [3ovEpy8>%%Kf> |>d@!YIc5 HnsބbNEF0kэOFJx3#JByNSY$)SyiL[I1$!@jQT"@j)U~4WD)4Mv]&: @`U50)0ҹ|םu3JO3M3}e=aY=Დ5TPv#Z8zVc (Z$UkOTG$3G"\Ӡ)\ېԠr\֓]}zN`Sep^k5m|-ڇ!lB[b/uO-[VB;P&8"(իG`Út#Y:L} &wT J:8{;$P ӳ$&=LZ X-s-]Нn2L$?lnuJWRuw:#* LPjOy4BڊƯ]ZŕQ 2o 8 s`+ fcK2@zaA҄}3{+#,haXy{oCLyC(Y;!go2s %[yՄ!ehK%iN;joW,le?äՠ5(Z:v/ԩk tMOɥ؞JTzuCn!V99nn4]+Ѕ ܡ[eJ$BG= _UO9E{ \?vp}hWp1bbPwt#\ ԩ#(;>}e%W \4xxԡw2~1"o&4[V?2zԱ$?"?A@kr@ƈ VQ@ 0 ȸTdҚFB !$"4BF$TBب&t'lCB)*?@A83k3ED=0D0GLJKLM|GOH5D\`SL=ODITWXExQEP dR4TFEFbEWb4cQe`\,4_ƿsF{DbTmDnddEf;bEhiDGRFhǵF4gyoGd\qxdžG(2LDŽj3q\FǍFǏ$ Hab,D)<?"bb$TE&/0b?03F4V5f6v78c4&:;<==%^9&B6CFDVEfFvGHIJC1 KOPQ&R6SFeIRMdXs#Z[\]e0{f``f[LU(`afU؎U.@vW.^mnf>ebfqF^2Z %Z0h.}?F*^>= DoFpq.h/@gSjxgMn;:>z'#giR"b.{Ȇ.f <@pKkXi4&6FVfj骶6b FH2yB@pfx=ڻY'q븖kq鍠Np~j&Vjfj66^ɖln_j@lhk@XB Uvg%b(hUsqȉ .J%iT@Vn^f6P.fˮlǾlnF68A @4mFmdVj8yk(۶AA8 n>nv FPlnq7q.7qFk obF8VG_Yj-axv :;oܾ~t<@'{t>:/'g0gl YtYq O1G@oDH&W'w)Nri? 1'j(T"pu7v8 Ol:Wt.C/>gfgv?@Od#F?hHhH\\pυLo5(u#Av;mI5YVwXG&YGfXi2_b4{/AH"ʼn+b1#Ǎ;f"&O h%˖._Œ)s&͚6o4po'Ϟ< 0'ѢE 5TIB )SVb s(ϕ\wTͪ#3rҀvZ%txʹ(M>s$x0a.a%eB7L jwcqHiI8I$&~bj6|Ȣk5HK 1Ro ǜpNԜ=k>I٭S- S re6*SRSopƜٹg2J>fL3eAhkhAKHcl3R !ђΔ@B0D 1 <GRYɾҳ#Ĉ eyJ[&lmpyRIc.?6EWڙ8˚iS։է!ة&QmtG@0$?2T@:ҫ{WrKK`0axO}mcU*S^y<' 4򆘷IPô"x\u)q#* vݷۍӁ /f` w#Ҵj\##'>Qx+ɖj&Kȃฦ( RA%$̜E6B2$kK$%YI8ILP߲ZTKG|(T3d !H,2| Z'_pk&1+@jeDA*$ >23KJP$-𤐇Ģ"hB.:\';3Cӵ3+'L'/!O$^12)&| 8@T,~_2:PoPREa& >́IKDY*re k.3K@Q:Т\#6äm{{cg`~QqLi'C:N\*2y@-Q S̓ [ߝg+G%U%ZX i %~of R;Ӟ6RAoQ'Ui䕕p{|*XT@(%XS~ʅ +3aBU[z;&xv7ُS+ݿzzz8ɉ%ި~UTT%ٕڡəxR!*'xBCzA&Bl Cqݜ)Z^$ҕ^U!iU%jqm(b*bhDa 5c( { $V(s@rg"tMg~V քvhh#v  ШI阖) I@Y, YxۛzM%'JmĂvip^P**~*#}Di.ZPJ (*}` BЀ@ *@I\Ix^ahZ ɭf}+T >hA*SA(@&"i 0'azjjlhNaG Ԁ0J D&U׼J[뎶SRgN+*frG5&m*=hQ:~^b8II+++lSi9ۄBlJ"L,C8n~GVjYgXM`)c1w(k(%,lٰD= k"ZJު'*6m ~+zh^;R)L#זGz*efؒmҩ=冞Nݲӯ nj-:-bvh*~ZvyN+B_RnS}x6%v@D*/&.mfr,wb~5Țk~VXӯB)j+PNG_jV%MMtm/N/RBѪ>nwTXdֶć BGM$RmI-ƯgZ(.nkG{p0Kn G Sf WnUn*[pb^.J$敒pd[&_ 7q$J./gR^g1hn~112-v/o ) 3EDfŸ~1/:L "q!/0)r**@p*fö'Lh2NU`2Vnr2„}2J i2NygzʰK$U.wqV/ODkD(d&s)6`˂*X"I@(bIq1mU27χlYv2Y111r9#93;<>3"NWܧopwX10ÄZNtGV12FߖF?QGt/.H4-IhKK#V0Bcp%CNr4[8PXIsQ/A]5(G7SsTOu?Wu++:VU&ۖDzCd5\n5];HsI5?6]%J$,,,$G4Sjw@cc O3tz3M2([65j2u:{g/^7R35?J_?W/m$L)ў,?o-C$|G/hC6iMoGL3kKwee19w\Sg#Q;A(C<π1@iWwjLvKk7PxWaK%SV4YsD6DǷKK8 A7#1~\s-8 ؃^麜`&i$C I8>${O T=H4_3u+8^5.cw6Mz?go4,B?ׁhG-D-i,(kժ`^R!*)VxcF9BT}!# +YtfL3iִ)=:Uyl7ı{pS)ӦSVsgUd:2ТEUz8+WZ@fzBS:@Xq3#\29wH~AJ|7,JIC(@\ ߆{-ۉ85ij*무rY-&k˻ e&<21Y${ϲ2> )Et@TdH*9\(+ȈsP@B }V2 Fs^ `}<&NFr褯5Bml,7 č-z(Щ(ΝW,9X$IF~4ݠ,YT `jFQAJ̗NĞ $MI!/4Ҙ,3&O=CPYIZ&b߸DRAQ> *FZ%*b:8z-kH["8jVLISOPDg)I ~CM /QXQ&KF-jZԞ?JiR}gk?jW/[`8 ߪJP`y\z(|,exwpxE|KG,ќ} " _xs+"ujb52|,p,>!kYbBO-*P9Q/Y^uB*qUL^iȑG<1ŀ)xTV0kqYGd876}B$9ɇn >~mzol2ǻt=IhuA\Y]61ҧ^@4kdpz5\hSZWZ:~ k6l@UI9*Vr᱖uqu))׷6a./%kF'O:ԥ17 L-;Jy+p,qǍNpߚ{i;NWzLik&4Ixg>3Lf.MV8 Σ\qwɽ X8Fp(46Yimy\ y+$z`I Toxt?|2 /þf"Βk>г_ ] /M?LO.1)`V낮)*bLf~qg,.($ fV#"(Zq(( G%' 6w X"s(ԏH{ BJ" $TiK-DŪBq `aP' @( ,"p%6pԊ> &j8j ˫ Ͱ#pprOx6 5A0KvolaX*p&B ." ", kFH =/"S/T VAT@r`(VqqۊejnrQQ"1&o"6HPʻƐ "40Yֲ/9>M%nb@`Qy& JH 9 yԱ(vΕ$#̖\i1#4Դs`%Bqr@@T*rےeB#`#`p$IF++Rf2 #/&K'i t#q&@4@ZZ뼑"kf))c)2 $R$ +RR,^ҚbM %R!ct g\b"4*+B.0o61%2e&+pKKxrDYbDO/&T/5w36F+UD@;}IR4@.kU: 'dEhI%XdsVvaR8a&&Mr^cj 1kg01Bq Ƨ_v2UnSVneetQt&Vfn3pm1XapSH+à$ wq8 r/l%rvFunҐwY78dL"[8Wn?wttm5H)uj%V[vc7ݦ`aw9 `wx ,3(:^ rixr7w{yn/YsTzz7tVWyJ^Ac?"LwsWqAq>k$*V\*O hXOC&s=n!8KwvHٖ& 3xIcWtwڗ %Al!*i~ИpboeTz)ifc6eP|7|?v }wqW#Q+ssp)X09Xs&zcю_lg֓Sg6X5IhQ t78QiwS 58-S&u}$KbtV_buA'?RpOTXhk65l)b!^xͳPZ'?(rrñiwҎ-|#XIh<7bJ9qPPp[FdZZCOoù%9 _=z,m6LKx)lcz*C؛my&/:x=փ:d/q%7z`(#Yy/xkѹ|Z g1Q!2"Fz:=%&7Ǿ\y&08 wuK^'_&r(SZ-5B8+&SYZWǙ&HۧQ԰:?Z=L&.%Lvo{StZy( ='T+&{[9V{{i-a3?343T%q:5m*`9W:WY-ZǺ³Ƴ^'%39 %9a"1M$MºSuA9&{cz%m6oŸ5n8>Ca\AYbƵ[ħB ?p(u 9y42|yTB3t&)-{&iܷ4>5n)ǤyVi?O"͍֜lߜ8%n4Gwt&|Tʩ[5*]W0 " pg7Z%_ iEɌK#_bLT[:Zy{*AMp w< J"Beҽ$r)W}ڀPuQ33!R=1ʫmF]p0t='|ց)}qrz%TY3&bYkY%)L^۳[9C!@݁^51X.*齏Yb]WRݙxT:O2Uv2N# 8LVň:B'3 h[5y;wXbAG$> iNJi^inʩJje[pi&oh*fO g%AuX*TM|k.+Ԡ7#z< {Cm~YBS÷+.۞k$(֮ĚC)BOJձV|j;9F5b.̰LΒy֢qJ:P N &IҹP \/ /[cT:1#"rpEpҀ>\hSk'OM5m#TZWJ)ru oG< 3gk=-՟ިp4h!t2 Vܞ(i/xw ]O%+=+5kvnHRsY؅w'Z8%!.ZBNy].y;تmc]gLk7:XoN9E] !`xIL®Y2_x#@[Kۇ )p'R"4ЋECbAGQ@:(5HqGt SHn"(DH8 28*$Ü@!e:b!vtmX@:.6F8 OLj##A Qc.L$<~c72-4l ¶$c\+#HI1Z6a̜D$La^ARH'MRM\H:aO9JSK!lJRLZeqɥw){8\0Gn}MD&P`J4E/ьVEld$&%JM!%1LKq1'rla lge A9cS;Fg ^HjW`C ^-Yϊֲ~H[͚M)t5ni}LMZrb꓿$}(@FtӒ6#PG,ST9iԶ` `1*elmɧSM UJUT U'U 1VAi]$ʋH"n%g"׺VR[" I3R v DEH@r]RxM1-Iv Ŝ;M 8.K|xoE|cDTω!.n #xZ}[涹2I[-#"uJ RcIr!IdM^6&u٪~6r('ſr`AxL-Ws @jsYI` WX& ' -BO5qnQ*)K_ ؒ8(Ў â'Ȥ]ٲ?%È xf 򳯬 RlXNk|UB*pLV5C\]%D `f wͼPqMm&vZ,:UsW# ov{T{#h<oGwS% R=3蠾X ~2ԧZ|0ںԸ&ߖH"eⷕ/qNȖ"90 _\RP.uK2=ł?99_4 zًvŲn]S3x }>e|Ǝyk#j 3no{|9zIBog}z< 6켓βN˄`Ik ~NEwחeA[ZaOڗ̳Ciϰ9O<~Eܺ@#׽Dw{j^CSG_S _O:ISOuS gC!Q>q>#gt'gt&rw%vxIwIԇwև.g=!X,}}JJ G zNGD!,N~ qq{b5V9;ȃ B'1yC6G6mcPFCqFC~ 'z/(;u ]\ e3H`fXqjpkȆmoq(s5AHcryLx* GORr"VHX{0w H8afP艟(Hh?*x\qTV7WxC&h5AoԂ S VPBQ XP(h'ÊH5^tѡDfol}/+8Syqhe֌D ȏ)(?nؘLJHwӡzXz7w"',xȌ^i')X@x^tB-HZ#~ű2KFg@[, "9+ɔM*8%2*4_dO:9דhMHJc]5!ketE]Qa"Jb%XQA$x˒8dnwiJHJ. 2Q0^ԣhFԕ9 (4і`7-3sy^D] !'S%eX%o)S3@##BC4uIgD7 ȚᚏɖI(,5IG0S} :X!txX7]H؍1r7Uh}S?~0݉nY{E2]"/apj-VBENnsq[i7i?):H釠T:';ɠ᠐J z*@3tSS3`yy9c=c5ʟ52=o t9GzIKJpQ acAs9bf%vciv% i<6j!2oP0UxeF  9 a ِHWZJ! բfiCgnc 2|#?Yp*dёUأƨ)|*Z+   j:_ڛst6tEFJqsK;{G _񍂤j3gP `t/aPSic7w}@gSxq&y2zժieKkyTi 9Hت212j(}a3KZaP00; =k;ñOTOUP5 *@G9Rpc~:K쥫s;,[a y+LZ}u "(Lf;#{ا⩺)/q аSo{^#z۽ +{+`P 1":ٛ(,@ gg0[+ `6` l` _ &Ӊ`Vj;ˮ['ѶW)P:#k;YQí{XXvY  $1^ K@Zh.|ıq7TeA; ^kU*BD,%[ۼq|\{ƕf`7a|hL(ǤT0LĬ`vYS{lȭ+˻Y6ŝ$Qo|r,t X*a ~*LƊJ/ piOɌWܾø@,̕ʘ&ʰ,lh/+xou" jL)<Rll(Yi񼟺Ǟ60رZmАlJ Sy9sSɉE<Ȃemۮ%-'҄i v,jn;^1JyccT̑Gf=} m̉MB$sy 0 ` ` ru]df*єN`=bEQ؋؍)EEi'*Ae o&WhJфԹ/-TJYf}$h]6)ZЪ]J{}<}mmdXLꧮ$)٨5f ^:s@k K@ɝCb<}ū=9cAyKy1y|݆ xGpnK8}Amm[T`]$HJNMRV~X~h>lF^S^b?,`  烾^~*,s~N\w&Of2qАN\јLk*+:.""M̩?~nƦz9>Q|>an޽n¾o.~Л鎅]>^P< J>Q^pGNq_Q *gY=k}V%dP8$(ㆶ?Jlm׼=;Ho :# )/i"9L.3V_3ulj8!NIY_EdzFgkcOS.7*{HjF4jOy1"1# @qV gY H`"DP!JzA1"txĈ9.pLDy@ȄTlޤ)SN=4 ,lXV>qD1C ]Ej!P ׇWP͞EVZm͢4-uśW^}X`."haȆRQ#Ty"$ʔIA0f'Mҥ= @/ hP0>)KDCUխV9z=dG\9ڮqE]tխ_Ǟ]l\7rsLc/V #Uq{@p鶎t褭$RI!Z.B 'lK/C 7C;1)**o2 3L jQAZ> >@N3t'* + d,T CJ+0ľc!ȓ9,[mEn!p/ƭ[obn0t8U`p8`t=`F8a;lK2Xä*@iZu6Uv]GnwwNF @HvW, pLNSY":\[huX.KTbIUsBjnK&\ l8l ܅9ofrF_m",n3TaFY;"sj׶dq۵ ^Hl3c_9Ϸ?b&tӥ˻/'N6j꣚  `|lr|vr0 yCb;t烎ӧzRؾY;]۽g 40!xoj7߷sώ`=io">]0""vT}j#0yEKM6 /|Cd]԰EuH PbU1!>VDb|;^'| "8Ws"&H$M w, p†7{HD, 1ѐ\f bâEo Cv-xdBFo# :Q8c-G?dЃH^WLHĶ'Gj犑;6 xAB;6Y0ƯA eHi6ψcZyGXq}# UK@2Jg<L@Yȹ #rV'5Ȉk Q6M71s ˩SX εa ]O3ck @f qM3^)34R{-B' "ҷmAkeJYVΥĂiR4ӦY<ܸl l?H'=9k` ΐVF븇(30F,YU 9 0ҳm[pҎ7mmlCOaFq Mt)Wuׄc@lQVPwK%Y_))Q Zpzw* 0_hjŢ`eX /i @Ul%#ѢSa')@zAK4K_k| AX͵s]6LI@y=;w,tPAJl!A;ƲFwSK0FE=0jy:d)"Y\k6iq[A#,lǖrر S `@:lerbz0[%π>:$aӤ[i:5t/e 4C;8Á*HzA$+A.A#c!ċ!D2s{@!"#C%JBGZBÂ12$  xE ýC[@( \C6\7ܥ8DC=0=.xn#?C ?yD4]^_`a$b4cFOdƺ +123xV$ULAC@$>mu;tkvA lyAD̐ċ/Ɍ KLDK<+E@یT4L[dɣ\JyڙL؜L.(`8:1+8tϬ<z܌|tYش.hK޴5ӺLx/x#x05 =$ @R{0 놕5=iMTQ Pڴ͈X0+3:f[22˲-ò!3UMuP%S*b&d>HFHR- tNNtJu:57PT[h e=0 Wԛ`P%GmLTGR ҈Ё0,Ph;]Ӳ@0#UW= uIV0Wn &Uu_=*\%_ELLK4 |f5/U 1C/s%8/UBemև pհ'm [nX *uEq ˓yq9p0WypMټT$STۼkh<{-3Xd؆V%ZUՁ84TFŐqXXvӖ< LDyNPLNӡ-ڢXpZE0שUWTpyl 4EyE.NT.LMh>m) # EҸ\ T\$BUp}֒P 8(۪ۓۀw9h!\4\ -\QV\ܿ\ܾX`:ڸ"B%]-.rіZS1;]#鄊uM-^9^Mބ^8Rj`#} 쉤P`L+„lE` t-94]X50Vӥva%ma;`'e=6mQtZ& `t``\ua+,^a,{C؉) TQ5f64Ʌc*+b>^icAMZR@cX 'K~^ aGF'fJTQc`A,X\|xe>cMR%垈䄸h6d.Kt˹eadJ>θ RIh(9>\4foVDc 8]Eې0c_g kDD桥 1H2gcyפW}ٶVnhfiY'ť3VpPg-|> z$f'T xW9T蘎γES%Rh- 4τPTF^^JMD`0cGF F2ΔșP~Lt%|n,[Dlhji A~j]dl_Nd`]>R Y6!цҖM|e֑QQpX4D8~YkMTl~ֲ0UOսqnX )Dmn`ڸc&M7prx1rzUhNkhi7xrD+OlЀaަǖ @NPNҬl-$iDEoDg-V2z2ԧ7/90}Бאʇ6~G~?䧎d3~h{@@!hzzh"ƌ7r#Ȑ}Ds$J Wl%̘2gҬi&Μ:wiɁ?@`(Ф"MS XJ'M \VZ5"Dq"txųҭ[W% F["Ja˥X0 2`Z1+Ȓ'S~O'Ja*PET}H/XbśYǖ[pwQ~$]yMS;9Raxyɡ{=Hq$_J!y$Iޕ(WX^Tg@ a\yEoTIh!r*L?hX!Tsy.g`EYTe掐( '9'Z~1 u [Ma%ehި pyxKry=-#{8Lj i̡BhZޣEZ'zfJTn:RU 8*heLo7*⪣C8(RU0ŧga@@Н5(jqHf<șf JHI%N doK~/dK+v0*%0' {N(%2OuzQSeqy&]{ bI<6")i5jt.ٖ9jJh֪q?#90 5 ȍBe:@7Xםw1F =:镞 TBd.01:@ے/ݙ ,kxZ^J?U wxBeAP9zeUċ?~};9.I wY)MYczz90;8sW%`ք5rHE1& Jr0oH@mQLdC3L&7@PHDnΣ XBS4`qs"&UaE$iL%(|]5 h(G ݸ%.sy1‡Ĺ4R DsJ:eZ&I/Bh&8#%dj-$ʕ+IGX~0qh1Zfw$ %ṕ퐎ӝ`/&FA-4%8јFکg!`(~u1,P~@R|H ~0 PXQH lբ3*Վl 7h%!LTUuLb:S=$>`/y$"Np1HԜnqHU2j%c%Mؘ.BUkX2=y1DPxQ:0%ԁ;;A^ ZI[2S !ZC_bL w& |bL}ng S$I_r͖Qm^|ɮDtsmE7^VKlJy2-OEm8 > I Yˢy=llZYF{af56gTgk웃^:xW 'Kz,t7zv\s~vGjsF$m%ESso$N/Aـ8-j} 6 T 43/[}oe;1oOg&uZ{O|OɑQ3q:q.̵c:qhȓvn{{}wDB/ч~ ~q]~{|HA{,js>=/?>3>/}Gֿ>;?2ኾ$$MmŪ>h]ҿ??`.&. 6Wץ^ϭy}I^I8@ Mި_}ATZT} L!!&.!6>!FNv^! ҄`[UDk &UU"!!&Le!֡!vV!  :KtH|!9-}Faf]"&fbf͡v'"`s"4')zEgi*"++bXȔf%v*X{R"J0y %nPUb+#$2.#363>#4F4N#5V#3v6ʔX#7v7~#8^#99"'A""ҷc!2?#@~c6fc@A2v>.$CBL힍-&"Տ OL">zMU5>H$IDjc6J$KBz$LGBDcEN0mau=䵰OXM%R&R.%S6S>% 6B%UVU^UbGYYN;TYvQQb[%\VTvV\֥]eT"8Yܧ9Ge.OJarWv%c6c>&dFdN&eVd,`fZ&gvg~&h2Vz_6--o&pnq'q&r.gmUf]`z`&lfk^g$&]@r~'xx'yyJ^~wgjjjj'Fe'|: wbz'~~'h}&E YΧkҧu0<(FN(V^(fn(v~(臮;i}^^{V{(%El)v~)))))Ʃ)֩)"biJY)**&)a>*FN*V^*fBDl~****~!N)֪*E**j̮Zj+vU%+FưfN+VƲV+bijf~ҁnJ+^N+~lԏkk"f@| +*k+&, lNu2,JDvʫ^ghȞvZ,vʾY,̊,O^ά,a,lad&>-%.mJV^--њ~m|,؎ mtئmdڒmr+mm-*m-JU6.-NU.n{.jSN-nP[n.v~.膮.閮.ꦮ.붮.Ʈ.֮.:.//&./6>/FN/V^/fn/v~/F///Ư/֯/o@;eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/guide/images/mvctree.gif000066400000000000000000000234311166301720600247260ustar00rootroot00000000000000GIF89av1 Lt <LLLtL ,D$$$,,,$4<,4D44444<<<<<j5'Bԛf)߅G̶56SŮx+dp VM)iJL)W{tQq^ZtUZ^ͺkG 7MVpEݦG~MɱmBV9 ~^4WOoɮv#3s: wtkSMH{1_}ܷ߃FhKl`)1HHFMspIh(P,B"`#!F4s$t-oQ,c؏H"[p6#5rc@9$% iaH`qF,>sh7 X-3ՓDiȔ⑒d&)b!ƘĠJ(,KgϞh:6pdQVx4hљ5 vє'!b1꧗qʊcxt`XfG`3w²_uy'Gʪ6,:g+bJ֦;iR8 u3顥{JE&U0{* 0詮&زJ{i$kc,ζ8rҀ(JKhJ.”=Fw}]NȖw(~4J\z Wm-|yX ~CWv0/=A &\a꽗`_8ĆN2 !@xP-@;"wCnkЎ*9'i 3#m$AJ7'G+>rj?`QU |9qْ放Y"t V6C)MtJ!XBZ#!nB OF:΁r8v4H:OG3ɁCɳ=ky 2I.Aa @^[>ήq z3MD捳.Rvg Ҧ2 )PLnb;t+Cp*2`0fAC1¾ o:6^tAឦN깣+c@θG%jh0 Oˁ'"+7DW"Ewhހx(eCx~CKHG;@:H'黍CaUmĖ^b2y#|Tlv3|2χEOE;T{C%cq#8q_nYZZK apVD8zMug=^ x{un߲kt{%DoW^ 7`?R\w653v2gd~a}gzgz7zgz'~2p\${ q>#2DZ6"Q"v0xJPJR6UWvVNDV1=Pgw y%Hy(GE{Va@p6Cj6X]Q!UAw@]"7H8*iX w6g'R}h%\P SHVz }G~x Mp"5!'PFbS,准`S9u83(g2s @0cpΐ(.x'C8Qţ 0`Rh( H ̸Ћ889{4X8ma#؉ >U E eqV"wpP0y6oG-yD, U+yt)9+4i+2GPhub S\euj;Œ6i+*ɓS)TٓgpgP> ?y+`)*I3`_} ِGyIpp6 4XUie|>J`\*||5\SaaoYq XE\y p|8 ,I: h%%.3YqxCci+rb#VI5WͰ}&H pE*J ``MhÅ-`6&H^cbi#w:yן}iE#I5)`Pe fUfcJ0UytyX}'[CzؠQxJTdpT˦Lssi*Me/JQ~RaF9s5Ew 9Gf>uDpkVYT밗hL?k hI8\ciVtΠ89Dk *C9NZF9eʊ=ڢɀi/=D*9T 7oaW7aJA`\iQ6妔~ zAp|AP6\6W+EJ)@|h !o@=yehA@<ě 9 lċN P\[#QS|ŕc͠Zl\Ƒ045dfXlkrƑtsLJǡT|,v~JƇȽaȄn)N~m ?_N?lk h0' bĈM1\.rk#ȑDLgDW~l2̘gҌhf:9'QB+jҤ%.5ԩTZ5֭\q*l)K) ڵlۺ} 7Z"rڽ{W 8ޠ >wQ1mdt'[~8h˜v7b'E?fIieӪf{M@.yWx4}Ӹkq1OrWNY=xۋw?z?5Qf}>䟳Ao טc w%݁͡`B~3 Suڒa3BG`oa-%"s4)4wBbLAyG^-Xch̊A2%kV"eX_WJaf0@Tl'TKBx(pʹ$tp@|t@ 9z ٘  )Ni#Q)# BTM/5efk]jhXk+{h=vPH(LQ[_4[snJaXkzJ 鮟 Ii~*YnX0b\ю}Ϥv " 8<Ɵ, e3T}v,j`ummw(m \{怿)ؘ_Ep Z78 8f SD fmT(|m a{{D7+q8{3Y݈ACs*b>sߦ7/~=9g2=RԡCQ1sLhGeTgO{*&nIϸ)wvFӥnDb_hT B5cu k . d 77/{ಢj_e(Çzկ}4l['~QN0P*-H{{/*t{RMx e}z_i@"iQGQ~??u~]UQ)w Tx8DdGU,Po׀HQ i4"?"~cCM  V+%j!ArUA@ P^P6|@C@ A8 UoAVg?9?*~EЂmU>jw$=@闅ex&`=|Cg< h|xX-C2 WDzȇa?d|QaGt 8hPIV)X50UVWx+%t x(XXh 1%uDx؇CHx?nq8z(%a@(7mΈ v`(j90(TXԊݔ EHxu֏jCt8 P~8;R!<H(r("9r`mP78>E50Td@p4{%DiKٔJ !$Ia&I|بȒ()2YD8 9()(ْ(la |8pp*MPC9EyeNu~AAPAi9`ٙ䶆b9w0h9+ٗCIqIgwȚȋi)HMVђD$٠*p8М\`Xc yiyiZI⩚ YYǩ6٨i t) Ę`c Ey  R?TXYVb@9 QBiJ [ " 7Y: :՛~9294Z8JƠ7iw7ؤxu9@W E0"**MTWYQǥC>ojCʗF*Hm@1}*8:疤ڰpPpwס[Y>YD@#_MJ 1Jx (i|E i< IjĉDoْ'I p`숬w׊'nu$=%fIVҊ_cLx%چԨ8 úwꛨʫS1خAR: 0mC@xpA~PdJd+>DI z@Q Jn:x8GxAĐ*r )`X <@˰c~_ɝH2IEUJL{I! )%K*D7ۑ3u4z霙0lJp_yT0uv~0u[Awkyf{ wDg[di 7{+ dk 8h !o&R. s>c[vDz踆 &9|R16G0f`=vC; s [qhwjQ<˴+R׫kD)˟K1B3(ȋۇq k }*և.’7;1x[I>6:F[WoRYu4 ,R S{Do{1{| Gb@y~hZo<&?gu!eÇlh=Ħ[O̲v ULX op~H`ԽbHi:`䅞Hf+R ů½P 7Ȏ9{c8S yQċ B= }j=ԟKҐIwP͜28}™\ H=}Yh< b}dUfj 朂fQ~p+ks}VwVy {ײn։`!9K *KXUrٓmٗ=ٝ#3I ةZDڑڰ}ۿ -MM ҚP܁! qE㕊T? o?wXE"wO ={᭙@ܶ Mm/ څ,q͏NA`.1B=Ci<pPwV9>'`Igt9P$(XT4xX&TGYiy *:JZjz {zTDID[X6H4+Kkk^xNۮ0`?"9g"BO"*I2ȑ$KZ[, 07"=r0+AZ**L"4m i2ҥL:E |̘Q#HnDLȈZc*"XrXJ>7޽g#RDEp9<X0aÈ*N٘͜;{f&Xd=t+rKgr84tWKF vJ_ 3jȱF Z'!IWMœ0KHp%cƜo%śrzU֡ivXz׬ڶƽJ%$g,g׼Mĕ̼ps97|tdUTg|]|vecn ߎmz g%V ^-D%-8l=s) uf݅elXbՙb&aWMHIm&׀ni8|cXh"VW5+V$;K<)IRB2VFelUZE:ChlKE$'Di!ީgpu'yJ;S(<8!ޔINW*h:DK=IQ-/ +xG B2?V*0իT!kN",C\@ @ J@6$nfқ $@;$| çAtI )pKnI  %%/ʔ,$̔ < (<  G < 4pёps$@ӑP @?B֍h`3̍У0vEіSCnˍ xdރ8}J 5M.Xm X@zЀ9) Cpne'y-:D9 ͬ%wDlS,P!hT0)XPis { CT 窝7[H(O*>6j:k?O.PtxB| FVU@9P H; V dd AhpR`GHE U")O0AbHCP+[D~f*báDRq("iC(hb%tHOO8,Z(F&qe"31gD#yG71f\G2qjh8v{_ZĆ6a#ɈX,!%QNzkbM㓨 e%&,Kb9JPe._S&_vI\rx /IUd,8S2ә.L>*̌6+McL[8rRX`t2׿ғ6 ='ӠAh%GI+I<ԁ4OR\GE=vm/RtWl)e:DЦ9)tJ8ͧrjل 6nͨTC*Ӕj4̩8*̤2̪v*Ŵ0&5 +)ֲʐ"H MBF} M d[zBUtjTj ~UE"+Ys[߮g:³tQ6;eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/guide/images/selectsequence.gif000066400000000000000000000321041166301720600262660ustar00rootroot00000000000000GIF87a61           $$$$,,,$$$$$$$$$,$,,4$p3oJ]$ 'r&lP&׆Bdߛ;^ B 2*&u@}ĪZY@@7tr֪jQ( X(_MQŒV饙wBずjQ7N6Yj#6nBۈjiѫalku9 %̌`b"xԖE K*#3M rMY>0>vʰپ1DvSf]y \ Ų]ˣن "{2Fp:ySڈCg9W.o<b&px⤳rAA) 6SSR S orÈ0<-01vY,㩂P?]BdRDr;e%Z<-w$z<ހ nv-\N*!йBnO˺S47y2bM^')yp"-T屆D#PƇ@1"RMn><-j(UHis30J8s;ҷ0ܘŮtP%6hw=SEx%(Y$VM^QJr b2QzL)n.s!Rb eDa8d{FB/BO2Bb#6!^*kQ$d /d%2EIeIb  l1sL@tNQfЀBJce-P2/Z|A0`05TnNղvh&6"I:Ѕ4@#B0i=ghxFv0#VT%tTҾbc!,xNudib@=kB [`tW(zn) Hp&nWu([:}i9e(DQ@ ]۶ M8ˍH XXl Ad0 E;|k)MCǓPYA :o~[r|QkxO:.d!/x4i-*!eI)vxϻ3XLw&Ń_T>OUgCM MN#FLJ}hYo'P~  &5s|xGBZP|NHNa RFE$`zQ  l@'dZm!L%i+X< 3XL'5sFԗ%ih2h/r{7X'Y*bQHC4{vhWzbsXh$cC&0 u@c װVf5*z1й#B*$j*$"*,yAv /{sv X ĚaIڒ1!7rD*¬gI{ h[(` $ @<)ا<eM01xzb]Ϭ y%sW"8"͛D@Lh'P2+ 0܄Z3Sڬml7|- ɏ1`NJi1W;@2R'fu% 2/&?%Q"vQ***24#؄$ޜ p*kk]zU!Ʀ `g(>n٢]"imH^#'.2NH )+,d9qqFZYrkAHT~=/%b5#%jb^>4r*""q_~AeJ!0_K Aھ}ԯ QYLT(x  ш2ljQL1ۧ0aA",ᾂLID6PX'bB2V s H JܷAN=}S;D{T)q?>5!U3UV]W CseÆ: }L2Γ ذ:jNܠ0E#:L%lyI6e DpC%1tɲ?0ha1m'Ucu<*ﰾGpFEH1?pEa7~S7uXc(s:V[Q B@*,k8"0A2P,-$$M$ïCix.5L6pr(P ԲCx"1v5Pj@j0)D2I|2J)J+[K0u!/S084;i-ƌ `K=us59JAGCM#)!ζGd4Rf.4SM7SO/So n!ԚVYkCxln"M@5^c޸4l-b4 ΘvLX,R${˗F"3 2%2݀(ꉱZk'[n7a"ZXk"#0!f Zt"1KonsI:XS]CA%bF԰w{r|rj>қLǓ+OÞ)jy#/!kHe3}>~TۖQ\ N9"Ay/z?YĠn(Y0E8BlT +BP&a\?Іkxk?\'C .EDⶄ#&8MtbPCx*Њ[LP8t;$ИF6ƌc+F9+oX=я ǭ{ $ yH LH"GRddyIl̤,yQ~򊡌T)JS:bc"RI#.!:&V#;2Il#2t׬e`ИHRfh 6k'Qt[TJ5mxM,zS$77 iLynrDuΐ&'(O6XbrK(d0 DkyN(쒘}^K}%u-M)'6K 'iDw5(Id$܉-jR5!4W ubnB} ON|W V:2z05_?]oBmOBT nAi:gVp : YϷ0v,h*fYaX \"'mW_pS~Wb-'Vmc):lA/زZê64p}o}+~ xyuSBHzl_=kT<]۞FUP D#¦ߍn[ELL2}bW|"ۈk'5b!Քs/|jm&_ZO=j_rk,,,{>"@E~ qq}UfD-=)y9jLA47; ; Bv? f"997c](/=uc(f4E&1`D"#}̘wq=a;Bbf\O0E ^0 OJE\h^M/϶LF.;tzjUW}kPnik_Ԑ%]Ɇy 6Tv}xy?β_-mBEwPO.6Gw}?em$tY{l1``4x%p|;( x-T >&>rG\:ڪ}І6a\È<Ҁ \\dDK(Q {kA)Wmh~\OرnlL{Ŀ`ýП%< bcnvh:l0<Owpbhc쿧_ 0#!o`#ו4A1=n?ܣ~b? |Z {p /O='֓GPbs+o8Zg: Kȃ##$e:Vc4X@8?b xQ9#vpaC@؁gQ :aԽA?;HAb;! M̍ {i?x ?+q BHY;pրB;A2$AK/܉0;Q.(("2jя; A'"Zĵ((\ =CA;AFP&>L; x9a&ZE9I Ź %;SC݊"8*x /ܣC-Td==,XlͰ FZC阓[J1r# wѸ;9}HhӃ  0<G9jErr|FY#4^ P ޹4ѸP(59ɒpȝB|:`(94:?HH4G!k y1a$G|E( ,(Dؚ1Ɠ,?UljʘJ<IA F|qdP ɢbƈ+`X8BHAJJKW;YH#'\ ^ L\5 HHLBȌK,.Cm=T$Ԧ  ;N!;IFd4ɦ|M)TFBN'lGr"H.ㄸ+.z: {$(D $Nɪ PͦL=aZq`lmHP``h,Jo.8\@4I)*ñ:(iP yQ%mFQ`D(|9R sQ#('K,F&)]`;3FҬ[O̠)m>H\HЅM8SpgehOlMdmK $oH}$p8bȺ+h.MQN]E0I؜pIji^fɥh-$@lHR[M^PRѝ9n1L#āRߙ)Ί+Nlc `MS`@`ݎ$ Rm[mΊ[`Vf& lmFF,h „ 2< Df 'Rh"ƌ>B%,*ee%̘;(&Μ:iԙQ$>A\ФJ)\ӦP:bQHr*+ذ%X¬+m۸e܂jUɄ}xkCGX3/tў*ޣAʐaF8P'_n퓵kYnmѤM@-P+LYZ;6Ǔw׶PD>u6 fB]e\) h]!Vn6gv!* i'(qcP"TFVdik &X5(2:Nn9X@wf)@8(N9j KE`a:⦫䡘 UD XBLTTojk#l`k+#, F=M]Yy=S$uD2ax(@tG Nә/ !GSA-gBx.DhfJҺYw.UiهYZgPa/Y-gwD*`i!̈́g2!`0cf/m&CmY/hvf(~QڮAjWU}U- T7F}Җ&vb6Z؍*\,bZ@l}2YA] w2w!ȡ54'wvs~co+DU^0Y'Kwd4NgKQuEb>buݠ ׈MoqP2r$zW7 R /x*{UԀ)SZT|әfռ Һ&[0r ā+y&!!F<" &ƃLS gc)Y-"1 k0 9U8@bz* Dn\b/DwH2Lg*%7,Ki2 %)YUFòH܉ALI@愮󑊐Q$"BX*ő^$'iۀJ;tVĪxYv̘ϕ%-5lĖx 3e'DbtmmbuV"[aAL;JĚ &7-Ѐjě$D(kА E(C ъtQU$jkr/G„qE!M]GO42&UK[JT.1 MkJӚ(<=OJ U,9Q[JԢ*LՋJP tCf{*BGpHV˒ԉfH8k bpV3nMX!I+AT;KF'B&x2D6ǚ5zZC{CH`)aEGrZiAN3!I مlVͲl=Jlv-jO%r4-QO+diX*\8M1bz:s>ί<׹hO[Z/ KK 9~.Kwy/xT]\HM}'v4nC?o,˫T-vמ@i ےz K eW% ]7=+޽UiHM`ZzA Ƿ\ևFxs-RYU#ln )SVEhŋ$\XҜ1!r99&6B X~3,g "L.L(y~3-h^ᯞYV k6)dI*e Ӟ4X29Fؑi!֛d-2#.ϰJ~jN9fb䝙6Q%`[䛞+J<9m+H2OG-`'d.2#@Z[y$f24ô}K¾oJe;[z Nt<cWCkבE8SI9U.|j19ι¦De) r';?9Mԥ&G~8u#8HVo%zNq$Ad A^<jXƾwlzj3{&O}/cg}]_Wow~F,gT^NK~$oŐoc4?] U^& C< La U Viy>[ S  : Ơ O`q`M  `r!O)al 2k8ILYeP!AbadhayIa^qa\ȩF[!!mz)ގX\ b3[bQ;eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/guide/index.html000066400000000000000000000020761166301720600233240ustar00rootroot00000000000000 org.eclipse.gef Programmer's Guide

    GEF Programmer's Guide
    org.eclipse.gef

    Draw2d focuses on efficient painting and layout of figures. The GEF plug-in adds an editing layer on top of Draw2d. The purpose of this framework is to:

    1. Facilitate the display of some existing model graphically using draw2d figures

    2. Support interactions from mouse, keyboard, or the Eclipse workbench

    3. Provide common components related to the above

    eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/notices.html000066400000000000000000000014101166301720600225530ustar00rootroot00000000000000 Legal Notices

    Notices

    The material in this guide is Copyright (c) IBM Corporation and others 2007.

    Terms and conditions regarding the use of this guide.

    eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/plugin.properties000066400000000000000000000013631166301720600236440ustar00rootroot00000000000000############################################################################### # Copyright (c) 2002, 2009 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # # Contributors: # IBM Corporation - initial API and implementation ############################################################################### GEF_Debug_view_name = GEF Debug GEF_Developer_views_category_name = GEF Developer GEF_stackviewer_view_name = Stack Viewer Plugin.name=Graphical Editing Framework GEF Documentation Plugin.providerName=Eclipse Modeling Projecteclipse-gef-3.7.1/org.eclipse.gef.doc.isv/plugin.xml000066400000000000000000000017431166301720600222520ustar00rootroot00000000000000 eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/toc.xml000066400000000000000000000021611166301720600215340ustar00rootroot00000000000000 eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/topics_Guide.xml000066400000000000000000000020261166301720600233650ustar00rootroot00000000000000 eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/topics_Reference.xml000066400000000000000000000057171166301720600242400ustar00rootroot00000000000000 eclipse-gef-3.7.1/org.eclipse.gef.doc.isv/topics_Samples.xml000066400000000000000000000021751166301720600237410ustar00rootroot00000000000000 eclipse-gef-3.7.1/org.eclipse.gef/000077500000000000000000000000001166301720600166615ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.gef/.checkstyle000066400000000000000000000010411166301720600210140ustar00rootroot00000000000000 eclipse-gef-3.7.1/org.eclipse.gef/.classpath000066400000000000000000000005571166301720600206530ustar00rootroot00000000000000 eclipse-gef-3.7.1/org.eclipse.gef/.cvsignore000066400000000000000000000001261166301720600206600ustar00rootroot00000000000000bin runtime temp.folder thumbs.db preview.pix .classpath *.jpage *.prefs org eclipse-gef-3.7.1/org.eclipse.gef/.project000066400000000000000000000016171166301720600203350ustar00rootroot00000000000000 org.eclipse.gef org.eclipse.jdt.core.javabuilder org.eclipse.pde.ManifestBuilder org.eclipse.pde.SchemaBuilder org.eclipse.pde.api.tools.apiAnalysisBuilder org.eclipse.jdt.core.javanature com.atlassw.tools.eclipse.checkstyle.CheckstyleNature org.eclipse.pde.PluginNature org.eclipse.pde.api.tools.apiAnalysisNature eclipse-gef-3.7.1/org.eclipse.gef/.settings/000077500000000000000000000000001166301720600205775ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.gef/.settings/.api_filters000066400000000000000000000174741166301720600231160ustar00rootroot00000000000000 eclipse-gef-3.7.1/org.eclipse.gef/.settings/checkstyleAPI.xml000066400000000000000000000013501166301720600240100ustar00rootroot00000000000000 eclipse-gef-3.7.1/org.eclipse.gef/.settings/checkstyleGeneric.xml000066400000000000000000000111541166301720600247560ustar00rootroot00000000000000 eclipse-gef-3.7.1/org.eclipse.gef/.settings/org.eclipse.jdt.core.prefs000066400000000000000000000654431166301720600255750ustar00rootroot00000000000000#Tue Nov 16 19:49:32 CET 2010 eclipse.preferences.version=1 org.eclipse.jdt.core.codeComplete.argumentPrefixes= org.eclipse.jdt.core.codeComplete.argumentSuffixes= org.eclipse.jdt.core.codeComplete.fieldPrefixes= org.eclipse.jdt.core.codeComplete.fieldSuffixes= org.eclipse.jdt.core.codeComplete.localPrefixes= org.eclipse.jdt.core.codeComplete.localSuffixes= org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.4 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.doc.comment.support=enabled org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning org.eclipse.jdt.core.compiler.problem.autoboxing=ignore org.eclipse.jdt.core.compiler.problem.deprecation=warning org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=protected org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled org.eclipse.jdt.core.compiler.problem.unusedImport=warning org.eclipse.jdt.core.compiler.problem.unusedLocal=warning org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.3 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_assignment=0 org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 org.eclipse.jdt.core.formatter.blank_lines_after_package=1 org.eclipse.jdt.core.formatter.blank_lines_before_field=0 org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 org.eclipse.jdt.core.formatter.blank_lines_before_method=1 org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 org.eclipse.jdt.core.formatter.blank_lines_before_package=0 org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false org.eclipse.jdt.core.formatter.comment.format_block_comments=true org.eclipse.jdt.core.formatter.comment.format_header=false org.eclipse.jdt.core.formatter.comment.format_html=true org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true org.eclipse.jdt.core.formatter.comment.format_line_comments=true org.eclipse.jdt.core.formatter.comment.format_source_code=true org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true org.eclipse.jdt.core.formatter.comment.indent_root_tags=true org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert org.eclipse.jdt.core.formatter.comment.line_length=80 org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true org.eclipse.jdt.core.formatter.compact_else_if=true org.eclipse.jdt.core.formatter.continuation_indentation=2 org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true org.eclipse.jdt.core.formatter.indent_empty_lines=false org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false org.eclipse.jdt.core.formatter.indentation.size=4 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert org.eclipse.jdt.core.formatter.join_lines_in_comments=true org.eclipse.jdt.core.formatter.join_wrapped_lines=true org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false org.eclipse.jdt.core.formatter.lineSplit=80 org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true org.eclipse.jdt.core.formatter.tabulation.char=tab org.eclipse.jdt.core.formatter.tabulation.size=4 org.eclipse.jdt.core.formatter.use_on_off_tags=false org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true eclipse-gef-3.7.1/org.eclipse.gef/.settings/org.eclipse.jdt.ui.prefs000066400000000000000000000205011166301720600252440ustar00rootroot00000000000000#Tue Nov 16 19:49:32 CET 2010 eclipse.preferences.version=1 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true formatter_profile=org.eclipse.jdt.ui.default.eclipse_profile formatter_settings_version=11 internal.default.compliance=default org.eclipse.jdt.ui.exception.name=e org.eclipse.jdt.ui.gettersetter.use.is=true org.eclipse.jdt.ui.ignorelowercasenames=true org.eclipse.jdt.ui.importorder=java;org.eclipse.swt;org.eclipse;org.eclipse.draw2d;org.eclipse.gef;org.eclipse.gef.examples; org.eclipse.jdt.ui.javadoc=false org.eclipse.jdt.ui.keywordthis=false org.eclipse.jdt.ui.ondemandthreshold=999 org.eclipse.jdt.ui.overrideannotation=true org.eclipse.jdt.ui.text.custom_code_templates= sp_cleanup.add_default_serial_version_id=true sp_cleanup.add_generated_serial_version_id=false sp_cleanup.add_missing_annotations=true sp_cleanup.add_missing_deprecated_annotations=true sp_cleanup.add_missing_methods=false sp_cleanup.add_missing_nls_tags=false sp_cleanup.add_missing_override_annotations=true sp_cleanup.add_missing_override_annotations_interface_methods=true sp_cleanup.add_serial_version_id=false sp_cleanup.always_use_blocks=true sp_cleanup.always_use_parentheses_in_expressions=false sp_cleanup.always_use_this_for_non_static_field_access=false sp_cleanup.always_use_this_for_non_static_method_access=false sp_cleanup.convert_to_enhanced_for_loop=false sp_cleanup.correct_indentation=false sp_cleanup.format_source_code=true sp_cleanup.format_source_code_changes_only=false sp_cleanup.make_local_variable_final=false sp_cleanup.make_parameters_final=false sp_cleanup.make_private_fields_final=true sp_cleanup.make_type_abstract_if_missing_method=false sp_cleanup.make_variable_declarations_final=true sp_cleanup.never_use_blocks=false sp_cleanup.never_use_parentheses_in_expressions=true sp_cleanup.on_save_use_additional_actions=false sp_cleanup.organize_imports=true sp_cleanup.qualify_static_field_accesses_with_declaring_class=false sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true sp_cleanup.qualify_static_member_accesses_with_declaring_class=false sp_cleanup.qualify_static_method_accesses_with_declaring_class=false sp_cleanup.remove_private_constructors=true sp_cleanup.remove_trailing_whitespaces=false sp_cleanup.remove_trailing_whitespaces_all=true sp_cleanup.remove_trailing_whitespaces_ignore_empty=false sp_cleanup.remove_unnecessary_casts=true sp_cleanup.remove_unnecessary_nls_tags=false sp_cleanup.remove_unused_imports=false sp_cleanup.remove_unused_local_variables=false sp_cleanup.remove_unused_private_fields=true sp_cleanup.remove_unused_private_members=false sp_cleanup.remove_unused_private_methods=true sp_cleanup.remove_unused_private_types=true sp_cleanup.sort_members=false sp_cleanup.sort_members_all=false sp_cleanup.use_blocks=false sp_cleanup.use_blocks_only_for_return_and_throw=false sp_cleanup.use_parentheses_in_expressions=false sp_cleanup.use_this_for_non_static_field_access=false sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true sp_cleanup.use_this_for_non_static_method_access=false sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true eclipse-gef-3.7.1/org.eclipse.gef/.settings/org.eclipse.pde.api.tools.prefs000066400000000000000000000103011166301720600265230ustar00rootroot00000000000000#Wed Dec 10 16:00:46 EST 2008 ANNOTATION_ELEMENT_TYPE_ADDED_METHOD_WITHOUT_DEFAULT_VALUE=Error ANNOTATION_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error ANNOTATION_ELEMENT_TYPE_REMOVED_FIELD=Error ANNOTATION_ELEMENT_TYPE_REMOVED_METHOD=Error ANNOTATION_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error API_COMPONENT_ELEMENT_TYPE_REMOVED_API_TYPE=Error API_COMPONENT_ELEMENT_TYPE_REMOVED_TYPE=Error CLASS_ELEMENT_TYPE_ADDED_METHOD=Error CLASS_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error CLASS_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error CLASS_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error CLASS_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error CLASS_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error CLASS_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error CLASS_ELEMENT_TYPE_CHANGED_RESTRICTIONS=Error CLASS_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error CLASS_ELEMENT_TYPE_REMOVED_CONSTRUCTOR=Error CLASS_ELEMENT_TYPE_REMOVED_FIELD=Error CLASS_ELEMENT_TYPE_REMOVED_METHOD=Error CLASS_ELEMENT_TYPE_REMOVED_SUPERCLASS=Error CLASS_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error CLASS_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error CONSTRUCTOR_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error CONSTRUCTOR_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error CONSTRUCTOR_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error CONSTRUCTOR_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error ENUM_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error ENUM_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error ENUM_ELEMENT_TYPE_REMOVED_ENUM_CONSTANT=Error ENUM_ELEMENT_TYPE_REMOVED_FIELD=Error ENUM_ELEMENT_TYPE_REMOVED_METHOD=Error ENUM_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error FIELD_ELEMENT_TYPE_ADDED_VALUE=Error FIELD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error FIELD_ELEMENT_TYPE_CHANGED_FINAL_TO_NON_FINAL_STATIC_CONSTANT=Error FIELD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error FIELD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error FIELD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error FIELD_ELEMENT_TYPE_CHANGED_TYPE=Error FIELD_ELEMENT_TYPE_CHANGED_VALUE=Error FIELD_ELEMENT_TYPE_REMOVED_TYPE_ARGUMENT=Error FIELD_ELEMENT_TYPE_REMOVED_VALUE=Error ILLEGAL_EXTEND=Error ILLEGAL_IMPLEMENT=Error ILLEGAL_INSTANTIATE=Error ILLEGAL_OVERRIDE=Error ILLEGAL_REFERENCE=Error INTERFACE_ELEMENT_TYPE_ADDED_FIELD=Error INTERFACE_ELEMENT_TYPE_ADDED_METHOD=Error INTERFACE_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error INTERFACE_ELEMENT_TYPE_ADDED_SUPER_INTERFACE_WITH_METHODS=Error INTERFACE_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error INTERFACE_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error INTERFACE_ELEMENT_TYPE_CHANGED_RESTRICTIONS=Error INTERFACE_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error INTERFACE_ELEMENT_TYPE_REMOVED_FIELD=Error INTERFACE_ELEMENT_TYPE_REMOVED_METHOD=Error INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error INVALID_JAVADOC_TAG=Error INVALID_REFERENCE_IN_SYSTEM_LIBRARIES=Error LEAK_EXTEND=Error LEAK_FIELD_DECL=Error LEAK_IMPLEMENT=Error LEAK_METHOD_PARAM=Error LEAK_METHOD_RETURN_TYPE=Error METHOD_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error METHOD_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error METHOD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error METHOD_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error METHOD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error METHOD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error METHOD_ELEMENT_TYPE_CHANGED_RESTRICTIONS=Error METHOD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error METHOD_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error METHOD_ELEMENT_TYPE_REMOVED_ANNOTATION_DEFAULT_VALUE=Error METHOD_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error TYPE_PARAMETER_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error TYPE_PARAMETER_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error eclipse.preferences.version=1 incompatible_api_component_version=Error incompatible_api_component_version_include_major_without_breaking_change=Disabled incompatible_api_component_version_include_minor_without_api_change=Disabled invalid_since_tag_version=Error malformed_since_tag=Error missing_since_tag=Error report_api_breakage_when_major_version_incremented=Disabled report_resolution_errors_api_component=Error eclipse-gef-3.7.1/org.eclipse.gef/META-INF/000077500000000000000000000000001166301720600200215ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.gef/META-INF/MANIFEST.MF000066400000000000000000000034401166301720600214540ustar00rootroot00000000000000Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Plugin.name Bundle-SymbolicName: org.eclipse.gef; singleton:=true Bundle-Version: 3.7.1.qualifier Bundle-Activator: org.eclipse.gef.internal.InternalGEFPlugin Bundle-Vendor: %Plugin.providerName Bundle-Localization: plugin Import-Package: com.ibm.icu.text;version="[3.8.1,5.0.0)" Export-Package: org.eclipse.gef, org.eclipse.gef.commands, org.eclipse.gef.dnd, org.eclipse.gef.editparts, org.eclipse.gef.editpolicies, org.eclipse.gef.handles, org.eclipse.gef.internal;x-friends:="org.eclipse.gef.examples.text,org.eclipse.gef.examples.logic", org.eclipse.gef.internal.icons;x-internal:=true, org.eclipse.gef.internal.ui.palette;x-internal:=true, org.eclipse.gef.internal.ui.palette.editparts;x-internal:=true, org.eclipse.gef.internal.ui.rulers;x-internal:=true, org.eclipse.gef.palette, org.eclipse.gef.print, org.eclipse.gef.requests, org.eclipse.gef.rulers, org.eclipse.gef.tools, org.eclipse.gef.ui.actions, org.eclipse.gef.ui.console, org.eclipse.gef.ui.console.icons, org.eclipse.gef.ui.palette, org.eclipse.gef.ui.palette.customize, org.eclipse.gef.ui.palette.editparts, org.eclipse.gef.ui.parts, org.eclipse.gef.ui.properties, org.eclipse.gef.ui.rulers, org.eclipse.gef.ui.stackview, org.eclipse.gef.ui.stackview.icons, org.eclipse.gef.ui.views.palette, org.eclipse.gef.util Require-Bundle: org.eclipse.draw2d;visibility:=reexport;bundle-version="[3.7.0,4.0.0)", org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)", org.eclipse.ui.views;resolution:=optional;bundle-version="[3.2.0,4.0.0)", org.eclipse.ui.workbench;bundle-version="[3.2.0,4.0.0)", org.eclipse.jface;bundle-version="[3.2.0,4.0.0)" Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: J2SE-1.4 eclipse-gef-3.7.1/org.eclipse.gef/about.html000066400000000000000000000024631166301720600206660ustar00rootroot00000000000000 About

    About This Content

    June 5, 2007

    License

    The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available at http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, "Program" will mean the Content.

    If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party ("Redistributor") and different terms and conditions may apply to your use of any object code in the Content. Check the Redistributor's license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise indicated below, the terms and conditions of the EPL still apply to any source code in the Content and such source code may be obtained at http://www.eclipse.org.

    eclipse-gef-3.7.1/org.eclipse.gef/about.ini000066400000000000000000000006261166301720600205000ustar00rootroot00000000000000# about.ini # contains information about a feature # java.io.Properties file (ISO 8859-1 with "\" escapes) # "%key" are externalized strings defined in about.properties # This file does not need to be translated. # Property "aboutText" contains blurb for "About" dialog (translated) aboutText=%blurb # Property "featureImage" contains path to feature image (32x32) featureImage=modeling32.png eclipse-gef-3.7.1/org.eclipse.gef/about.mappings000066400000000000000000000002551166301720600215350ustar00rootroot00000000000000# about.mappings # contains fill-ins for about.properties # java.io.Properties file (ISO 8859-1 with "\" escapes) # This file does not need to be translated. 0=@build@eclipse-gef-3.7.1/org.eclipse.gef/about.properties000066400000000000000000000016631166301720600221170ustar00rootroot00000000000000############################################################################### # Copyright (c) 2000, 2009 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # # Contributors: # IBM Corporation - initial API and implementation ############################################################################### # about.properties # contains externalized strings for about.ini # java.io.Properties file (ISO 8859-1 with "\" escapes) # fill-ins are supplied by about.mappings # This file should be translated. blurb=Eclipse Graphical Editing Framework GEF\n\ \n\ Version: {featureVersion}\n\ Build id: {0}\n\ \n\ (c) Copyright Eclipse Contributors and others 2000, 2009. All rights reserved.\n\ Visit http://www.eclipse.org/gef eclipse-gef-3.7.1/org.eclipse.gef/build.properties000066400000000000000000000016731166301720600221050ustar00rootroot00000000000000############################################################################### # Copyright (c) 2002, 2009 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # # Contributors: # IBM Corporation - initial API and implementation ############################################################################### bin.includes = about.*,\ modeling32.png,\ plugin.xml,\ plugin.properties,\ icons/*.gif,\ .,\ META-INF/ bin.excludes = **/doc-files/** source.. = src/ src.includes = src/org/eclipse/gef/internal/icons/,\ src/org/eclipse/gef/ui/console/icons/,\ src/org/eclipse/gef/ui/stackview/icons/ eclipse-gef-3.7.1/org.eclipse.gef/icons/000077500000000000000000000000001166301720600177745ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.gef/icons/palette_view.gif000066400000000000000000000011711166301720600231530ustar00rootroot00000000000000GIF89a!(ޘӷ[.fXQ 3)4-!^,ր^) ")G]G@VXVRQR@XTXQSP* VR\ *)4FAA+34I42)^"WYWA55#NMN"^!YUY$A; >MOM!0W1HE\N)=^X…ȅ!.dh u6/u(zF>z{1[<󂁚x /WJbmԜ`rݚ&uޒyfffjn%QkAb,dG/D ‘}._)2'/J_>$ ҆8mٲ^?E~ zAhit&{;dm6k$S u_{%m-KWW֬k%=zUXKs6#!"<26Tyx}8/\0}7詇H&쳯ѥKYiuϞ~};  1t#W#p ::Zܾ}G<o|a߾~7soOӮ=J>v~JŲLAWtq~78k]dXOo_]]뵷4+y4OѴ(0P.XPc~n\`4| g\# [h5nk+Лc轡Zª%,\b>474)݅rvF>ᑑhOpx`jHƺ3\R0 U_(Б%6,sGQgFvJrꗽ@\2+4AAxB `F3pM&n#J27Oz+Aj_ ʘWvoIENDB`eclipse-gef-3.7.1/org.eclipse.gef/plugin.properties000066400000000000000000000017431166301720600223020ustar00rootroot00000000000000############################################################################### # Copyright (c) 2000, 2009 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # # Contributors: # IBM Corporation - initial API and implementation ############################################################################### Plugin.name= Graphical Editing Framework GEF Plugin.providerName= Eclipse Modeling Project ############################################## # Zoom Actions ############################################## ZoomIn.Tooltip=Zoom In ZoomIn.Label=Zoom &In ZoomOut.Tooltip=Zoom Out ZoomOut.Label=Zoom &Out ############################################## # View Key Binding Category ############################################## ViewCategory.Label=View Palette.Label=Palette eclipse-gef-3.7.1/org.eclipse.gef/plugin.xml000066400000000000000000000045441166301720600207100ustar00rootroot00000000000000 eclipse-gef-3.7.1/org.eclipse.gef/src/000077500000000000000000000000001166301720600174505ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.gef/src/org/000077500000000000000000000000001166301720600202375ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/000077500000000000000000000000001166301720600216635ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/000077500000000000000000000000001166301720600224245ustar00rootroot00000000000000eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/AccessibleAnchorProvider.java000066400000000000000000000044521166301720600301770ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import java.util.List; /** * This class provides keyboard accessibility support for Anchors. * Anchors are simply locations (relative to the Viewer's Control) on the * GraphicalEditPart's figure indicated by * {@link org.eclipse.draw2d.geometry.Point Points}. Anchors are used when * creating or manipulating connections graphically. Accessible Anchors * are the locations that should be used during keyboard connection * manipulation. *

    * Keyboard connection manipulation moves the Mouse cursor programmatically to * the AccessibleAnchor's location. Targeting is still performed as if the User * were using the Mouse and not the keyboard. Therefore, the GraphicalEditPart * should provide locations that will result in its being targeted by the * current tool. *

    * Connection operations involves either the source or target end of a * connection. The AccessibleAnchorProvider has the option of * returning different locations depending on the context of the operatation. */ public interface AccessibleAnchorProvider { /** * Returns a list of Points in absolute coordinates where source * anchors are located. Tools that work with connections should use these * locations when operating in accesible keyboard modes. * * @return A list of absolute locations (Points relative to the Viewer's * Control) */ List getSourceAnchorLocations(); /** * Returns a list of Points in absolute coordinates where target * anchors are located. Tools that work with connections should use these * locations when operating in accesible keyboard modes. * * @return A list of absolute locations (Points relative to the Viewer's * Control) */ List getTargetAnchorLocations(); } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/AccessibleEditPart.java000066400000000000000000000071521166301720600267660ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import org.eclipse.swt.accessibility.AccessibleControlEvent; import org.eclipse.swt.accessibility.AccessibleEvent; import org.eclipse.draw2d.AccessibleBase; /** * This class provides Accessibility support for * {@link org.eclipse.gef.EditPart EditParts}. EditParts are the unit of * selection in GEF. When selection changes, Accessibility clients are notified. * These clients then query the EditPartViewer for various accessibility * information. *

    * EditParts must provide AccessibileEditPart adapters in order to work with * screen-readers, screen magnifiers, and other accessibility tools. EditParts * should override * {@link org.eclipse.gef.editparts.AbstractEditPart#getAccessibleEditPart()}. * * @author hudsonr */ public abstract class AccessibleEditPart extends AccessibleBase { /** * @see org.eclipse.swt.accessibility.AccessibleControlAdapter#getChildCount(AccessibleControlEvent) * @param e * AccessibleControlEvent */ public abstract void getChildCount(AccessibleControlEvent e); /** * @see org.eclipse.swt.accessibility.AccessibleControlAdapter#getChildren(AccessibleControlEvent) * @param e * AccessibleControlEvent */ public abstract void getChildren(AccessibleControlEvent e); /** * @see org.eclipse.swt.accessibility.AccessibleControlAdapter#getDefaultAction(AccessibleControlEvent) * @param e * AccessibleControlEvent */ public void getDefaultAction(AccessibleControlEvent e) { } /** * @see org.eclipse.swt.accessibility.AccessibleAdapter#getDescription(AccessibleEvent) * @param e * AccessibleEvent */ public void getDescription(AccessibleEvent e) { } /** * @see org.eclipse.swt.accessibility.AccessibleAdapter#getKeyboardShortcut(AccessibleEvent) * @param e * AccessibleEvent */ public void getKeyboardShortcut(AccessibleEvent e) { } /** * @see org.eclipse.swt.accessibility.AccessibleAdapter#getHelp(AccessibleEvent) * @param e * AccessibleEvent */ public void getHelp(AccessibleEvent e) { } /** * @see org.eclipse.swt.accessibility.AccessibleAdapter#getName(AccessibleEvent) * @param e * AccessibleEvent */ public abstract void getName(AccessibleEvent e); /** * @see org.eclipse.swt.accessibility.AccessibleControlAdapter#getLocation(AccessibleControlEvent) * @param e * AccessibleControlEvent */ public abstract void getLocation(AccessibleControlEvent e); /** * @see org.eclipse.swt.accessibility.AccessibleControlAdapter#getRole(AccessibleControlEvent) * @param e * AccessibleControlEvent */ public void getRole(AccessibleControlEvent e) { } /** * @see org.eclipse.swt.accessibility.AccessibleControlAdapter#getState(AccessibleControlEvent) * @param e * AccessibleControlEvent */ public abstract void getState(AccessibleControlEvent e); /** * @see org.eclipse.swt.accessibility.AccessibleControlAdapter#getValue(AccessibleControlEvent) * @param e * AccessibleControlEvent */ public void getValue(AccessibleControlEvent e) { } } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/AccessibleHandleProvider.java000066400000000000000000000034031166301720600301530ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import java.util.List; /** * This class provides keyboard accessibility support for the {@link Handle * Handles} of the primary-selected {@link EditPart}. Handles are grabbable * regions on the screen. Typically the user will grab a handle by pressing and * holding the mouse button. This function must also be available via the * keyboard for accessibility reasons. Even mouse Users will appreciate the * fine-grained control offered by the keyboard for operations like "nudging". *

    * The SelectionTool is the primary client for Handles. When it is active, the * PERIOD keystroke will cycle through the list of Accessibile locations * (Points) supplied by the current EditPart. The "current EditPart" is defined * as the EditPart with primary selection. */ public interface AccessibleHandleProvider { /** * Returns a list of Points in absolute coordinates where * {@link Handle Handles} are located. {@link Tool Tools} that work with * Handles should use these locations when operating in accesible keyboard * modes. * * @return A list of absolute locations (Points relative to the Viewer's * Control); cannot be null */ List getAccessibleHandleLocations(); } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/AutoexposeHelper.java000066400000000000000000000100371166301720600265640ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import java.util.Collection; import org.eclipse.draw2d.geometry.Point; /** * A helper returned from a {@link org.eclipse.gef.GraphicalEditPart}. Certain * DragTrackers tools and native drop listeners will make use of * autoexpose helpers to reveal any potential drop areas that are currently not * visible to the user. An example of this is scrolling a container to reveal * unexposed area. Another example is a bunch of stacked containers in a * "tab folder" arrangement, whever hovering over a tab should switch which * container is on top. *

    * Autoexpose helpers are obtained from editparts that are target of whatever * operation is being performed. If the target provides no helper, its parent * chain is traversed looking for helpers. A helper will be obtained under * conditions deemed appropriate by the caller, such as when the mouse has * paused for some amount of time in the current location. *

    * An autoexpose helper may be short-lived or long-running. A short-lived helper * would be something like the example described above when a "page" is being * flipped. A long-running example is auto-scrolling. A helper requests to * remains active by returning true from its {@link #step(Point)} * method for as long as necessary. An active helper can remain active even as * the mouse is moving. The client may stop calling step(Point) at * any time, even if false was never returned, such as when the * user releases the mouse. * * @author hudsonr */ public interface AutoexposeHelper { /** * Returns true if the specified location is interesting to the * helper. This method gets called as part of the search for an * AutoexposeHelper. The helper should do something if it returns * true, or it may wait for {@link #step(Point)} to be called * later. * * @param where * the mouse's current location in the viewer * @return true if the location is interesting */ boolean detect(Point where); /** * Performs the autoexpose and returns a hint indicating that the helper * would like to remain active. The client will continue to call step() for * as long as it previously returned true, and the conditions * are deemed appropriate to continue the autoexpose process. *

    * The client may stop calling this method at any time, even if the previous * invocation returned true. The return value is a hint. * * @param where * the current location of the mouse in the viewer * @return a hint indicating whether this helper should continue to be * invoked */ boolean step(Point where); /** * Used with EditPartViewers to find the AutoexposeHelper at a Point. * Clients can instantiate the search, call * {@link EditPartViewer#findObjectAtExcluding(Point,Collection, EditPartViewer.Conditional)} * , and then check the {@link #result} field. */ class Search implements EditPartViewer.Conditional { /** * Constructs a new Search at a point on the viewer. * * @param pt * the mouse location */ public Search(Point pt) { where = pt; } /** * the result of the search. */ private Point where; public AutoexposeHelper result; public boolean evaluate(EditPart editpart) { result = (AutoexposeHelper) editpart .getAdapter(AutoexposeHelper.class); if (result != null && result.detect(where)) return true; result = null; return false; } } } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/CompoundSnapToHelper.java000066400000000000000000000036421166301720600273450ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import org.eclipse.core.runtime.Assert; import org.eclipse.draw2d.geometry.PrecisionRectangle; /** * Combines multiple SnapToHelpers into one compound helper. The compound helper * deletages to multiple other helpers. * * @author Pratik Shah */ public class CompoundSnapToHelper extends SnapToHelper { private SnapToHelper[] delegates; /** * Constructs a compound snap to helper which will delegate to the provided * array of helpers. The first helper in the array has highest priority and * will be given the first opportunity to perform snapping. * * @since 3.0 * @param delegates * an array of helpers */ public CompoundSnapToHelper(SnapToHelper delegates[]) { Assert.isTrue(delegates.length != 0); this.delegates = delegates; } /** * Gets the array of helpers. * * @return the array of helpers. * @since 3.4 */ protected SnapToHelper[] getDelegates() { return delegates; } /** * @see SnapToHelper#snapRectangle(Request, int, PrecisionRectangle, * PrecisionRectangle) */ public int snapRectangle(Request request, int snapOrientation, PrecisionRectangle baseRect, PrecisionRectangle result) { for (int i = 0; i < getDelegates().length && snapOrientation != NONE; i++) snapOrientation = getDelegates()[i].snapRectangle(request, snapOrientation, baseRect, result); return snapOrientation; } } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/ConnectionEditPart.java000066400000000000000000000071401166301720600270250ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; /** * A specialization of {@link GraphicalEditPart GraphicalEditPart} for * representing connections. ConnectionEditParts must join a source and * target EditPart. Its Figure is typically a line between two "nodes", * with possible decorations on that line. *

    * In GEF, ConnectionEditParts are structural features of their * source and target "nodes", which are EditParts. However, the model does not * have this requirement. The application may store the connection model in any * way, or there may even be no real model. The burden is on the source and * target EditPart to obtain their appropriate connections in the methods * {@link org.eclipse.gef.editparts.AbstractGraphicalEditPart#getModelSourceConnections() * getModelSourceConnections()} and * {@link org.eclipse.gef.editparts.AbstractGraphicalEditPart#getModelTargetConnections() * getModelTargetConnections()}. How this is done is application specific. *

    * Since ConnectionEditParts are features of their node EditPart, it is those * EditParts that must create and manage the connection. Creation is performed * by whichever end happens to "intialize" itself first. Therefore an end always * looks first in the * {@link org.eclipse.gef.EditPartViewer#getEditPartRegistry() EditPartRegistry} * to see if the connection was already created by the other end. *

    * ConnectionEditParts are EditParts, and therefore can have children. This is a * common way to implement labels and other selectable decorations on * connections. Similarly, a ConnectionEditPart can also be a "node", meaning it * can serve as the source or target of some other ConnectionEditPart. This * makes connection to connection possible. *

    * IMPORTANT: The need to display something as a line does not automatically * mean that a ConnectionEditPart is required. There are several situations in * which ConnectionEditParts should not be used. You should use * ConnectionEditParts in general if: *

      *
    • The connection should be selectable by the user independant of its * "nodes". *
    • The connection can be deleted, leaving the source and target intact. *
    • The connection cannot exist without a source and target. A instance of * when this is not true is assocations. Associations are * top-level object that are children of the diagram. They are probably only * valid if they have a source and target, but many applications allow you to * create things in any order. *
    */ public interface ConnectionEditPart extends GraphicalEditPart { /** * @return the EditPart at the source end of this connection. */ EditPart getSource(); /** * @return the EditPart at the target end of this connection. */ EditPart getTarget(); /** * Sets the source of this connection. * * @param source * the source of this connection */ void setSource(EditPart source); /** * Sets thetarget of this connection. * * @param target * the target of this connection */ void setTarget(EditPart target); } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/ContextMenuProvider.java000066400000000000000000000040641166301720600272570ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; /** * Extends MenuManager to allow populating the menu directly from the manager * itself. Using this class is no different than using a standalone * MenuManager, and adding a menuAboutToShow listener. * * @author hudsonr */ public abstract class ContextMenuProvider extends MenuManager implements IMenuListener { private EditPartViewer viewer; /** * Constructs a context menu for the specified EditPartViewer. * * @param viewer * the editpart viewer */ public ContextMenuProvider(EditPartViewer viewer) { setViewer(viewer); addMenuListener(this); setRemoveAllWhenShown(true); } /** * Called when the menu is about to show. Subclasses must implement this * method to populate the menu each time it is shown. * * @param menu * this parameter is actually this object */ public abstract void buildContextMenu(IMenuManager menu); /** * Returns the EditPartViewer * * @return the viewer */ protected EditPartViewer getViewer() { return viewer; } /** * @see IMenuListener#menuAboutToShow(IMenuManager) */ public void menuAboutToShow(IMenuManager menu) { buildContextMenu(menu); } /** * Sets the editpart viewer. Called during construction. * * @param viewer * the viewer */ protected void setViewer(EditPartViewer viewer) { this.viewer = viewer; } } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/DefaultEditDomain.java000066400000000000000000000036471166301720600266230ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import org.eclipse.ui.IEditorPart; /** * A default implementation of {@link EditDomain}. An {@link IEditorPart} is * required in the constructor, but it can be null. *

    * A {@link org.eclipse.gef.tools.SelectionTool} will be the active Tool until: *

      *
    • A {@link org.eclipse.gef.palette.PaletteRoot} is provided which contains * a default entry which is a {@link org.eclipse.gef.palette.ToolEntry}. In * which case that entry's tool is made the active Tool. *
    *

    * DefaultEditDomain can be configured with a * {@link org.eclipse.gef.ui.palette.PaletteViewer}. When provided, the * DefaultEditDomain will listen for PaletteEvents, and will switch the active * Tool automatically in response. */ public class DefaultEditDomain extends EditDomain { private IEditorPart editorPart; /** * Constructs a DefaultEditDomain with the specified IEditorPart * * @param editorPart * null or an IEditorPart */ public DefaultEditDomain(IEditorPart editorPart) { setEditorPart(editorPart); } /** * @return the IEditorPart for this EditDomain */ public IEditorPart getEditorPart() { return editorPart; } /** * Sets the IEditorPart for this EditDomain. * * @param editorPart * the editor */ protected void setEditorPart(IEditorPart editorPart) { this.editorPart = editorPart; } } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/Disposable.java000066400000000000000000000013431166301720600253550ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; /** * Marks objects that should be disposed of when no longer in use. */ public interface Disposable { /** * Performs and necessary cleanup. */ void dispose(); } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/DragTracker.java000066400000000000000000000026551166301720600254700ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; /** * A specialization of Tool that is used by the * {@link org.eclipse.gef.tools.SelectionTool} during a Mouse Drag. The * SelectionTool obtains a DragTracker on mouse down, * and forwards all input to that tracker until after the mouse is released. The * SelectionTool also obtains DragTrackers in keyboard accessible ways. */ public interface DragTracker extends Tool { /** * The SelectionTool supports keyboard accessible drags. In * such scenarios it is up to the SelectionTool to interpret commit * and abort keystrokes. Since the DragTracker cannot do this, this * method is used to indicate that the User has committed the drag using the * keyboard. Abort is not handled specially, and the DragTracker should * peform the usual cleanup in its {@link Tool#deactivate()} method. */ void commitDrag(); } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/EditDomain.java000066400000000000000000000307041166301720600253100ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import java.util.ArrayList; import java.util.List; import org.eclipse.swt.dnd.DragSourceEvent; import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.TraverseEvent; import org.eclipse.swt.widgets.Event; import org.eclipse.gef.commands.CommandStack; import org.eclipse.gef.palette.PaletteListener; import org.eclipse.gef.palette.PaletteRoot; import org.eclipse.gef.palette.ToolEntry; import org.eclipse.gef.tools.SelectionTool; import org.eclipse.gef.ui.palette.PaletteViewer; /** * The collective state of a GEF "application", loosely defined by a * CommandStack, one or more EditPartViewers, and the active Tool. An EditDomain * is usually tied with an Eclipse {@link org.eclipse.ui.IEditorPart * IEditorPart}). However, the distinction between EditorPart and EditDomain was * made to allow for much flexible use of the Graphical Editing Framework. */ public class EditDomain { private Tool defaultTool; private PaletteViewer paletteViewer; private PaletteRoot paletteRoot; private Tool activeTool; private List viewers = new ArrayList(); private CommandStack commandStack = new CommandStack(); /** * Listens to the PaletteViewer for changes in selection, and sets the * Domain's Tool accordingly. */ private PaletteListener paletteListener = new PaletteListener() { public void activeToolChanged(PaletteViewer viewer, ToolEntry tool) { handlePaletteToolChanged(); } }; /** * Constructs an EditDomain and loads the default tool. */ public EditDomain() { loadDefaultTool(); } /** * Adds an EditPartViewer into the EditDomain. A viewer is most likely * placed in a {@link org.eclipse.ui.IWorkbenchPart WorkbenchPart} of some * form, such as the IEditorPart or an IViewPart. * * @param viewer * The EditPartViewer */ public void addViewer(EditPartViewer viewer) { viewer.setEditDomain(this); if (!viewers.contains(viewer)) viewers.add(viewer); } /** * Called when one of the EditDomain's Viewers receives keyboard focus. * * @param event * The SWT focus event * @param viewer * the Viewer that received the event. */ public void focusGained(FocusEvent event, EditPartViewer viewer) { Tool tool = getActiveTool(); if (tool != null) tool.focusGained(event, viewer); } /** * Called when one of the EditDomain's Viewers is losing keyboard focus. * * @param event * The SWT focus event * @param viewer * the Viewer that received the event. */ public void focusLost(FocusEvent event, EditPartViewer viewer) { Tool tool = getActiveTool(); if (tool != null) tool.focusLost(event, viewer); } /** * Returns the active Tool * * @return the active Tool */ public Tool getActiveTool() { return activeTool; } /** * Returns the CommandStack. Command stacks could potentially be shared * across domains depending on the application. * * @return The command stack */ public CommandStack getCommandStack() { return commandStack; } /** * Returns the default tool for this edit domain. This will be a * {@link org.eclipse.gef.tools.SelectionTool} unless specifically replaced * using {@link #setDefaultTool(Tool)}. * * @return The default Tool for this domain */ public Tool getDefaultTool() { if (defaultTool == null) defaultTool = new SelectionTool(); return defaultTool; } /** * Returns the palette viewer currently associated with this domain. * * @since 1.0 * @return The current palette viewer */ public PaletteViewer getPaletteViewer() { return paletteViewer; } private void handlePaletteToolChanged() { PaletteViewer paletteViewer = getPaletteViewer(); if (paletteViewer != null) { ToolEntry entry = paletteViewer.getActiveTool(); if (entry != null) setActiveTool(entry.createTool()); else setActiveTool(getDefaultTool()); } } /** * Called when a key is pressed on a Viewer. * * @param keyEvent * The SWT key event * @param viewer * The source of the event. */ public void keyDown(KeyEvent keyEvent, EditPartViewer viewer) { Tool tool = getActiveTool(); if (tool != null) tool.keyDown(keyEvent, viewer); } /** * Called when a traversal occurs on a viewer. * * @param traverseEvent * the SWT traverse event * @param viewer * the source of the event * @since 3.1 */ public void keyTraversed(TraverseEvent traverseEvent, EditPartViewer viewer) { Tool tool = getActiveTool(); if (tool != null) tool.keyTraversed(traverseEvent, viewer); } /** * Called when a key is released on a Viewer. * * @param keyEvent * The SWT key event * @param viewer * the source of the event. */ public void keyUp(KeyEvent keyEvent, EditPartViewer viewer) { Tool tool = getActiveTool(); if (tool != null) tool.keyUp(keyEvent, viewer); } /** * Loads the default Tool. If a palette has been provided and that palette * has a default, then that tool is loaded. If not, the EditDomain's default * tool is loaded. By default, this is the * {@link org.eclipse.gef.tools.SelectionTool}. */ public void loadDefaultTool() { setActiveTool(null); PaletteViewer paletteViewer = getPaletteViewer(); if (paletteRoot != null && paletteViewer != null) { if (paletteRoot.getDefaultEntry() != null) { paletteViewer.setActiveTool(paletteRoot.getDefaultEntry()); return; } else paletteViewer.setActiveTool(null); } setActiveTool(getDefaultTool()); } /** * Called when the mouse button has been double-clicked on a Viewer. * * @param mouseEvent * The SWT mouse event * @param viewer * The source of the event. */ public void mouseDoubleClick(MouseEvent mouseEvent, EditPartViewer viewer) { Tool tool = getActiveTool(); if (tool != null) tool.mouseDoubleClick(mouseEvent, viewer); } /** * Called when the mouse button has been pressed on a Viewer. * * @param mouseEvent * The SWT mouse event * @param viewer * The source of the event. */ public void mouseDown(MouseEvent mouseEvent, EditPartViewer viewer) { Tool tool = getActiveTool(); if (tool != null) tool.mouseDown(mouseEvent, viewer); } /** * Called when the mouse has been dragged within a Viewer. * * @param mouseEvent * The SWT mouse event * @param viewer * The source of the event. */ public void mouseDrag(MouseEvent mouseEvent, EditPartViewer viewer) { Tool tool = getActiveTool(); if (tool != null) tool.mouseDrag(mouseEvent, viewer); } /** * Called when the mouse has hovered on a Viewer. * * @param mouseEvent * The SWT mouse event * @param viewer * The source of the event. */ public void mouseHover(MouseEvent mouseEvent, EditPartViewer viewer) { Tool tool = getActiveTool(); if (tool != null) tool.mouseHover(mouseEvent, viewer); } /** * Called when the mouse has been moved on a Viewer. * * @param mouseEvent * The SWT mouse event * @param viewer * The viewer that the mouse event is over. */ public void mouseMove(MouseEvent mouseEvent, EditPartViewer viewer) { Tool tool = getActiveTool(); if (tool != null) tool.mouseMove(mouseEvent, viewer); } /** * Called when the mouse button has been released on a Viewer. * * @param mouseEvent * The SWT mouse event * @param viewer * The source of the event. */ public void mouseUp(MouseEvent mouseEvent, EditPartViewer viewer) { Tool tool = getActiveTool(); if (tool != null) tool.mouseUp(mouseEvent, viewer); } /** * Called by the DomainEventDispatcher when the mouse wheel has been * scrolled. * * @param event * The SWT event * @param viewer * The source of the event */ public void mouseWheelScrolled(Event event, EditPartViewer viewer) { Tool tool = getActiveTool(); if (tool != null) tool.mouseWheelScrolled(event, viewer); } /** * Called when a native drag has finished on a Viewer. * * @param event * The DragSourceEvent * @param viewer * The viewer where the drag finished */ public void nativeDragFinished(DragSourceEvent event, EditPartViewer viewer) { Tool tool = getActiveTool(); if (tool != null) tool.nativeDragFinished(event, viewer); } /** * Called when a native drag has started on a Viewer. * * @param event * The DragSourceEvent * @param viewer * The viewer where the drag started */ public void nativeDragStarted(DragSourceEvent event, EditPartViewer viewer) { Tool tool = getActiveTool(); if (tool != null) tool.nativeDragStarted(event, viewer); } /** * Removes a previously added viewer from the EditDomain. A Viewer that is * removed from the EditDomain will no longer forward input to the domain * and its active Tool. * * @param viewer * the Viewer being removed */ public void removeViewer(EditPartViewer viewer) { if (viewers.remove(viewer)) viewer.setEditDomain(null); } /** * Sets the CommandStack. * * @param stack * the CommandStack */ public void setCommandStack(CommandStack stack) { commandStack = stack; } /** * Sets the default Tool, which is used if the Palette does not provide a * default * * @param tool * null or a Tool */ public void setDefaultTool(Tool tool) { defaultTool = tool; } /** * Sets the PalatteRoot for this EditDomain. If the EditDomain already knows * about a PaletteViewer, this root will be set into the palette viewer * also. Loads the default Tool after the root has been set. *

    * It is recommended that the palette root not be set multiple times. Some * components (such as the PaletteCustomizerDialog for the PaletteViewer) * might still hold on to the old root. If the input has changed or needs to * be refreshed, just remove all the children from the root and add the new * ones. * * @param root * the palette's root */ public void setPaletteRoot(PaletteRoot root) { if (paletteRoot == root) return; paletteRoot = root; if (getPaletteViewer() != null) { getPaletteViewer().setPaletteRoot(paletteRoot); loadDefaultTool(); } } /** * Sets the PaletteViewer for this EditDomain * * @param palette * the PaletteViewer */ public void setPaletteViewer(PaletteViewer palette) { if (palette == paletteViewer) return; if (paletteViewer != null) paletteViewer.removePaletteListener(paletteListener); paletteViewer = palette; if (paletteViewer != null) { palette.addPaletteListener(paletteListener); if (paletteRoot != null) { paletteViewer.setPaletteRoot(paletteRoot); loadDefaultTool(); } } } /** * Sets the active Tool for this EditDomain. If a current Tool is active, it * is deactivated. The new Tool is told its EditDomain, and is activated. * * @param tool * the Tool */ public void setActiveTool(Tool tool) { if (activeTool != null) activeTool.deactivate(); activeTool = tool; if (activeTool != null) { activeTool.setEditDomain(this); activeTool.activate(); } } /** * Called when the mouse enters a Viewer. * * @param mouseEvent * the SWT mouse event * @param viewer * the Viewer being entered */ public void viewerEntered(MouseEvent mouseEvent, EditPartViewer viewer) { Tool tool = getActiveTool(); if (tool != null) tool.viewerEntered(mouseEvent, viewer); } /** * Called when the mouse exits a Viewer. * * @param mouseEvent * the SWT mouse event * @param viewer * the Viewer being exited */ public void viewerExited(MouseEvent mouseEvent, EditPartViewer viewer) { Tool tool = getActiveTool(); if (tool != null) tool.viewerExited(mouseEvent, viewer); } } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/EditPart.java000066400000000000000000000355361166301720600250170ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import java.util.List; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.gef.commands.Command; /** * EditParts are the building blocks of GEF Viewers. As the Controller, * an EditPart ties the application's model to a visual representation. * EditParts are responsible for making changes to the model. EditParts * typically control a single model object or a coupled set of object. Visual * representations include {@link org.eclipse.draw2d.IFigure Figures} and * {@link org.eclipse.swt.widgets.TreeItem TreeItems}. Model objects are often * composed of other objects that the User will interact with. Similarly, * EditParts can be composed of or have references to other EditParts. *

    * The creator of an EditPart should call only setModel(Object). The remaining * API is used mostly by Tools, EditPolicies, and other EditParts. CHANGES are * made to the model, not the EditPart. *

    * Most interaction with EditParts is achieved using {@link Request Requests}. A * Request specifies the type of interaction. Requests are used in * {@link #getTargetEditPart(Request) targeting}, filtering the selection (using * {@link #understandsRequest(Request)}), graphical * {@link #showSourceFeedback(Request)} feedback, and most importantly, * {@link #getCommand(Request) obtaining} commands. Only {@link Command * Commands} should change the model. *

    * IMPORTANT: This interface is not intended to be implemented by * clients. Clients should inherit from * {@link org.eclipse.gef.editparts.AbstractEditPart}. New methods may be added * in the future. */ public interface EditPart extends IAdaptable { /** * Used to indicate no selection */ int SELECTED_NONE = 0; /** * Used to indicate non-primary selection */ int SELECTED = 1; /** * Used to indicate primary selection, or "Anchor" selection. Primary * selection is defined as the last object selected. */ int SELECTED_PRIMARY = 2; /** * Activates the EditPart. EditParts that observe a dynamic model or support * editing must be active. Called by the managing EditPart, or the * Viewer in the case of the {@link RootEditPart}. This method may be called * again once {@link #deactivate()} has been called. *

    * During activation the receiver should: *

      *
    • begin to observe its model if appropriate, and should continue the * observation until {@link #deactivate()} is called. *
    • activate all of its EditPolicies. EditPolicies may also observe the * model, although this is rare. But it is common for EditPolicies to * contribute additional visuals, such as selection handles or feedback * during interactions. Therefore it is necessary to tell the EditPolicies * when to start doing this, and when to stop. *
    • call activate() on the EditParts it manages. This includes its * children, and for GraphicalEditParts, its source connections. *
    */ void activate(); /** * Adds a listener to the EditPart. Duplicate calls result in duplicate * notification. * * @param listener * the Listener */ void addEditPartListener(EditPartListener listener); /** * Called after the EditPart has been added to its parent. This is * used to indicate to the EditPart that it should refresh itself for the * first time. */ void addNotify(); /** * Deactivates the EditPart. EditParts that observe a dynamic model or * support editing must be active. deactivate() is * guaranteed to be called when an EditPart will no longer be used. Called * by the managing EditPart, or the Viewer in the case of the * {@link RootEditPart}. This method may be called multiple times. *

    * During deactivation the receiver should: *

      *
    • remove all listeners that were added in {@link #activate} *
    • deactivate all of its EditPolicies. EditPolicies may be contributing * additional visuals, such as selection handles or feedback during * interactions. Therefore it is necessary to tell the EditPolicies when to * start doing this, and when to stop. *
    • call deactivate() on the EditParts it manages. This includes its * children, and for GraphicalEditParts, its source * connections. *
    */ void deactivate(); /** * Erases source feedback for the specified {@link Request}. A * Request is used to describe the type of source feedback that should be * erased. This method should only be called once to erase feedback. It * should only be called in conjunction with a prior call to * {@link #showSourceFeedback(Request)}. * * @param request * the type of feedback that is being erased */ void eraseSourceFeedback(Request request); /** * Erases target feedback for the specified {@link Request}. A * Request is used to describe the type of target feedback that should be * erased. This method should only be called once to erase feedback. It * should only be called in conjunction with a prior call to * {@link #showTargetFeedback(Request)}. * * @param request * the type of feedback that is being erased */ void eraseTargetFeedback(Request request); /** * Returns the List of children EditParts. This method should * rarely be called, and is only made public so that helper objects of this * EditPart, such as EditPolicies, can obtain the children. The returned * List may be by reference, and should never be modified. * * @return a List of children */ List getChildren(); /** * Returns the {@link Command} to perform the specified Request or * null. * * @param request * describes the Command being requested * @return null or a Command */ Command getCommand(Request request); /** * Returns a {@link DragTracker} for dragging this EditPart. The * {@link org.eclipse.gef.tools.SelectionTool SelectionTool} is the only * Tool by default that calls this method. The SelectionTool will use a * {@link org.eclipse.gef.requests.SelectionRequest} to provide information * such as which mouse button is down, and what modifier keys are pressed. * * @param request * a Request indicating the context of the drag * @return null or a DragTracker */ DragTracker getDragTracker(Request request); /** * @param key * the key identifying the EditPolicy * @return null or the EditPolicy installed with the given key */ EditPolicy getEditPolicy(Object key); /** * Returns the primary model object that this EditPart represents. EditParts * may correspond to more than one model object, or even no model object. In * practice, the Object returned is used by other EditParts to identify this * EditPart. In addition, EditPolicies probably rely on this method to build * Commands that operate on the model. * * @return null or the primary model object */ Object getModel(); /** * Returns the parent EditPart. This method should only be * called internally or by helpers such as EditPolicies. * * @return null or the parent {@link EditPart} */ EditPart getParent(); /** * Returns the {@link RootEditPart}. This method should only be called * internally or by helpers such as edit policies. The root can be used to * get the viewer. * * @return null or the {@link RootEditPart} */ RootEditPart getRoot(); /** * Returns the selected state of this EditPart. This method should only be * called internally or by helpers such as EditPolicies. * * @return one of: *
      *
    • {@link #SELECTED} *
    • {@link #SELECTED_NONE} *
    • {@link #SELECTED_PRIMARY} *
    */ int getSelected(); /** * Return the EditPart that should be used as the target * for the specified Request. Tools will generally call this * method with the mouse location so that the receiver can implement drop * targeting. Typically, if this EditPart is not the requested target (for * example, this EditPart is not a composite), it will forward the call to * its parent. * * @param request * the type of target being requested * @return null or the target */ EditPart getTargetEditPart(Request request); /** * Convenience method for returning the EditPartViewer for this * part. * * @return the {@link EditPartViewer} or null */ EditPartViewer getViewer(); /** * Returns true if this EditPart has focus. The focus EditPart is a * property of the EditPartViewer. The Viewer keeps this property in sync * with its focus. * * @see EditPartViewer#getFocusEditPart() * @return true if the EditPart has focus */ boolean hasFocus(); /** * Installs an EditPolicy for a specified role. A role is is * simply an Object used to identify the EditPolicy. An example of a role is * layout. {@link EditPolicy#LAYOUT_ROLE} is generally used as the key for * this EditPolicy. null is a valid value for reserving a * location. * * @param role * an identifier used to key the EditPolicy * @param editPolicy * the EditPolicy */ void installEditPolicy(Object role, EditPolicy editPolicy); /** * returns true if the EditPart is active. Editparts are active * after {@link #activate()} is called, and until {@link #deactivate()} is * called. * * @return true when active */ boolean isActive(); /** * Returns true if the EditPart is selectable. A selectable * EditPart may be selected as a result of the * {@link org.eclipse.gef.tools.SelectionTool} receiving a mouse down, or as * a result of the User pressing a key to change selection. * * @return true if the receiver can be selected */ boolean isSelectable(); /** * Performs the specified Request. This method can be used to send a generic * message to an EditPart. If the EditPart interprets this request to mean * make a change in the model, it should still use Commands and * the CommandStack so that the change is undoable. The * CommandStack is available from the EditDomain. * * @param request * the request to be performed */ void performRequest(Request request); /** * Called to force a refresh of this EditPart. All visuals properties will * be updated, as well as structural features like children. */ void refresh(); /** * Removes the first occurance of the specified listener from the list of * listeners. Does nothing if the listener was not present. * * @param listener * the listener being removed */ void removeEditPartListener(EditPartListener listener); /** * Removes the EditPolicy for the given role. The EditPolicy is * deactivated if it is active. The position for that role is maintained * with null in the place of the old EditPolicy. * * @param role * the key identifying the EditPolicy to be removed * @see #installEditPolicy(Object, EditPolicy) */ void removeEditPolicy(Object role); /** * Called when the EditPart is being permanently removed from its * {@link EditPartViewer}. This indicates that the EditPart will no longer * be in the Viewer, and therefore should remove itself from the Viewer. * This method is not called when a Viewer is disposed. It is only * called when the EditPart is removed from its parent. This method is the * inverse of {@link #addNotify()} */ void removeNotify(); /** * Set the focus property to reflect the value in the EditPartViewer. * Focus is determined by the EditPartViewer. *

    * Focus is considered to be part of the selected state, changing * this value will fire * {@link EditPartListener#selectedStateChanged(EditPart)}. *

    * IMPORTANT: This method should only be called by the EditPartViewer. * * @param hasFocus * boolean indicating if this part has focus */ void setFocus(boolean hasFocus); /** * Sets the model. This method is made * public to facilitate the use of {@link EditPartFactory EditPartFactories} * . * *

    * IMPORTANT: This method should only be called once. * * @param model * the Model */ void setModel(Object model); /** * Sets the parent. This should only be * called by the parent EditPart. * * @param parent * the parent EditPart */ void setParent(EditPart parent); /** * Sets the selected state property to * reflect the selection in the EditPartViewer. Fires * selectedStateChanged(EditPart) to any EditPartListeners. Selection is * maintained by the EditPartViewer. *

    * IMPORTANT: This method should only be called by the EditPartViewer. * * @param value * an enum indicating the selected state * @see #getSelected() */ void setSelected(int value); /** * Shows or updates source feedback for the given request. This method may * be called multiple times so that the feedback can be updated for changes * in the request, such as the mouse location changing. * * @param request * request describing the type of feedback */ void showSourceFeedback(Request request); /** * Shows or updates target feedback for the given request. This method can * be called multiple times so that the feedback can be updated for changes * in the request, such as the mouse location changing. * * @param request * request describing the type of feedback */ void showTargetFeedback(Request request); /** * Used to filter EditParts out of the current selection. If an * operation is going to be performed on the current selection, the * selection can first be culled to remove EditParts that do not participate * in the operation. For example, when aligning the left edges of * GraphicalEditParts, it makes sense to ignore any selected * ConnectionEditParts, as they cannot be aligned. * * @param request * a Request describing an operation of some type * @return true if Request is understood */ boolean understandsRequest(Request request); } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/EditPartFactory.java000066400000000000000000000025521166301720600263370ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; /** * A factory for creating new EditParts. {@link EditPartViewer EditPartViewers} * can be configured with an EditPartFactory. Whenever an * EditPart in that viewer needs to create another EditPart, it can * use the Viewer's factory. The factory is also used by the viewer whenever * {@link EditPartViewer#setContents(Object)} is called. * * @since 2.0 */ public interface EditPartFactory { /** * Creates a new EditPart given the specified context and * model. * * @param context * The context in which the EditPart is being created, such as * its parent. * @param model * the model of the EditPart being created * @return EditPart the new EditPart */ EditPart createEditPart(EditPart context, Object model); } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/EditPartListener.java000066400000000000000000000054631166301720600265210ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; /** * The listener interface for receiving basic events from an EditPart. Listeners * interested in only one type of Event can extend the * {@link EditPartListener.Stub} implementation rather than implementing the * entire interface. */ public interface EditPartListener { /** * Listeners interested in just a subset of Events can extend this stub * implementation. Also, extending the Stub will reduce the impact of new * API on this interface. */ public class Stub implements EditPartListener { /** * @see org.eclipse.gef.EditPartListener#childAdded(EditPart, int) */ public void childAdded(EditPart child, int index) { } /** * @see org.eclipse.gef.EditPartListener#partActivated(EditPart) */ public void partActivated(EditPart editpart) { } /** * @see org.eclipse.gef.EditPartListener#partDeactivated(EditPart) */ public void partDeactivated(EditPart editpart) { } /** * @see org.eclipse.gef.EditPartListener#removingChild(EditPart, int) */ public void removingChild(EditPart child, int index) { } /** * @see org.eclipse.gef.EditPartListener#selectedStateChanged(EditPart) */ public void selectedStateChanged(EditPart part) { } }; /** * Called after a child EditPart has been added to its parent. * * @param child * the Child * @param index * the index at which the child was added */ void childAdded(EditPart child, int index); /** * Called when the editpart has been activated. * * @param editpart * the EditPart */ void partActivated(EditPart editpart); /** * Called when the editpart has been deactivated. * * @param editpart * the EditPart */ void partDeactivated(EditPart editpart); /** * Called before a child EditPart is removed from its parent. * * @param child * the Child being removed * @param index * the child's current location */ void removingChild(EditPart child, int index); /** * Called when the selected state of an EditPart has changed. Focus changes * also result in this method being called. * * @param editpart * the part whose selection was changed * @see EditPart#getSelected() */ void selectedStateChanged(EditPart editpart); } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/EditPartViewer.java000066400000000000000000000527431166301720600262000ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import java.beans.PropertyChangeListener; import java.util.Collection; import java.util.List; import java.util.Map; import org.eclipse.swt.graphics.Cursor; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.resource.ResourceManager; import org.eclipse.jface.util.TransferDragSourceListener; import org.eclipse.jface.util.TransferDropTargetListener; import org.eclipse.jface.viewers.ISelection; import org.eclipse.draw2d.geometry.Point; /** * An adapter on an SWT {@link org.eclipse.swt.widgets.Control} that manages the * {@link org.eclipse.gef.EditPart EditParts}. The viewer is responsible for the * editpart lifecycle. Editparts have visuals, such as * TreeItems or Figures, which are hosted by the * viewer and its control. The viewer provides targeting of editparts via their * visuals. * *

    * A viewer is a {@link org.eclipse.jface.viewers.ISelectionProvider}. It * maintains a list of selected editparts. The last member of this list is the * primary member of the selection. The list should never be empty; when * no editparts are selected, the viewer's contents editpart is used. * *

    * A viewer is populated by setting its contents. This can be done by * passing the model corresponding to the contents. The viewer's * {@link org.eclipse.gef.EditPartFactory EditPartFactory} is then used to * create the contents editpart, and add it to the root editpart. * Alternatively, the contents editpart itself can be provided. Once the * contents editpart is parented, it will populate the rest of the viewer by * calling its {@link EditPart#refresh()} method. * *

    * The Root editpart does not correspond to anything in the model, it is used to * bootstrap the viewer, and to parent the contents. Depending on the type of * viewer being used, it may be common to replace the root editpart. See * implementations of {@link org.eclipse.gef.RootEditPart}. * *

    * An editpart's lifecycle is managed by the viewer. When the Viewer is * realized, meaning it has an SWT Control, it activates its root, * which in turn activates all editparts. Editparts are deactivated when they * are removed from the viewer. When the viewer's control is disposed, all * editparts are similarly deactivated by decativating the root. * *

    * A Viewer has an arbitrary collection of keyed properties that can be set and * queried. A value of null is used to remove a key from the * property map. A viewer will fire property change notification whenever these * values are updated. * *

    * WARNING: This interface is not intended to be implemented. Clients should * extend {@link org.eclipse.gef.ui.parts.AbstractEditPartViewer}. */ public interface EditPartViewer extends org.eclipse.jface.viewers.ISelectionProvider { /** * An object which evaluates an EditPart for an arbitrary property. * Conditionals are used when querying a viewer for an editpart. * * @author hudsonr */ interface Conditional { /** * Returns true if the editpart meets this condition. * * @param editpart * the editpart being evaluated * @return true if the editpart meets the condition */ boolean evaluate(EditPart editpart); } /** * Provided for compatibility with existing code. * * @param listener * a drag source listener * @see #addDragSourceListener(TransferDragSourceListener) */ void addDragSourceListener( org.eclipse.gef.dnd.TransferDragSourceListener listener); /** * Adds a TransferDragSourceListener to this viewer. This has * the side-effect of creating a {@link org.eclipse.swt.dnd.DragSource} on * the viewer's Control. A Control can only have a single DragSource. * Clients must not create their own DragSource when using this method. * * @param listener * the listener */ void addDragSourceListener(TransferDragSourceListener listener); /** * Provided for compatibility with existing code. * * @param listener * the listener * @see #addDropTargetListener(TransferDropTargetListener) */ void addDropTargetListener( org.eclipse.gef.dnd.TransferDropTargetListener listener); /** * Adds a TransferDropTargetListener to this viewer. This has * the side-effect of creating a {@link org.eclipse.swt.dnd.DropTarget} on * the viewer's Control. A Control can only have a single DropTarget. * Clients must not create their own DropTarget when using this method. * * @param listener * the listener */ void addDropTargetListener(TransferDropTargetListener listener); /** * Adds a listener to be notified of viewer property changes. * * @param listener * the listener */ void addPropertyChangeListener(PropertyChangeListener listener); /** * Appends the specified EditPart to the viewer's * selection. The EditPart becomes the new primary selection. Fires * selection changed to all * {@link org.eclipse.jface.viewers.ISelectionChangedListener}s. * * @param editpart * the EditPart to append */ void appendSelection(EditPart editpart); /** * Optionally creates the default {@link org.eclipse.swt.widgets.Control * Control} using the default style. The Control can also be created * externally and then set into the Viewer. * * @param composite * the parent in which create the SWT Control * @see #setControl(Control) * @return the created Control for convenience */ Control createControl(Composite composite); /** * Removes the specified EditPart from the current selection. * If the selection becomes empty, the viewer's {@link #getContents() * contents} becomes the current selected part. The last EditPart in the new * selection is made {@link EditPart#SELECTED_PRIMARY primary}. *

    * Fires selection changed to * {@link org.eclipse.jface.viewers.ISelectionChangedListener}s. * * @param editpart * the EditPart to deselect */ void deselect(EditPart editpart); /** * Deselects all EditParts. The viewer's {@link #getContents() contents} * becomes the current selection. Fires selection changed to * {@link org.eclipse.jface.viewers.ISelectionChangedListener}s. */ void deselectAll(); /** * Returns null or the EditPart associated with * the specified location. The location is relative to the client area of * the Viewer's Control. An EditPart is not directly visible. * It is targeted using its visual part which it registered using the * {@link #getVisualPartMap() visual part map}. What constitutes a visual * part is viewer-specific. Examples include Figures and TreeItems. * * @param location * The location * @return null or an EditPart */ EditPart findObjectAt(Point location); /** * Returns null or the EditPart at the specified * location, excluding the specified set. This method behaves similarly to * {@link #findObjectAt(Point)}. * * @param location * The mouse location * @param exclusionSet * The set of EditParts to be excluded * @return null or an EditPart */ EditPart findObjectAtExcluding(Point location, Collection exclusionSet); /** * Returns null or the EditPart at the specified * location, using the given exclusion set and conditional. This method * behaves similarly to {@link #findObjectAt(Point)}. * * @param location * The mouse location * @param exclusionSet * The set of EditParts to be excluded * @param conditional * the Conditional used to evaluate a potential hit * @return null or an EditPart */ EditPart findObjectAtExcluding(Point location, Collection exclusionSet, Conditional conditional); /** * Flushes all pending updates to the Viewer. */ void flush(); /** * Returns the contents of this Viewer. The contents is the EditPart * associated with the top-level model object. It is considered to be * "The Diagram". If the user has nothing selected, the contents is * implicitly the selected object. *

    * The Root of the Viewer is different. By constrast, the root is * never selected or targeted, and does not correspond to something in the * model. * * @see #getRootEditPart() * @return the contents EditPart */ EditPart getContents(); /** * Returns null or the MenuManager for this viewer. The menu * manager is set using {@link #setContextMenu(MenuManager)}. * * @return null or a MenuManager */ MenuManager getContextMenu(); /** * Returns null or the SWT Control for this * viewer. The control is either set explicitly or can be created by the * viewer. * * @see #setControl(Control) * @see #createControl(Composite) * @return the SWT Control */ Control getControl(); /** * Returns the {@link EditDomain EditDomain} to which this viewer belongs. * * @return the viewer's EditDomain */ EditDomain getEditDomain(); /** * Returns the EditPartFactory for this viewer. The * EditPartFactory is used to create the contents EditPart when * {@link #setContents(Object)} is called. It is made available so that * other EditParts can use it to create their children or connection * editparts. * * @return EditPartFactory */ EditPartFactory getEditPartFactory(); /** * Returns the {@link Map} for registering EditParts by * Keys. EditParts may register themselves using any method, and may * register themselves with multiple keys. The purpose of such registration * is to allow an EditPart to be found by other EditParts, or by listeners * of domain notifiers. By default, EditParts are registered by their model. *

    * Some models use a "domain" notification system, in which all changes are * dispatched to a single listener. Such a listener might use this map to * lookup editparts for a given model, and then ask the editpart to update. * * @return the registry map */ Map getEditPartRegistry(); /** * Returns the focus EditPart. Focus refers to keyboard * focus. This is the same concept as focus in a native Tree or Table. The * User can change focus using the keyboard without affecting the currently * selected objects. Never returns null. * * @return the focus EditPart */ EditPart getFocusEditPart(); /** * Returns the KeyHandler for this viewer. The KeyHandler is * sent KeyEvents by the currently active Tool. This is * important, because only the current tool knows if it is in a state in * which keys should be ignored, such as during a drag. By default, only the * {@link org.eclipse.gef.tools.SelectionTool} forwards keysrokes. It does * not do so during a drag. * * @return null or a KeyHandler */ KeyHandler getKeyHandler(); /** * Returns the value of the given property. Returns null if the * property has not been set, or has been set to null. * * @param key * the property's key * @return the given properties value or null. */ Object getProperty(String key); /** * Returns null, or the ResourceManager for this Viewer. Once a * viewer has a Control, clients may access the viewer's resource manager. * Any resources constructed using this manager, but not freed, will be * freed when the viewer's control is disposed. This does not mean that * clients should be lazy about deallocating resources. If a resource is no * longer needed but the viewer is still in use, the client must deallocate * the resource. *

    * Typical usage is by EditParts contained inside the viewer. EditParts * which are removed from the viewer should free their resources during * {@link EditPart#removeNotify()}. When the viewer is disposed, * removeNotify() is not called, but the viewer's resource * manager will be disposed anyway. *

    * The viewer's default resource manager is linked to JFace's * {@link JFaceResources#getResources() global shared resources}. * * @return the ResourceManager associated with this viewer * @since 3.3 */ ResourceManager getResourceManager(); /** * Returns the RootEditPart. The RootEditPart is a special * EditPart that serves as the parent to the contents editpart. The * root is never selected. The root does not correspond to anything * in the model. The User does not interact with the root. *

    * The RootEditPart has a single child: the {@link #getContents() contents}. *

    * By defining the concept of "root", GEF allows the application's "real" * EditParts to be more homogeneous. For example, all non-root EditParts * have a parent. Also, it allows applications to change the type of root * being used without affecting their own editpart implementation hierarchy. * * @see #getContents() * @see #setRootEditPart(RootEditPart) * @return the RootEditPart */ RootEditPart getRootEditPart(); /** * Returns an unmodifiable List containing zero or more * selected editparts. This list may be empty. In contrast, the inherited * method * {@link org.eclipse.jface.viewers.ISelectionProvider#getSelection()} * should not return an empty selection. When no editparts are selected, * generally the contents editpart is considered to be selected. This list * can be modified indirectly by calling other methods on the viewer. * * @return a list containing zero or more editparts */ List getSelectedEditParts(); /** * This method is inherited from * {@link org.eclipse.jface.viewers.ISelectionProvider ISelectionProvider}. * This method should return a * {@link org.eclipse.jface.viewers.StructuredSelection} containing one or * more of the viewer's EditParts. If no editparts are selected, the * {@link #getContents() contents} editpart is returned. * * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection() */ ISelection getSelection(); /** * Returns the viewer's selection manager. The selection manager has * complete control over the viewer's representation of selection. It * provides the {@link ISelection} for the viewer, and manages all changes * to the current selection. * * @return the selection manager * @since 3.2 */ SelectionManager getSelectionManager(); /** * Returns the {@link Map} for associating visual parts with their * EditParts. This map is used for hit-testing. Hit testing is * performed by first determining which visual part is hit, and then mapping * that part to an EditPart. What consistutes a visual * part is viewer-specific. Examples include Figures and * TreeItems. * * @return the visual part map */ Map getVisualPartMap(); /** * Used for accessibility purposes. * * @param acc * the AccessibleEditPart */ void registerAccessibleEditPart(AccessibleEditPart acc); /** * Removes the specified drag source listener. If all listeners are removed, * the DragSource that was created will be disposed. * * @see #addDragSourceListener(TransferDragSourceListener) * @param listener * the listener * @deprecated */ void removeDragSourceListener( org.eclipse.gef.dnd.TransferDragSourceListener listener); /** * Removes the specified drag source listener. If all listeners are removed, * the DragSource that was created will be disposed. * * @see #addDragSourceListener(TransferDragSourceListener) * @param listener * the listener */ void removeDragSourceListener(TransferDragSourceListener listener); /** * Removes the specified drop target listener. If all listeners are removed, * the DropTarget that was created will be disposed. * * @see #addDropTargetListener(TransferDropTargetListener) * @param listener * @deprecated */ void removeDropTargetListener( org.eclipse.gef.dnd.TransferDropTargetListener listener); /** * Removes the specified drop target listener. If all listeners are removed, * the DropTarget that was created will be disposed. * * @see #addDropTargetListener(TransferDropTargetListener) * @param listener * the listener */ void removeDropTargetListener(TransferDropTargetListener listener); /** * removes the first instance of the specified property listener. * * @param listener * the listener to remove */ void removePropertyChangeListener(PropertyChangeListener listener); /** * Reveals the given EditPart if it is not visible. * * @param editpart * the EditPart to reveal */ void reveal(EditPart editpart); /** * Replaces the current selection with the specified EditPart. * That part becomes the primary selection. Fires selection changed to * {@link org.eclipse.jface.viewers.ISelectionChangedListener}s. * * @param editpart * the new selection */ void select(EditPart editpart); /** * Sets the contents for this Viewer. The contents can also be set using * {@link #setContents(Object)}. * * @param editpart * the contents * @see #getRootEditPart() */ void setContents(EditPart editpart); /** * Creates an EditPart for the provided model object using the * EditPartFactory. That EditPart is then added to the * {@link #getRootEditPart() RootEditPart}, and becomes the viewer's * contents editpart. * * @param contents * the contents model object */ void setContents(Object contents); /** * Sets the context MenuManager for this viewer. The * MenuManager will be asked to create a Menu, which will be used as the * context menu for this viewer's Control. * * @param contextMenu * the ContextMenuProvider */ void setContextMenu(MenuManager contextMenu); /** * Sets the Control for this viewer. The viewer's control is * also set automatically if {@link #createControl(Composite)} is called. * * @param control * the Control */ void setControl(Control control); /** * Sets the cursor for the viewer's Control. This method should * only be called by {@link Tool Tools}. null can be used to * indicate that the default cursor should be restored. * * @param cursor * null or a Cursor * @see #getControl() */ void setCursor(Cursor cursor); /** * Sets the EditDomain for this viewer. The Viewer will route * all mouse and keyboard events to the EditDomain. * * @param domain * The EditDomain */ void setEditDomain(EditDomain domain); /** * Sets the EditPartFactory. * * @param factory * the factory * @see #getEditPartFactory() */ void setEditPartFactory(EditPartFactory factory); /** * Sets the focus EditPart. * * @see #getFocusEditPart() * @param focus * the FocusPart. */ void setFocus(EditPart focus); /** * Sets the KeyHandler. * * @param keyHandler * the KeyHandler * @see #getKeyHandler() */ void setKeyHandler(KeyHandler keyHandler); /** * Sets a property on this viewer. A viewer property is an arbitrary * key-value pair that can be observed via * {@link #addPropertyChangeListener(PropertyChangeListener)}. A * null value will remove the property from the viewer. * * @param propertyName * a unique string identifying the property * @param value * the properties new value or null to remove * @since 3.0 */ void setProperty(String propertyName, Object value); /** * Sets the root of this viewer. The root should not be confused with * the contents. * * @param root * the RootEditPart * @see #getRootEditPart() * @see #getContents() */ void setRootEditPart(RootEditPart root); /** * Turns on/off the routing of events directly to the Editor. If supported * by the viewer implementation, all Events should be routed to the * EditDomain rather than handled in the default way. * * @param value * true if the viewer should route events to the EditDomain */ void setRouteEventsToEditDomain(boolean value); /** * Sets the selection manager for this viewer. * * @param manager * the new selection manager * @since 3.2 */ void setSelectionManager(SelectionManager manager); /** * Used for accessibility purposes. * * @param acc * the accessible part */ void unregisterAccessibleEditPart(AccessibleEditPart acc); } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/EditPolicy.java000066400000000000000000000246201166301720600253400ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import org.eclipse.gef.commands.Command; /** * A pluggable contribution implementing a portion of an EditPart's behavior. * EditPolicies contribute to the overall editing behavior of an * EditPart. Editing behavior is defined as one or more of the following: *

      *
    • Command Creation - Returning a Command in response to * {@link #getCommand(Request)} *
    • Feedback Management - Showing/erasing source and/or target * feedback in response to Requests. *
    • Delegation/Forwarding - Collecting contributions from other * EditParts (and therefore their EditPolicies). In response to a given * Request, an EditPolicy may create a derived Request and forward * it to other EditParts. For example, during the deletion of a composite * EditPart, that composite may consult its children for contributions to the * delete command. Then, if the children have any additional work to do, they * will return additional comands to be executed. *
    *

    * EditPolicies should determine an EditPart's editing capabilities. It is * possible to implement an EditPart such that it handles all editing * responsibility. However, it is much more flexible and object-oriented to use * EditPolicies. Using policies, you can pick and choose the editing behavior * for an EditPart without being bound to its class hierarchy. Code reuse is * increased, and code management is easier. *

    * IMPORTANT: This interface is not intended to be implemented by * clients. Clients should inherit from * {@link org.eclipse.gef.editpolicies.AbstractEditPolicy}. New methods may be * added in the future. */ public interface EditPolicy { /** * The key used to install a component EditPolicy. A component * is defined as anything in the model. This EditPolicy should handle the * fundamental operations that do not fit under any other EditPolicy role. * For example, delete is a fundamental operation. Generally the component * EditPolicy knows only about the model, and can be used in any type of * EditPartViewer. */ String COMPONENT_ROLE = "ComponentEditPolicy"; //$NON-NLS-1$ /** * The key used to install a connection endpoint EditPolicy. A * connection endpoint EditPolicy is usually a * {@link org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy} subclass. * Besides rendering selection by displaying Handles at then * ends of the connection, the EditPolicy also understands how to move the * endpoints of the connection. If the endpoints are moveable, the * EditPolicy will show feedback and provide Commands to * perform the move. */ String CONNECTION_ENDPOINTS_ROLE = "Connection Endpoint Policy"; //$NON-NLS-1$ /** * The key used to install a bendpoint EditPolicy. A bendpoint * EditPolicy is an optional EditPolicy for connections that are visibile. * As with {@link #CONNECTION_ENDPOINTS_ROLE endpoints}, bendpoint * EditPolicies are porbably * {@link org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy}. */ String CONNECTION_BENDPOINTS_ROLE = "Connection Bendpoint Policy"; //$NON-NLS-1$ /** * The key used to install a connection EditPolicy. The behavior of a * ConnectionEditPart may be implemented in its * component EditPolicy, */ String CONNECTION_ROLE = "ConnectionEditPolicy"; //$NON-NLS-1$ /** * The key used to install a container EditPolicy. */ String CONTAINER_ROLE = "ContainerEditPolicy"; //$NON-NLS-1$ /** * The key used to install a direct edit EditPolicy. */ String DIRECT_EDIT_ROLE = "DirectEditPolicy"; //$NON-NLS-1$ /** * The key used to install a graphical node EditPolicy. */ String GRAPHICAL_NODE_ROLE = "GraphicalNodeEditPolicy"; //$NON-NLS-1$ /** * The key used to install a layout EditPolicy. */ String LAYOUT_ROLE = "LayoutEditPolicy"; //$NON-NLS-1$ /** * The key used to install a node EditPolicy. */ String NODE_ROLE = "NodeEditPolicy"; //$NON-NLS-1$ /** * The key used to install a primary drag EditPolicy. */ String PRIMARY_DRAG_ROLE = "PrimaryDrag Policy"; //$NON-NLS-1$ /** * The key used to install a selection feedback EditPolicy. */ String SELECTION_FEEDBACK_ROLE = "Selection Feedback"; //$NON-NLS-1$ /** * The key used to install a tree container EditPolicy. */ String TREE_CONTAINER_ROLE = "TreeContainerEditPolicy"; //$NON-NLS-1$ /** * Activates this EditPolicy. The EditPolicy might need to hook listeners. * These listeners should be unhooked in deactivate(). The * EditPolicy might also contribute feedback/visuals immediately, such as * selection handles if the EditPart was selected at the time of * activation. *

    * Activate is called after the host has been set, and that host has * been activated. * * @see EditPart#activate() * @see #deactivate() * @see EditPart#installEditPolicy(Object, EditPolicy) */ void activate(); /** * Deactivates the EditPolicy, the inverse of {@link #activate()}. * Deactivate is called when the host is deactivated, or when the * EditPolicy is uninstalled from an active host. Deactivate unhooks any * listeners, and removes all feedback. * * @see EditPart#deactivate() * @see #activate() * @see EditPart#removeEditPolicy(Object) */ void deactivate(); /** * Erases source feedback based on the given Request. Does * nothing if the EditPolicy does not apply to the given Request. *

    * This method is declared on {@link EditPart#eraseSourceFeedback(Request) * EditPart}, and is redeclared here so that EditPart can delegate its * implementation to each of its EditPolicies. * * @param request * the Request */ void eraseSourceFeedback(Request request); /** * Erases target feedback based on the given Request. Does * nothing if the EditPolicy does not apply to the given Request. *

    * This method is declared on {@link EditPart#eraseTargetFeedback(Request) * EditPart}, and is redeclared here so that EditPart can delegate its * implementation to each of its EditPolicies. * * @param request * the Request * */ void eraseTargetFeedback(Request request); /** * Returns the Command contribution for the given * Request, or null. null is treated * as a no-op by the caller, or an empty contribution. The EditPolicy must * return an {@link org.eclipse.gef.commands.UnexecutableCommand} if it * wishes to disallow the Request. *

    * This method is declared on {@link EditPart#getCommand(Request) EditPart}, * and is redeclared here so that EditPart can delegate its implementation * to each of its EditPolicies. The EditPart will combine each EditPolicy's * contribution into a {@link org.eclipse.gef.commands.CompoundCommand}. * * @param request * the Request * @return null or a Command contribution */ Command getCommand(Request request); /** * @return the host EditPart on which this policy is installed. */ EditPart getHost(); /** * Returns null or the appropriate EditPart for * the specified Request. In general, this EditPolicy will * return its host EditPart if it understands the Request. Otherwise, * it will return null. *

    * This method is declared on {@link EditPart#getTargetEditPart(Request) * EditPart}, and is redeclared here so that EditPart can delegate its * implementation to each of its EditPolicies. The first non- * null result returned by an EditPolicy is returned by the * EditPart. * * @param request * the Request * @return null or the appropriate target EditPart */ EditPart getTargetEditPart(Request request); /** * Sets the host in which this EditPolicy is installed. * * @param editpart * the host EditPart */ void setHost(EditPart editpart); /** * Shows or updates source feedback for the specified * Request. This method may be called repeatedly for the * purpose of updating feedback based on changes to the Request. *

    * Does nothing if the EditPolicy does not recognize the given Request. *

    * This method is declared on {@link EditPart#showSourceFeedback(Request) * EditPart}, and is redeclared here so that EditPart can delegate its * implementation to each of its EditPolicies. * * @param request * the Request */ void showSourceFeedback(Request request); /** * Shows or updates target feedback for the specified * Request. This method may be called repeatedly for the * purpose of updating feedback based on changes to the Request. *

    * Does nothing if the EditPolicy does not recognize the given request. *

    * This method is declared on {@link EditPart#showTargetFeedback(Request) * EditPart}, and is redeclared here so that EditPart can delegate its * implementation to each of its EditPolicies. * * @param request * the Request */ void showTargetFeedback(Request request); /** * Returns true if this EditPolicy understand the specified * request. *

    * This method is declared on {@link EditPart#understandsRequest(Request) * EditPart}, and is redeclared here so that EditPart can delegate its * implementation to each of its EditPolicies. EditPart returns * true if any of its EditPolicies returns true. * In other words, it performs a logical OR. * * @param request * the Request * @return boolean true if the EditPolicy understands the * specified request * @see EditPart#understandsRequest(Request) */ boolean understandsRequest(Request request); } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/ExposeHelper.java000066400000000000000000000030131166301720600256670ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; /** * An adapter on an EditPart used to expose a descendant * contained in that EditPart. EditPartViewer uses this interface * to reveal a given EditPart. *

    * An expose helper is obtained by calling {@link EditPart#getAdapter(Class)}. * The returned helper is responsible for modifying *only* that EditPart's * visuals such that the specified descendant is made visible. */ public interface ExposeHelper { /** * Exposes the specified descendant on the EditPart which returned this * helper. This is done by adjusting the EditPart's visuals such that * the descendants visuals are exposed. Expose is performed from the * bottom up, meaning that EditParts in the parent-chain between the * helper's EditPart and the descendant will already have had a * change to expose the descendant. * * @param editpart * the descendant to expose */ void exposeDescendant(EditPart editpart); } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/GEF.java000066400000000000000000000054671166301720600237040ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import com.ibm.icu.text.DecimalFormat; import com.ibm.icu.text.NumberFormat; import org.eclipse.swt.widgets.Text; /** * This is an internal class used for debugging * * @deprecated in 3.1 This class will be removed in future releases. */ public final class GEF { static final String TAB = " ";//$NON-NLS-1$ static Text text; static int msgCount; static int tab; static NumberFormat formatter = new DecimalFormat(); /** * @deprecated */ public static boolean DebugTools = false; /** * @deprecated */ public static boolean DebugEvents = false; /** * @deprecated */ public static boolean DebugEditParts = false; /** * @deprecated */ public static boolean DebugPainting = false; /** * @deprecated */ public static boolean DebugFeedback = false; /** * @deprecated */ public static boolean GlobalDebug = false; /** * @deprecated */ public static boolean DebugToolStates = false; /** * @deprecated */ public static boolean DebugDND = false; /** * Clears the trace console if active * * @since 1.0 */ public static void clearConsole() { if (text == null) return; text.setText("");//$NON-NLS-1$ } /** * Sets a text control to be used as a console. * * @since 1.0 * @param textBox * the text control for streaming */ public static void setConsole(Text textBox) { msgCount = 0; formatter.setMinimumIntegerDigits(2); formatter.setMaximumFractionDigits(0); text = textBox; } /** * decrements the tracing indentation * * @since 2.0 */ public static void debugPop() { tab--; } /** * Prints the given string to a trace window and increments indentation. * * @since 2.0 * @param heading * the message describing the indented text to follow */ public static void debugPush(String heading) { debug(heading); tab++; } /** * Prints the given message to a trace window if available. * * @since 1.0 * @param message * a debug message */ public static void debug(String message) { String lineNumber = formatter.format(new Long(msgCount++)); msgCount %= 100; String indent = "";//$NON-NLS-1$ for (int i = 0; i < tab; i++) indent += TAB; if (text != null) text.append('\n' + lineNumber + '\t' + indent + message); } } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/GEFPlugin.java000066400000000000000000000032401166301720600250460ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.eclipse.ui.views.properties.IPropertySheetEntry; import org.eclipse.gef.commands.CommandStack; import org.eclipse.gef.internal.InternalGEFPlugin; /** * @deprecated The GEF plugin class must not be referenced by clients. */ public final class GEFPlugin extends AbstractUIPlugin { private static GEFPlugin singleton; /** * This method will be deleted. * * @deprecated use org.eclipse.gef.ui.properties.UndoablePropertySheetEntry * @param stack * a command stack * @return the implementation for the entry */ public static IPropertySheetEntry createUndoablePropertySheetEntry( CommandStack stack) { return new org.eclipse.gef.ui.properties.UndoablePropertySheetEntry( stack); } /** * Gets the plugin singleton. * * @return the default GEFPlugin singleton */ public static GEFPlugin getDefault() { if (singleton == null) singleton = new GEFPlugin(); return singleton; } GEFPlugin() { try { start(InternalGEFPlugin.getContext()); } catch (Exception exc) { throw new RuntimeException(exc); } } } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/GraphicalEditPart.java000066400000000000000000000066531166301720600266300ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import java.util.List; import org.eclipse.draw2d.IFigure; /** * A Specialization of {@link EditPart} for use with {@link GraphicalViewer * GraphicalViewers}. The visual part of a GraphicalEditPart is a * {@link org.eclipse.draw2d.IFigure Figure}. *

    * IMPORTANT: This interface is not intended to be implemented by clients. * Clients should inherit from * {@link org.eclipse.gef.editparts.AbstractGraphicalEditPart}. New methods may * be added in the future. */ public interface GraphicalEditPart extends EditPart { /** * Adds a NodeListener to the EditPart. Duplicate calls result in duplicate * notification. * * @param listener * the Listener */ void addNodeListener(NodeListener listener); /** * Returns the primary Figure representing this GraphicalEditPart. The * parent will add this Figure to its content pane. The Figure may be * a composition of several Figures. * * @return this EditPart's Figure */ IFigure getFigure(); /** * Returns the source connections for this GraphicalEditPart. This * method should only be called by the EditPart itself, and its helpers such * as EditPolicies. * * @return the source connections */ List getSourceConnections(); /** * Returns the target connections for this GraphicalEditPart. This * method should only be called by the EditPart itself, and its helpers such * as EditPolicies. * * @return the target connections */ List getTargetConnections(); /** * The Figure into which childrens' Figures will be added. May return the * same Figure as {@link #getFigure()}. The GraphicalEditPart's * {@link #getFigure() primary Figure} may be composed of multiple figures. * This is the figure in that composition that will contain children's * figures. * * @return the content pane Figure */ IFigure getContentPane(); /** * Removes the first occurance of the specified listener from the list of * listeners. Does nothing if the listener was not present. * * @param listener * the listener being removed */ void removeNodeListener(NodeListener listener); /** * Sets the specified constraint for a child's Figure on the * {@link #getContentPane() content pane} figure for this GraphicalEditPart. * The constraint will be applied to the content pane's * {@link org.eclipse.draw2d.LayoutManager}. revalidate() is * called on the content pane, which will cause it to layout during the next * update. * * @param child * the child GraphicalEditPart whose constraint is being * set * @param figure * the Figure whose constraint is being set * @param constraint * the constraint for the draw2d * {@link org.eclipse.draw2d.LayoutManager} */ void setLayoutConstraint(EditPart child, IFigure figure, Object constraint); } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/GraphicalViewer.java000066400000000000000000000024321166301720600263440ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import org.eclipse.draw2d.geometry.Point; /** * Specializes {@link EditPartViewer} adding the ability to hit-test * {@link Handle Handles}. * * @see org.eclipse.gef.ui.parts.GraphicalViewerImpl */ public interface GraphicalViewer extends EditPartViewer { /** * Returns the Handle at the specified Point. Returns * null if no handle exists at the given Point. The specified * point should be relative to the * {@link org.eclipse.swt.widgets.Scrollable#getClientArea() client area} * for this Viewer's Control. * * @param p * the location relative to the Control's client area * @return Handle null or a Handle */ Handle findHandleAt(Point p); } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/Handle.java000066400000000000000000000030041166301720600244570ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import org.eclipse.draw2d.geometry.Point; /** * An interface used by the {@link org.eclipse.gef.tools.SelectionTool} to * obtain a DragTracker. A GraphicalViewer will return a Handle at a given * location. The SelectionTool looks for Handles first * whenever the User presses the mouse button. If a Handle is found, it usually * offers a DragTracker, although null can also be returned. *

    * For keyboard accessibility purposes, a Handle can provide a Point at which * the SelectionTool should programmatically place the mouse. */ public interface Handle { /** * Returns the DragTracker for dragging this Handle. * * @return null or a DragTracker */ DragTracker getDragTracker(); /** * Returns an optional accessibility Point. This returned point is in * absolute coordinates. * * @return null or the absolute location */ Point getAccessibleLocation(); } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/KeyHandler.java000066400000000000000000000101641166301720600253170ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import java.util.HashMap; import java.util.Map; import org.eclipse.swt.events.KeyEvent; import org.eclipse.jface.action.IAction; /** * The KeyHandler should handle all normal keystrokes on an * EditPartViewer. Normal is simply defined as keystrokes * which are not associated with an Accelerator on the Menu. The KeyHandler will * be forwarded KeyEvents by the active Tool, which is usually the * SelectionTool. The Tool may be in a state where keystrokes should not be * processed, in which case it will not forward the keystrokes. For this reason, * it is important to always handle KeyEvents by using a KeyHandler. *

    * KeyHandlers can be chained by calling {@link #setParent(KeyHandler)}. If this * KeyHandler does not handle the keystroke, it will pass the keystroke to its * parent KeyHandler. *

    * KeyHandlers can be implemented using two stragegies. One is to map * {@link KeyStroke KeyStrokes} to {@link org.eclipse.jface.action.IAction * Actions} using the {@link #put(KeyStroke, IAction)} and * {@link #remove(KeyStroke)} API. The other is to subclass KeyHandler, and * override various methods. A combination of the two is also useful. * * @since 2.0 */ public class KeyHandler { private Map actions; private KeyHandler parent; /** * Processes a key pressed event. This method is called by the Tool * whenever a key is pressed, and the Tool is in the proper state. * * @param event * the KeyEvent * @return true if KeyEvent was handled in some way */ public boolean keyPressed(KeyEvent event) { if (performStroke(new KeyStroke(event, true))) { event.doit = false; return true; } return parent != null && parent.keyPressed(event); } /** * Processes a key released event. This method is called by the Tool * whenever a key is released, and the Tool is in the proper state. * * @param event * the KeyEvent * @return true if KeyEvent was handled in some way */ public boolean keyReleased(KeyEvent event) { if (performStroke(new KeyStroke(event, false))) return true; return parent != null && parent.keyReleased(event); } private boolean performStroke(KeyStroke key) { if (actions == null) return false; IAction action = (IAction) actions.get(key); if (action == null) return false; if (action.isEnabled()) action.run(); return true; } /** * Maps a specified KeyStroke to an IAction. When * a KeyEvent occurs matching the given KeyStroke, the Action will be * run() iff it is enabled. * * @param keystroke * the KeyStroke * @param action * the Action to run */ public void put(KeyStroke keystroke, IAction action) { if (actions == null) actions = new HashMap(); actions.put(keystroke, action); } /** * Removed a mapped IAction for the specified * KeyStroke. * * @param keystroke * the KeyStroke to be unmapped */ public void remove(KeyStroke keystroke) { if (actions != null) actions.remove(keystroke); } /** * Sets a parent KeyHandler to which this KeyHandler * will forward un-consumed KeyEvents. This KeyHandler will first attempt to * handle KeyEvents. If it does not recognize a given KeyEvent, that event * is passed to its parent * * @param parent * the parent KeyHandler * @return this for convenience */ public KeyHandler setParent(KeyHandler parent) { this.parent = parent; return this; } } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/KeyStroke.java000066400000000000000000000122461166301720600252140ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import org.eclipse.swt.events.KeyEvent; /** * Encapsulates a Keyboard gesture (press or release) from the User. A KeyStroke * is matched to a KeyEvent based the {@link KeyEvent#stateMask}, * {@link KeyEvent#keyCode} or {@link KeyEvent#character}, and whether that * KeyEvent was dispatched as a result of a release or press by the User. */ public class KeyStroke { /** * Constructs a KeyStroke that will match the given * {@link KeyEvent#character} and {@link KeyEvent#stateMask} during a press * event. * * @param character * the character to match * @param stateMask * the stateMask to match * @return a new KeyStroke */ public static KeyStroke getPressed(char character, int stateMask) { return new KeyStroke(character, stateMask, true); } /** * Constructs a KeyStroke that will match the given {@link KeyEvent#keyCode} * and {@link KeyEvent#stateMask} during a press event. * * @param keyCode * the keyCode to match * @param stateMask * the stateMask to match * @return a new KeyStroke */ public static KeyStroke getPressed(int keyCode, int stateMask) { return new KeyStroke(keyCode, stateMask, true); } /** * Constructs a KeyStroke that will match the given * {@link KeyEvent#character}, {@link KeyEvent#keyCode}, and * {@link KeyEvent#stateMask} during a press event. * * @param character * the character to match * @param keyCode * the keyCode to match * @param stateMask * the stateMask to match * @return a new KeyStroke */ public static KeyStroke getPressed(char character, int keyCode, int stateMask) { return new KeyStroke(character, keyCode, stateMask, true); } /** * Constructs a KeyStroke that will match the given * {@link KeyEvent#character} and {@link KeyEvent#stateMask} during a * release event. * * @param character * the character to match * @param stateMask * the stateMask to match * @return a new KeyStroke */ public static KeyStroke getReleased(char character, int stateMask) { return new KeyStroke(character, stateMask, false); } /** * Constructs a KeyStroke that will match the given {@link KeyEvent#keyCode} * and {@link KeyEvent#stateMask} during a release event. * * @param keyCode * the keyCode to match * @param stateMask * the stateMask to match * @return a new KeyStroke */ public static KeyStroke getReleased(int keyCode, int stateMask) { return new KeyStroke(keyCode, stateMask, false); } /** * Constructs a KeyStroke that will match the given * {@link KeyEvent#character}, {@link KeyEvent#keyCode}, and * {@link KeyEvent#stateMask} during a release event. * * @param character * the character to match * @param keyCode * the keyCode to match * @param stateMask * the stateMask to match * @return a new KeyStroke */ public static KeyStroke getReleased(char character, int keyCode, int stateMask) { return new KeyStroke(character, keyCode, stateMask, false); } private int stateMask; private char character; private boolean onPressed; private int keyCode; /** * Creates a KeyStroke for the specified KeyEvent and pressed value. * * @param event * The KeyEvent * @param pressed * true if the KeyStroke is for a press event */ KeyStroke(KeyEvent event, boolean pressed) { onPressed = pressed; stateMask = event.stateMask; character = event.character; keyCode = event.keyCode; } KeyStroke(int keyCode, int stateMask, boolean onPressed) { this.keyCode = keyCode; this.stateMask = stateMask; this.onPressed = onPressed; } KeyStroke(char character, int stateMask, boolean onPressed) { this.character = character; this.stateMask = stateMask; this.onPressed = onPressed; } KeyStroke(char character, int keyCode, int stateMask, boolean onPressed) { this.character = character; this.keyCode = keyCode; this.stateMask = stateMask; this.onPressed = onPressed; } /** * @return true iff the Object is an equivalent KeyStroke * @param obj * the Object being compared */ public boolean equals(Object obj) { if (obj instanceof KeyStroke) { KeyStroke stroke = (KeyStroke) obj; return stroke.character == character && stroke.keyCode == keyCode && stroke.onPressed == onPressed && stroke.stateMask == stateMask; } return false; } /** * @see java.lang.Object#hashCode() */ public int hashCode() { return (stateMask + 1) * ((character ^ keyCode) + 1) // One of these is // always Zero. + (onPressed ? 0 : 32); } } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/LayerConstants.java000066400000000000000000000037421166301720600262460ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; /** * The constants used to identify typical layers in a graphical application. */ public interface LayerConstants { /** * Identifies the layer containing the primary pieces of the application. */ String PRIMARY_LAYER = "Primary Layer"; //$NON-NLS-1$ /** * Identifies the layer containing connections, which typically appear on * top of anything in the primary layer. */ String CONNECTION_LAYER = "Connection Layer"; //$NON-NLS-1$ /** * Identifies the layer where the grid is painted. */ String GRID_LAYER = "Grid Layer"; //$NON-NLS-1$ /** * Identifies the layer where Guides add feedback to the primary viewer. */ String GUIDE_LAYER = "Guide Layer"; //$NON-NLS-1$ /** * Identifies the layer containing handles, which are typically editing * decorations that appear on top of any model representations. */ String HANDLE_LAYER = "Handle Layer"; //$NON-NLS-1$ /** * The layer containing feedback, which are generally temporary visuals that * appear on top of all other visuals. */ String FEEDBACK_LAYER = "Feedback Layer"; //$NON-NLS-1$ /** * The layer containing scaled feedback. */ String SCALED_FEEDBACK_LAYER = "Scaled Feedback Layer"; //$NON-NLS-1$ /** * The layer that contains all printable layers. */ String PRINTABLE_LAYERS = "Printable Layers"; //$NON-NLS-1$ /** * The layer that contains all scaled layers. */ String SCALABLE_LAYERS = "Scalable Layers"; //$NON-NLS-1$ } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/MouseWheelHandler.java000066400000000000000000000050701166301720600266440ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2005, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Event; /** * MouseWheelHandlers can be * {@link org.eclipse.gef.EditPartViewer#setProperty(String, Object) registered} * on an EditPartViewer with keys generated by the KeyGenerator. GEF tools * delegate handling of mouse-wheel events to MouseWheelHandlers, if there are * no drag trackers active. * * @author Pratik Shah * @since 3.1 */ public interface MouseWheelHandler { /** * Handles mouse-wheel events. If the given event was handled in some way, * its {@link Event#doit doit} field should be set to false so as to prevent * further processing of that event. * * @param event * The SWT event that was generated as a result of the * mouse-wheel scrolling * @param viewer * The originating viewer */ void handleMouseWheel(Event event, EditPartViewer viewer); /** * A utility class used to generate keys from a given stateMask. A * MouseWheelHandler registered with such a key would only be asked to * handle mouse-wheel events that have the same stateMask as the one that * was used to generate the key. * * @author Pratik Shah * @since 3.1 */ public class KeyGenerator { /** * The returned String is guaranteed to be equal for two different * invocations with the same stateMask. *

    * Valid stateMasks are SWT.NONE, SWT.CTRL, SWT.COMMAND, SWT.ALT, * SWT.SHIFT, SWT.MOD1, SWT.MOD2, SWT.MOD3, SWT.MOD4, SWT.BUTTON* or any * combination thereof. * * @param stateMask * the state indicating which buttons/modifiers are active * @return key for the given stateMask * @throws IllegalArgumentException * if the given stateMask is not valid */ public static String getKey(int stateMask) { if ((stateMask & ~(SWT.BUTTON_MASK | SWT.MODIFIER_MASK)) != 0) throw new IllegalArgumentException( "Illegal state: " + stateMask); //$NON-NLS-1$ return "MouseWheelHandler(" + stateMask + ")"; //$NON-NLS-1$ //$NON-NLS-2$ } } } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/MouseWheelHelper.java000066400000000000000000000031321166301720600265030ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2005, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import org.eclipse.swt.widgets.Event; /** * MouseWheelHelpers provide each EditPart to handle mouse-wheel events in their * own desired way. By default, when mouse-wheel events are generated that have * no stateMask, a default {@link MouseWheelHandler} delegates the task to the * MouseWheelHelper that is returned by the getAdapter() method of the EditPart * in focus. *

    * The most common usage of MouseWheelHelpers involves scrolling of an * EditPart's figure. They should be returned in the EditPart's getAdapter() * method. * * @see org.eclipse.gef.editparts.ViewportMouseWheelHelper * @author Pratik Shah * @since 3.1 */ public interface MouseWheelHelper { /** * Handles mouse-wheel events. If the given event was handled in some way, * its {@link Event#doit doit} field should be set to false so as to prevent * further processing of that event. * * @param event * The SWT event that was generated as a result of the * mouse-wheel scrolling */ void handleMouseWheelScrolled(Event event); } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/MouseWheelZoomHandler.java000066400000000000000000000031301166301720600275040ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2005, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import org.eclipse.swt.widgets.Event; import org.eclipse.gef.editparts.ZoomManager; /** * A MouseWheelHandler that zooms the given viewer. Typically, this handler * should be registered on a viewer that supports zoom as follows:
    * * graphicalViewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1), * MouseWheelZoomHandler.SINGLETON); * * * @author Pratik Shah * @since 3.1 */ public final class MouseWheelZoomHandler implements MouseWheelHandler { /** * The Singleton */ public static final MouseWheelHandler SINGLETON = new MouseWheelZoomHandler(); private MouseWheelZoomHandler() { } /** * Zooms the given viewer. * * @see MouseWheelHandler#handleMouseWheel(Event, EditPartViewer) */ public void handleMouseWheel(Event event, EditPartViewer viewer) { ZoomManager zoomMgr = (ZoomManager) viewer .getProperty(ZoomManager.class.toString()); if (zoomMgr != null) { if (event.count > 0) zoomMgr.zoomIn(); else zoomMgr.zoomOut(); event.doit = false; } } } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/NodeEditPart.java000066400000000000000000000077561166301720600256300ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import org.eclipse.draw2d.ConnectionAnchor; /** * A specialized GraphicalEditPart that supports both target * and source ConnectionEditParts. This optional * interface is used by the default {@link ConnectionEditPart} implementation * and supporting classes to obtain the correct {@link ConnectionAnchor * ConnectionAnchors} for the {@link org.eclipse.draw2d.Connection} Figure. This * interface offers a single access point for obtaining ConnectionAnchors at * different times. The classes which rely on this interface are: *

      *
    • {@link org.eclipse.gef.editparts.AbstractConnectionEditPart} - during * refresh(), this interface is used to obtain the appropriate ConnectionAnchors * for the figure. *
    • {@link org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy} - during * creation of a new connection, there is no ConnectionEditPart. Therefore, the * source node EditPart is responsible for display feedback. *
    • {@link org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy} - when * disconnecting the end of a connection and reattaching it to a new node, * ConnectionEndpointEditPolicy uses this interface to obtain the proper anchors * for diaplaying feedback. *
    */ public interface NodeEditPart extends GraphicalEditPart { /** * Returns the ConnectionAnchor for the specified source * connection. This NodeEditPart is the * {@link ConnectionEditPart#getSource() source} EditPart for the given * connection. *

    * The anchor may be a function of the connection's model, the node's model, * a combination of both, or it may not depend on anything all. * * @param connection * the ConnectionEditPart * @return the ConnectionAnchor for the given ConnectionEditPart */ ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connection); /** * Returns the ConnectionAnchor for the specified target * connection. This NodeEditPart is the * {@link ConnectionEditPart#getTarget() target} EditPart for the given * connection. *

    * The anchor may be a function of the connection's model, the node's model, * a combination of both, or it may not depend on anything all. * * @param connection * the ConnectionEditPart * @return the ConnectionAnchor for the given ConnectionEditPart */ ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connection); /** * Returns the source ConnectionAnchor for the specified * Request. The returned ConnectionAnchor is used only when displaying * feedback. The Request is usually a * {@link org.eclipse.gef.requests.LocationRequest}, which provides the * current mouse location. * * @param request * a Request describing the current interaction * @return the ConnectionAnchor to use during feedback */ ConnectionAnchor getSourceConnectionAnchor(Request request); /** * Returns the target ConnectionAnchor for the specified * Request. The returned ConnectionAnchor is used only when displaying * feedback. The Request is usually a * {@link org.eclipse.gef.requests.LocationRequest}, which provides the * current mouse location. * * @param request * a Request describing the current interaction * @return the ConnectionAnchor to use during feedback */ ConnectionAnchor getTargetConnectionAnchor(Request request); } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/NodeListener.java000066400000000000000000000037241166301720600256700ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; /** * The listener interface for receiving Connection events from EditParts that * serve as connection nodes. */ public interface NodeListener { /** * Called prior to removing the connection from its source node. The source * is not passed, but can still be obtained at this point by calling * {@link ConnectionEditPart#getSource connection.getSource()} * * @param connection * the connection * @param index * the index */ void removingSourceConnection(ConnectionEditPart connection, int index); /** * Called prior to removing the connection from its target node. The target * is not passed, but can still be obtained at this point by calling * {@link ConnectionEditPart#getTarget connection.getTarget()} * * @param connection * the connection * @param index * the index */ void removingTargetConnection(ConnectionEditPart connection, int index); /** * Called after the connection has been added to its source node. * * @param connection * the connection * @param index * the index */ void sourceConnectionAdded(ConnectionEditPart connection, int index); /** * Called after the connection has been added to its target node. * * @param connection * the connection * @param index * the index */ void targetConnectionAdded(ConnectionEditPart connection, int index); } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/Request.java000066400000000000000000000042631166301720600247240ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import java.util.HashMap; import java.util.Map; /** * An Object used to communicate with EditParts. Request encapsulates the * information EditParts need to perform various functions. Requests are used * for obtaining commands, showing feedback, and performing generic operations. * TODO: This should probably go into the org.eclipse.gef.requests package. */ public class Request { private Object type; private Map extendedData; /** * Constructs an empty Request */ public Request() { } /** * Constructs a Request with the specified type * * @param type * the Request type * @see #getType() */ public Request(Object type) { setType(type); } /** * Returns a Map that can be used to save useful information in this * request. * * @return a map to store useful information */ public Map getExtendedData() { if (extendedData == null) { extendedData = new HashMap(); } return extendedData; } /** * Returns the type of the request. The type is often used as a quick way to * filter recognized Requests. Once the type is identified, the Request is * usually cast to a more specific subclass containing additional data. * * @return the Request type */ public Object getType() { return type; } /** * Sets the given map to be the new extended data (by reference) for this * request. * * @param map * The new map */ public void setExtendedData(Map map) { extendedData = map; } /** * Sets the type of the Request. * * @param type * the Request type */ public void setType(Object type) { this.type = type; } } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/RequestConstants.java000066400000000000000000000111711166301720600266150ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; /** * The set of constants used to identify Requests by their * {@link Request#getType() type}. Applications can extend this set of constants * with their own. */ public interface RequestConstants { /** * Indicates the creation of a new connection. Creating a connection * involves both the source node and target node EditParts. This is the * constant that is used with the first node on which the user clicks. */ String REQ_CONNECTION_START = "connection start";//$NON-NLS-1$ /** * Indicates the end of creation of a new connection. Creating a connection * involves both the source node and target node EditParts. This is the * constant that is used with the second node on which the user clicks. */ String REQ_CONNECTION_END = "connection end";//$NON-NLS-1$ /** * Constant used to indicate that the source end of an existing * connection is being reconnected to a new source node EditPart. The new * source node is the receiver of such Requests. */ String REQ_RECONNECT_SOURCE = "Reconnection source";//$NON-NLS-1$ /** * Constant used to indicate that the target end of an existing * connection is being reconnected to a new target node EditPart. The new * target node is the receiver of such Requests. */ String REQ_RECONNECT_TARGET = "Reconnection target";//$NON-NLS-1$ /** * Indicates that an existing bendpoint is being moved or dragged by the * User. */ String REQ_MOVE_BENDPOINT = "move bendpoint";//$NON-NLS-1$ /** * Indicates that a bendpoint is being inserted by the User. */ String REQ_CREATE_BENDPOINT = "create bendpoint";//$NON-NLS-1$ /** * Indicates that a part (or a group of parts) is being resized. */ String REQ_RESIZE = "resize"; //$NON-NLS-1$ /** * Indicates that a group of children are to be resized. */ String REQ_RESIZE_CHILDREN = "resize children"; //$NON-NLS-1$ /** * Indicates that a part (or a group of parts) is being moved within its * current parent. */ String REQ_MOVE = "move"; //$NON-NLS-1$ /** * Indicates that a group of children are being moved. */ String REQ_MOVE_CHILDREN = "move children"; //$NON-NLS-1$ /** * Indicates that the user has double-clicked on the receiver. "Open" means * different things for different applications. Sometimes it means open a * popup dialog of properties, or the Workbench's properties view. Sometimes * it means open a sub-diagram. */ String REQ_OPEN = "open"; //$NON-NLS-1$ /** * Indicates that the receiver is being removed from its current parent, to * be inserted into a new parent. */ String REQ_ORPHAN = "orphan"; //$NON-NLS-1$ /** * Indicates that a group of children are being removed from the receiver of * the Request. */ String REQ_ORPHAN_CHILDREN = "orphan children"; //$NON-NLS-1$ /** * Indicates that an object is to be created by the receiver of the Request. */ String REQ_CREATE = "create child"; //$NON-NLS-1$ /** * Constant used to indicate that a group of existing children are being * added to the receiver of the Request. */ String REQ_ADD = "add children"; //$NON-NLS-1$ /** * Indicates that the reciever of the request should be cloned. */ String REQ_CLONE = "clone"; //$NON-NLS-1$ /** * Constant used to indicate that the receiver of the Request is being * deleted. */ String REQ_DELETE = "delete"; //$NON-NLS-1$ /** * Constant used to indicate that a child of the receiver the Request is to * be deleted. */ String REQ_DELETE_DEPENDANT = "delete dependant"; //$NON-NLS-1$ /** * Constant used to indicate that alignment is being performed. */ String REQ_ALIGN = "align"; //$NON-NLS-1$ /** * Constant used to indicate that a group of children are being aligned. */ String REQ_ALIGN_CHILDREN = "align children"; //$NON-NLS-1$ /** * Indicates that a direct edit should be performed. */ String REQ_DIRECT_EDIT = "direct edit"; //$NON-NLS-1$ /** * Indicates selection Requests. */ String REQ_SELECTION = "selection"; //$NON-NLS-1$ /** * Indicates selection hover Requests. */ String REQ_SELECTION_HOVER = "selection hover"; //$NON-NLS-1$ } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/RootEditPart.java000066400000000000000000000031571166301720600256550ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; /** * A RootEditPart is the root of an EditPartViewer. It bridges the gap * between the EditPartViewer and its {@link EditPartViewer#getContents() * contents}. It does not correspond to anything in the model, and typically can * not be interacted with by the User. The Root provides a homogeneous context * for the applications "real" EditParts. */ public interface RootEditPart extends EditPart { /** * Returns the contents EditPart. A RootEditPart only has a single * child, called its contents. * * @return the contents. */ EditPart getContents(); /** * Returns the root's EditPartViewer. * * @return The EditPartViewer */ EditPartViewer getViewer(); /** * Sets the contents EditPart. A RootEditPart only has a single * child, called its contents. * * @param editpart * the contents */ void setContents(EditPart editpart); /** * Sets the root's EditPartViewer. * * @param viewer * the EditPartViewer */ void setViewer(EditPartViewer viewer); } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/SelectionManager.java000066400000000000000000000161641166301720600265170ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2006, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import java.util.List; import org.eclipse.swt.widgets.Control; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.StructuredSelection; /** * Manages a viewer's selection model. Selection management includes * representing a form of selection which is available to clients of a viewer as * an ISelection. It also includes managing the notion of focus, which is * closely tied to the current selection. The selection manager provides the * mechanism for modifying the selection and any validation. *

    * WARNING: Subclassing this class is considered experimental at this point. * * @since 3.2 */ public class SelectionManager { private EditPart focusPart; private Runnable notifier; private List selection; private EditPartViewer viewer; /** * Default Constructor * * @since 3.2 */ protected SelectionManager() { } /** * Creates the default implementation for a selection manager. * * @return the default selection manager * @since 3.2 */ public static SelectionManager createDefault() { return new SelectionManager(); } /** * Appends the EditPart to the current selection. The EditPart * becomes the new primary selection. Fires selection changed to all * {@link org.eclipse.jface.viewers.ISelectionChangedListener}s. * * @param editpart * the EditPart to append * @since 3.2 */ public void appendSelection(EditPart editpart) { if (editpart != getFocus()) viewer.setFocus(null); if (!selection.isEmpty()) { EditPart primary = (EditPart) selection.get(selection.size() - 1); primary.setSelected(EditPart.SELECTED); } // if the editpart is already in the list, re-order it to be the last // one selection.remove(editpart); selection.add(editpart); editpart.setSelected(EditPart.SELECTED_PRIMARY); fireSelectionChanged(); } /** * Removes the EditPart from the current selection. * * @param editpart * the editpart * @since 3.2 */ public void deselect(EditPart editpart) { editpart.setSelected(EditPart.SELECTED_NONE); selection.remove(editpart); if (!selection.isEmpty()) { // IMPORTANT: it may (temporarily) happen that the selection list // contains edit parts, which are not selectable (any more) when // this method gets called. Consider e.g. that the selectable state // of an edit part may bound to its activation state (by overwriting // isSelectable()); in this case, when deleting a selected edit part // and its primary selected child simultaneously, the parent edit // part may have already become non selectable, while not having // been deselected yet (because deselection is performed within // removeNotify() after deactivation), when the child edit part gets // deselected. Therefore, we do not simply choose the last edit part // in the list as the new primary selection, but reverse-search the // list for the first that is (still) selectable. for (int i = selection.size() - 1; i >= 0; i--) { EditPart primaryCandidate = (EditPart) selection.get(i); if (primaryCandidate.isSelectable()) { primaryCandidate.setSelected(EditPart.SELECTED_PRIMARY); break; } } } fireSelectionChanged(); } /** * Deselects everything. * * @since 3.2 */ public void deselectAll() { EditPart part; setFocus(null); for (int i = 0; i < selection.size(); i++) { part = (EditPart) selection.get(i); part.setSelected(EditPart.SELECTED_NONE); } selection.clear(); fireSelectionChanged(); } /** * Causes the viewer to fire selection changed notification to all * listeners. * * @since 3.2 */ protected final void fireSelectionChanged() { notifier.run(); } /** * Returns the focus editpart. * * @return the focus editpart * @since 3.2 */ protected EditPart getFocus() { return focusPart; } /** * Returns the current selection. * * @return the selection * @since 3.2 */ public ISelection getSelection() { if (selection.isEmpty() && viewer.getContents() != null) return new StructuredSelection(viewer.getContents()); return new StructuredSelection(selection); } /** * Returns null or the viewer whose selection is managed. * * @return null or the viewer * @since 3.2 */ protected EditPartViewer getViewer() { return viewer; } /** * For internal use only. This API is subject to change. * * @param control * the control * @since 3.2 */ public void internalHookControl(Control control) { } /** * For internal use only. This API is subject to change. * * @since 3.2 */ public void internalUninstall() { } /** * Provides a hook for when the viewer has been set. * * @param viewer * the viewer. * @since 3.2 */ protected void hookViewer(EditPartViewer viewer) { } /** * For internal use only. * * @param viewer * viewer * @param selection * selection * @param notifier * notifier * @since 3.2 */ public void internalInitialize(EditPartViewer viewer, List selection, Runnable notifier) { this.viewer = viewer; this.selection = selection; this.notifier = notifier; hookViewer(viewer); } /** * Sets the focus part. * * @param part * the focus part * @since 3.2 */ public void setFocus(EditPart part) { if (focusPart == part) return; if (focusPart != null) focusPart.setFocus(false); focusPart = part; if (focusPart != null) focusPart.setFocus(true); } /** * Sets the selection. * * @param newSelection * the new selection * @since 3.2 */ public void setSelection(ISelection newSelection) { if (!(newSelection instanceof IStructuredSelection)) return; List orderedSelection = ((IStructuredSelection) newSelection).toList(); // Convert to HashSet to optimize performance. Collection hashset = new HashSet(orderedSelection); setFocus(null); for (int i = 0; i < selection.size(); i++) { EditPart part = (EditPart) selection.get(i); if (!hashset.contains(part)) part.setSelected(EditPart.SELECTED_NONE); } selection.clear(); if (!orderedSelection.isEmpty()) { Iterator itr = orderedSelection.iterator(); while (true) { EditPart part = (EditPart) itr.next(); selection.add(part); if (!itr.hasNext()) { part.setSelected(EditPart.SELECTED_PRIMARY); break; } part.setSelected(EditPart.SELECTED); } } fireSelectionChanged(); } } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/SharedCursors.java000066400000000000000000000037021166301720600260600ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import org.eclipse.swt.graphics.Cursor; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.draw2d.Cursors; import org.eclipse.gef.internal.Internal; /** * A shared collection of Cursors. * * @since 2.0 */ public class SharedCursors extends Cursors { /** * Cursor for valid connection */ public static final Cursor CURSOR_PLUG; /** * Cursor for invalid connection */ public static final Cursor CURSOR_PLUG_NOT; /** * Cursor for adding to a tree */ public static final Cursor CURSOR_TREE_ADD; /** * Cursor for dragging in a tree */ public static final Cursor CURSOR_TREE_MOVE; static { CURSOR_PLUG = createCursor("icons/plugmask.gif", //$NON-NLS-1$ "icons/plug.bmp"); //$NON-NLS-1$ CURSOR_PLUG_NOT = createCursor("icons/plugmasknot.gif", //$NON-NLS-1$ "icons/plugnot.bmp"); //$NON-NLS-1$ CURSOR_TREE_ADD = createCursor("icons/Tree_Add_Mask.gif", //$NON-NLS-1$ "icons/Tree_Add.gif"); //$NON-NLS-1$ CURSOR_TREE_MOVE = createCursor("icons/Tree_Move_Mask.gif", //$NON-NLS-1$ "icons/Tree_Move.gif"); //$NON-NLS-1$ } private static Cursor createCursor(String sourceName, String maskName) { ImageDescriptor src = ImageDescriptor.createFromFile(Internal.class, sourceName); ImageDescriptor mask = ImageDescriptor.createFromFile(Internal.class, maskName); return new Cursor(null, src.getImageData(), mask.getImageData(), 0, 0); } } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/SharedImages.java000066400000000000000000000054321166301720600256270ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.gef.internal.Internal; /** * A class containing shared Images and ImageDescriptors for use by clients. * * @author hudsonr * @since 2.1 */ public class SharedImages { /** * A 16x16 icon representing the Selection Tool */ public static final ImageDescriptor DESC_SELECTION_TOOL_16; /** * A 24x24 icon representing the Selection Tool */ public static final ImageDescriptor DESC_SELECTION_TOOL_24; /** * A 16x16 icon representing the Marquee Tool (nodes and connections) */ public static final ImageDescriptor DESC_MARQUEE_TOOL_16; /** * A 24x24 icon representing the Marquee Tool (nodes and connections) */ public static final ImageDescriptor DESC_MARQUEE_TOOL_24; /** * A 16x16 icon representing the Marquee Tool (nodes only) * * @since 3.7 */ public static final ImageDescriptor DESC_MARQUEE_TOOL_NODES_16; /** * A 24x24 icon representing the Marquee Tool (nodes only). * * @since 3.7 */ public static final ImageDescriptor DESC_MARQUEE_TOOL_NODES_24; /** * A 16x16 icon representing the Marquee Tool (connections only) * * @since 3.7 */ public static final ImageDescriptor DESC_MARQUEE_TOOL_CONNECTIONS_16; /** * A 24x24 icon representing the Marquee Tool (connections only). * * @since 3.7 */ public static final ImageDescriptor DESC_MARQUEE_TOOL_CONNECTIONS_24; static { DESC_SELECTION_TOOL_16 = createDescriptor("icons/arrow16.gif"); //$NON-NLS-1$ DESC_SELECTION_TOOL_24 = createDescriptor("icons/arrow24.gif"); //$NON-NLS-1$ DESC_MARQUEE_TOOL_16 = createDescriptor("icons/marquee16.gif"); //$NON-NLS-1$ DESC_MARQUEE_TOOL_24 = createDescriptor("icons/marquee24.gif"); //$NON-NLS-1$ DESC_MARQUEE_TOOL_NODES_16 = createDescriptor("icons/marquee_nodes16.gif"); //$NON-NLS-1$ DESC_MARQUEE_TOOL_NODES_24 = createDescriptor("icons/marquee_nodes24.gif"); //$NON-NLS-1$ DESC_MARQUEE_TOOL_CONNECTIONS_16 = createDescriptor("icons/marquee_wires16.gif"); //$NON-NLS-1$ DESC_MARQUEE_TOOL_CONNECTIONS_24 = createDescriptor("icons/marquee_wires24.gif"); //$NON-NLS-1$ } private static ImageDescriptor createDescriptor(String filename) { return ImageDescriptor.createFromFile(Internal.class, filename); } } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/SharedMessages.java000066400000000000000000000021221166301720600261620ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import org.eclipse.gef.internal.GEFMessages; /** * This class contains UI strings (translated, if available) that clients can * use. * * @author Eric Bordeau */ public class SharedMessages { /** * The string "Page". */ public static String FitAllAction_Label = GEFMessages.FitAllAction_Label; /** * The string "Width". */ public static String FitWidthAction_Label = GEFMessages.FitWidthAction_Label; /** * The string "Height". */ public static String FitHeightAction_Label = GEFMessages.FitHeightAction_Label; } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/SnapToGeometry.java000066400000000000000000000346361166301720600262230ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.geometry.PrecisionRectangle; import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.gef.handles.HandleBounds; import org.eclipse.gef.requests.GroupRequest; /** * A temporary helper used to perform snapping to existing elements. This helper * can be used in conjunction with the * {@link org.eclipse.gef.tools.DragEditPartsTracker DragEditPartsTracker} when * dragging editparts within a graphical viewer. Snapping is based on the * existing children of a container. When snapping a rectangle, the edges * of the rectangle will snap to edges of other rectangles generated from the * children of the given container. Similarly, the centers and middles of * rectangles will snap to each other. *

    * If the snap request is being made during a Move, Reparent or Resize, then the * figures of the participants of that request will not be used for snapping. If * the request is a Clone, then the figures for the parts being cloned will be * used as possible snap locations. *

    * This helper does not keep up with changes made to the container editpart. * Clients should instantiate a new helper each time one is requested and not * hold on to instances of the helper. * * @since 3.0 * @author Randy Hudson * @author Pratik Shah */ public class SnapToGeometry extends SnapToHelper { /** * A property indicating whether this helper should be used. The value * should be an instance of Boolean. Currently, this class does not check to * see if the viewer property is set to true. * * @see EditPartViewer#setProperty(String, Object) */ public static final String PROPERTY_SNAP_ENABLED = "SnapToGeometry.isEnabled"; //$NON-NLS-1$ /** * The key used to identify the North anchor point in the extended data of a * request. The north anchor may be set to an {@link Integer} value * indicating where the snapping is occurring. This is used for feedback * purposes. */ public static final String KEY_NORTH_ANCHOR = "SnapToGeometry.NorthAnchor"; //$NON-NLS-1$ /** * The key used to identify the South anchor point in the extended data of a * request. The south anchor may be set to an {@link Integer} value * indicating where the snapping is occurring. This is used for feedback * purposes. */ public static final String KEY_SOUTH_ANCHOR = "SnapToGeometry.SouthAnchor"; //$NON-NLS-1$ /** * The key used to identify the West anchor point in the extended data of a * request. The west anchor may be set to an {@link Integer} value * indicating where the snapping is occurring. This is used for feedback * purposes. */ public static final String KEY_WEST_ANCHOR = "SnapToGeometry.WestAnchor"; //$NON-NLS-1$ /** * The key used to identify the East anchor point in the extended data of a * request. The east anchor may be set to an {@link Integer} value * indicating where the snapping is occurring. This is used for feedback * purposes. */ public static final String KEY_EAST_ANCHOR = "SnapToGeometry.EastAnchor"; //$NON-NLS-1$ /** * A vertical or horizontal snapping point. since 3.0 */ protected static class Entry { final int type; final int location; /** * Constructs a new entry of the given type and location. * * @param type * an integer between -1 and 1 inclusively * @param location * the location */ protected Entry(int type, int location) { if (type < -1 || type > 1) throw new IllegalArgumentException("Unrecognized snap type"); //$NON-NLS-1$ this.type = type; this.location = location; } /** * Returns the location of the snap entry. * * @return the location * @since 3.2 */ public int getLocation() { return location; } /** * Returns the snap type. The following values may be returned. *

      *
    • -1 indicates left/top *
    • 0 indicates middle/center *
    • 1 indicates right/bottom *
    * * @return the snap type * @since 3.2 */ public int getType() { return type; } } /** * The sensitivity of the snapping. Corrections greater than this value will * not occur. */ protected static final double THRESHOLD = 5.0001; private double threshold = THRESHOLD; boolean cachedCloneBool; /** * The horizontal rows being snapped to. */ protected Entry rows[]; /** * The vertical columnd being snapped to. */ protected Entry cols[]; /** * The container editpart providing the coordinates and the children to * which snapping occurs. */ protected GraphicalEditPart container; /** * Constructs a helper that will use the given part as its basis for * snapping. The part's contents pane will provide the coordinate system and * its children determine the existing elements. * * @since 3.0 * @param container * the container editpart */ public SnapToGeometry(GraphicalEditPart container) { this.container = container; } /** * Get the sensitivity of the snapping. Corrections greater than this value * will not occur. * * @return the snapping threshold * @since 3.4 */ protected double getThreshold() { return this.threshold; } /** * Set the sensitivity of the snapping. * * @see #getThreshold() * @param newThreshold * the new snapping threshold * @since 3.4 */ protected void setThreshold(double newThreshold) { this.threshold = newThreshold; } /** * Generates a list of parts which should be snapped to. The list is the * original children, minus the given exclusions, minus and children whose * figures are not visible. * * @since 3.0 * @param exclusions * the children to exclude * @return a list of parts which should be snapped to */ protected List generateSnapPartsList(List exclusions) { // Don't snap to any figure that is being dragged List children = new ArrayList(container.getChildren()); children.removeAll(exclusions); // Don't snap to hidden figures List hiddenChildren = new ArrayList(); for (Iterator iter = children.iterator(); iter.hasNext();) { GraphicalEditPart child = (GraphicalEditPart) iter.next(); if (!child.getFigure().isVisible()) hiddenChildren.add(child); } children.removeAll(hiddenChildren); return children; } /** * Returns the correction value for the given entries and sides. During a * move, the left, right, or center is free to snap to a location. * * @param entries * the entries * @param extendedData * the requests extended data * @param vert * true if the correction is vertical * @param near * the left/top side of the rectangle * @param far * the right/bottom side of the rectangle * @return the correction amount or #getThreshold () if no correction was * made */ protected double getCorrectionFor(Entry entries[], Map extendedData, boolean vert, double near, double far) { far -= 1.0; double total = near + far; // If the width is even (i.e., odd right now because we have reduced one // pixel from // far) there is no middle pixel so favor the left-most/top-most pixel // (which is what // populateRowsAndCols() does by using int precision). if ((int) (near - far) % 2 != 0) total -= 1.0; double result = getCorrectionFor(entries, extendedData, vert, total / 2, 0); if (result == getThreshold()) result = getCorrectionFor(entries, extendedData, vert, near, -1); if (result == getThreshold()) result = getCorrectionFor(entries, extendedData, vert, far, 1); return result; } /** * Returns the correction value between {@link #getThreshold()}, or the * #getThreshold () if no corrections were found. * * @param entries * the entries * @param extendedData * the map for setting values * @param vert * true if vertical * @param value * the value being corrected * @param side * which sides should be considered * @return the correction or #getThreshold () if no correction was made */ protected double getCorrectionFor(Entry entries[], Map extendedData, boolean vert, double value, int side) { double resultMag = getThreshold(); double result = getThreshold(); String property; if (side == -1) property = vert ? KEY_WEST_ANCHOR : KEY_NORTH_ANCHOR; else property = vert ? KEY_EAST_ANCHOR : KEY_SOUTH_ANCHOR; for (int i = 0; i < entries.length; i++) { Entry entry = entries[i]; double magnitude; if (entry.type == -1 && side != 0) { magnitude = Math.abs(value - entry.location); if (magnitude < resultMag) { resultMag = magnitude; result = entry.location - value; extendedData.put(property, new Integer(entry.location)); } } else if (entry.type == 0 && side == 0) { magnitude = Math.abs(value - entry.location); if (magnitude < resultMag) { resultMag = magnitude; result = entry.location - value; extendedData.put(property, new Integer(entry.location)); } } else if (entry.type == 1 && side != 0) { magnitude = Math.abs(value - entry.location); if (magnitude < resultMag) { resultMag = magnitude; result = entry.location - value; extendedData.put(property, new Integer(entry.location)); } } } return result; } /** * Returns the rectangular contribution for the given editpart. This is the * rectangle with which snapping is performed. * * @since 3.0 * @param part * the child * @return the rectangular guide for that part */ protected Rectangle getFigureBounds(GraphicalEditPart part) { IFigure fig = part.getFigure(); if (fig instanceof HandleBounds) return ((HandleBounds) fig).getHandleBounds(); return fig.getBounds(); } /** * Updates the cached row and column Entries using the provided parts. * * @since 3.0 * @param parts * a List of EditParts */ protected void populateRowsAndCols(List parts) { rows = new Entry[parts.size() * 3]; cols = new Entry[parts.size() * 3]; for (int i = 0; i < parts.size(); i++) { GraphicalEditPart child = (GraphicalEditPart) parts.get(i); Rectangle bounds = getFigureBounds(child); cols[i * 3] = new Entry(-1, bounds.x); rows[i * 3] = new Entry(-1, bounds.y); cols[i * 3 + 1] = new Entry(0, bounds.x + (bounds.width - 1) / 2); rows[i * 3 + 1] = new Entry(0, bounds.y + (bounds.height - 1) / 2); cols[i * 3 + 2] = new Entry(1, bounds.right() - 1); rows[i * 3 + 2] = new Entry(1, bounds.bottom() - 1); } } /** * @see SnapToHelper#snapRectangle(Request, int, PrecisionRectangle, * PrecisionRectangle) */ public int snapRectangle(Request request, int snapOrientation, PrecisionRectangle baseRect, PrecisionRectangle result) { baseRect = baseRect.getPreciseCopy(); makeRelative(container.getContentPane(), baseRect); PrecisionRectangle correction = new PrecisionRectangle(); makeRelative(container.getContentPane(), correction); // Recalculate snapping locations if needed boolean isClone = request.getType().equals(RequestConstants.REQ_CLONE); if (rows == null || cols == null || isClone != cachedCloneBool) { cachedCloneBool = isClone; List exclusionSet = Collections.EMPTY_LIST; if (!isClone && request instanceof GroupRequest) exclusionSet = ((GroupRequest) request).getEditParts(); populateRowsAndCols(generateSnapPartsList(exclusionSet)); } if ((snapOrientation & HORIZONTAL) != 0) { double xcorrect = getThreshold(); xcorrect = getCorrectionFor(cols, request.getExtendedData(), true, baseRect.preciseX(), baseRect.preciseRight()); if (xcorrect != getThreshold()) { snapOrientation &= ~HORIZONTAL; correction.setPreciseX(correction.preciseX() + xcorrect); } } if ((snapOrientation & VERTICAL) != 0) { double ycorrect = getThreshold(); ycorrect = getCorrectionFor(rows, request.getExtendedData(), false, baseRect.preciseY(), baseRect.preciseBottom()); if (ycorrect != getThreshold()) { snapOrientation &= ~VERTICAL; correction.setPreciseY(correction.preciseY() + ycorrect); } } if ((snapOrientation & EAST) != 0) { double rightCorrection = getCorrectionFor(cols, request.getExtendedData(), true, baseRect.preciseRight() - 1, 1); if (rightCorrection != getThreshold()) { snapOrientation &= ~EAST; correction.setPreciseWidth(correction.preciseWidth() + rightCorrection); } } if ((snapOrientation & WEST) != 0) { double leftCorrection = getCorrectionFor(cols, request.getExtendedData(), true, baseRect.preciseX(), -1); if (leftCorrection != getThreshold()) { snapOrientation &= ~WEST; correction.setPreciseWidth(correction.preciseWidth() - leftCorrection); correction.setPreciseX(correction.preciseX() + leftCorrection); } } if ((snapOrientation & SOUTH) != 0) { double bottom = getCorrectionFor(rows, request.getExtendedData(), false, baseRect.preciseBottom() - 1, 1); if (bottom != getThreshold()) { snapOrientation &= ~SOUTH; correction .setPreciseHeight(correction.preciseHeight() + bottom); } } if ((snapOrientation & NORTH) != 0) { double topCorrection = getCorrectionFor(rows, request.getExtendedData(), false, baseRect.preciseY(), -1); if (topCorrection != getThreshold()) { snapOrientation &= ~NORTH; correction.setPreciseHeight(correction.preciseHeight() - topCorrection); correction.setPreciseY(correction.preciseY() + topCorrection); } } makeAbsolute(container.getContentPane(), correction); result.setPreciseX(result.preciseX() + correction.preciseX()); result.setPreciseY(result.preciseY() + correction.preciseY()); result.setPreciseWidth(result.preciseWidth() + correction.preciseWidth()); result.setPreciseHeight(result.preciseHeight() + correction.preciseHeight()); return snapOrientation; } } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/SnapToGrid.java000066400000000000000000000132121166301720600253000ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.PrecisionRectangle; /** * A helper used to perform snapping to a grid, which is specified on the * graphical viewer via the various properties defined in this class. This * helper can be used in conjunction with the * {@link org.eclipse.gef.tools.DragEditPartsTracker DragEditPartsTracker} when * dragging editparts within a graphical viewer. When snapping a rectangle, the * edges of the rectangle will snap along gridlines. *

    * This helper does not keep up with changes made to the graphical viewer's * properties. Clients should instantiate a new helper each time one is * requested and not hold on to instances of the helper, if the grid properties * specified on the viewer are subject to change. * * @author Randy Hudson * @author Pratik Shah * @since 3.0 * @see org.eclipse.gef.editparts.GridLayer */ public class SnapToGrid extends SnapToHelper { /** * A viewer property indicating whether the snap function is enabled. The * value must be a Boolean. */ public static final String PROPERTY_GRID_ENABLED = "SnapToGrid.isEnabled"; //$NON-NLS-1$ /** * A viewer property indicating whether the grid should be displayed. The * value must be a Boolean. */ public static final String PROPERTY_GRID_VISIBLE = "SnapToGrid.isVisible"; //$NON-NLS-1$ /** * A viewer property indicating the grid spacing. The value must be a * {@link Dimension}. */ public static final String PROPERTY_GRID_SPACING = "SnapToGrid.GridSpacing"; //$NON-NLS-1$ /** * A viewer property indicating the grid's origin. The value must be a * {@link Point}. */ public static final String PROPERTY_GRID_ORIGIN = "SnapToGrid.GridOrigin"; //$NON-NLS-1$ /** * The default grid size if the viewer does not specify a size. * * @see #PROPERTY_GRID_SPACING */ public static final int DEFAULT_GRID_SIZE = 12; /** * @deprecated use DEFAULT_GRID_SIZE */ public static final int DEFAULT_GAP = DEFAULT_GRID_SIZE; /** * The graphical part whose content's figure defines the grid. */ protected GraphicalEditPart container; /** * The horizontal interval for the grid */ protected int gridX; /** * The vertical interval for the grid */ protected int gridY; /** * The origin of the grid. */ protected Point origin; /** * Constructs a gridded snap helper on the given editpart. The editpart * should be the graphical editpart whose contentspane figure is used as the * reference for the grid. * * @param container * the editpart which the grid is on */ public SnapToGrid(GraphicalEditPart container) { this.container = container; Dimension spacing = (Dimension) container.getViewer().getProperty( PROPERTY_GRID_SPACING); if (spacing != null) { gridX = spacing.width; gridY = spacing.height; } if (gridX == 0) gridX = DEFAULT_GRID_SIZE; if (gridY == 0) gridY = DEFAULT_GRID_SIZE; Point loc = (Point) container.getViewer().getProperty( PROPERTY_GRID_ORIGIN); if (loc != null) origin = loc; else origin = new Point(); } /** * @see SnapToHelper#snapRectangle(Request, int, PrecisionRectangle, * PrecisionRectangle) */ public int snapRectangle(Request request, int snapLocations, PrecisionRectangle rect, PrecisionRectangle result) { rect = rect.getPreciseCopy(); makeRelative(container.getContentPane(), rect); PrecisionRectangle correction = new PrecisionRectangle(); makeRelative(container.getContentPane(), correction); if (gridX > 0 && (snapLocations & EAST) != 0) { correction.setPreciseWidth(correction.preciseWidth() - Math.IEEEremainder(rect.preciseRight() - origin.x - 1, gridX)); snapLocations &= ~EAST; } if ((snapLocations & (WEST | HORIZONTAL)) != 0 && gridX > 0) { double leftCorrection = Math.IEEEremainder(rect.preciseX() - origin.x, gridX); correction.setPreciseX(correction.preciseX() - leftCorrection); if ((snapLocations & HORIZONTAL) == 0) { correction.setPreciseWidth(correction.preciseWidth() + leftCorrection); } snapLocations &= ~(WEST | HORIZONTAL); } if ((snapLocations & SOUTH) != 0 && gridY > 0) { correction.setPreciseHeight(correction.preciseHeight() - Math.IEEEremainder(rect.preciseBottom() - origin.y - 1, gridY)); snapLocations &= ~SOUTH; } if ((snapLocations & (NORTH | VERTICAL)) != 0 && gridY > 0) { double topCorrection = Math.IEEEremainder(rect.preciseY() - origin.y, gridY); correction.setPreciseY(correction.preciseY() - topCorrection); if ((snapLocations & VERTICAL) == 0) { correction.setPreciseHeight(correction.preciseHeight() + topCorrection); } snapLocations &= ~(NORTH | VERTICAL); } makeAbsolute(container.getContentPane(), correction); result.setPreciseX(result.preciseX() + correction.preciseX()); result.setPreciseY(result.preciseY() + correction.preciseY()); result.setPreciseWidth(result.preciseWidth() + correction.preciseWidth()); result.setPreciseHeight(result.preciseHeight() + correction.preciseHeight()); return snapLocations; } } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/SnapToGuides.java000066400000000000000000000276221166301720600256450ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import java.util.Map; import org.eclipse.draw2d.geometry.PrecisionRectangle; import org.eclipse.gef.requests.GroupRequest; import org.eclipse.gef.rulers.RulerProvider; /** * A helper used to perform snapping to guides. The guides are obtained from the * viewer's horizontal and vertical {@link RulerProvider RulerProviders}. If * snapping is performed, the request's extended data will contain keyed values * indicating which guides were snapped to, and which side of the part should be * attached. Generally snapping to a guide should attach the part to that guide, * but application behavior may differ. *

    * Snapping (and attaching) to a guide is only possible if a single part is * being dragged. The current implementation will not snap if a request contains * multiple parts. This may be relaxed in the future to allow snapping, but * without setting the attachment extended data. *

    * This helper does not keep up with changes in guides. Clients should * instantiate a new helper each time one is requested and not hold on to * instances of the helper. * * @since 3.0 * @author Randy Hudson * @author Pratik Shah */ public class SnapToGuides extends SnapToHelper { /** * The key used to identify the Vertical Guide. This key is used with the * request's extended data map to store an Integer. The integer value is the * location of the guide that is being snapped to. */ public static final String KEY_VERTICAL_GUIDE = "SnapToGuides.VerticalGuide"; //$NON-NLS-1$ /** * The key used to identify the Horizontal Guide. This key is used with the * request's extended data map to store an Integer. The integer value is the * location of the guide that is being snapped to. */ public static final String KEY_HORIZONTAL_GUIDE = "SnapToGuides.HorizontalGuide"; //$NON-NLS-1$ /** * The key used to identify the vertical anchor point. This key is used with * the request's extended data map to store an Integer. If the * VERTICAL_GUIDE has been set, then this integer is a number identifying * which side of the dragged object is being snapped to that guide. *

      *
    • -1 indicates the left side should be attached. *
    • 0 indicates the center should be attached. *
    • 1 indicates the right side should be attached. *
    */ public static final String KEY_VERTICAL_ANCHOR = "SnapToGuides.VerticalAttachment"; //$NON-NLS-1$ /** * The key used to identify the horizontal anchor point. This key is used * with the request's extended data map to store an Integer. If the * HORIZONTAL_GUIDE has been set, then this integer is a number identifying * which side of the dragged object is being snapped to that guide. *
      *
    • -1 indicates the top side should be attached. *
    • 0 indicates the middle should be attached. *
    • 1 indicates the bottom side should be attached. *
    */ public static final String KEY_HORIZONTAL_ANCHOR = "SnapToGuides.HorizontalAttachment";//$NON-NLS-1$ /** * The threshold for snapping to guides. The rectangle being snapped must be * within +/- the THRESHOLD. The default value is 5.001; */ protected static final double THRESHOLD = 5.001; private double threshold = THRESHOLD; /** * The graphical editpart to which guides are relative. This should also the * parent of the parts being snapped to guides. */ protected GraphicalEditPart container; /** * The locations of the vertical guides in the container's coordinates. Use * {@link #getVerticalGuides()}. */ protected int[] verticalGuides; /** * The locations of the horizontal guides in the container's coordinates. * Use {@link #getHorizontalGuides()}. */ protected int[] horizontalGuides; /** * Constructs a new snap-to-guides helper using the given container as the * basis. * * @param container * the container editpart */ public SnapToGuides(GraphicalEditPart container) { this.container = container; } /** * Get the sensitivity of the snapping. Corrections greater than this value * will not occur. * * @return the snapping threshold * @since 3.4 */ protected double getThreshold() { return this.threshold; } /** * Set the sensitivity of the snapping. * * @see #getThreshold() * @param newThreshold * the new snapping threshold * @since 3.4 */ protected void setThreshold(double newThreshold) { this.threshold = newThreshold; } /** * Returns the correction for the given near and far sides of a rectangle or * {@link #getThreshold()} if no correction was found. The near side * represents the top or left side of a rectangle being snapped. Similar for * far. If snapping occurs, the extendedData will have the guide and * attachment point set. * * @param guides * the location of the guides * @param near * the top or left location * @param far * the bottom or right location * @param extendedData * the map for storing snap details * @param isVertical * true if for vertical guides, false * for horizontal. * @return the correction amount or getThreshold() if no correction was made */ protected double getCorrectionFor(int[] guides, double near, double far, Map extendedData, boolean isVertical) { far -= 1.0; double total = near + far; // If the width is even, there is no middle pixel so favor the left - // most pixel. if ((int) (near - far) % 2 == 0) total -= 1.0; double result = getCorrectionFor(guides, total / 2, extendedData, isVertical, 0); if (result == getThreshold()) result = getCorrectionFor(guides, near, extendedData, isVertical, -1); if (result == getThreshold()) result = getCorrectionFor(guides, far, extendedData, isVertical, 1); return result; } /** * Returns the correction for the given location or {@link #getThreshold()} * if no correction was found. If correction occurs, the extendedData will * have the guide and attachment point set. The attachment point is * identified by the side parameter. *

    * The correction's magnitude will be less than getThreshold(). * * @param guides * the location of the guides * @param value * the location being tested * @param extendedData * the map for storing snap details * @param vert * true if for vertical guides, false * @param side * the integer indicating which side is being snapped * @return a correction amount or getThreshold() if no correction was made */ protected double getCorrectionFor(int[] guides, double value, Map extendedData, boolean vert, int side) { double resultMag = getThreshold(); double result = getThreshold(); for (int i = 0; i < guides.length; i++) { int offset = guides[i]; double magnitude; magnitude = Math.abs(value - offset); if (magnitude < resultMag) { extendedData.put(vert ? KEY_VERTICAL_GUIDE : KEY_HORIZONTAL_GUIDE, new Integer(guides[i])); extendedData.put(vert ? KEY_VERTICAL_ANCHOR : KEY_HORIZONTAL_ANCHOR, new Integer(side)); resultMag = magnitude; result = offset - value; } } return result; } /** * Returns the horizontal guides in the coordinates of the container's * contents pane. * * @return the horizontal guides */ protected int[] getHorizontalGuides() { if (horizontalGuides == null) { RulerProvider rProvider = ((RulerProvider) container.getViewer() .getProperty(RulerProvider.PROPERTY_VERTICAL_RULER)); if (rProvider != null) horizontalGuides = rProvider.getGuidePositions(); else horizontalGuides = new int[0]; } return horizontalGuides; } /** * Returns the vertical guides in the coordinates of the container's * contents pane. * * @return the vertical guides */ protected int[] getVerticalGuides() { if (verticalGuides == null) { RulerProvider rProvider = ((RulerProvider) container.getViewer() .getProperty(RulerProvider.PROPERTY_HORIZONTAL_RULER)); if (rProvider != null) verticalGuides = rProvider.getGuidePositions(); else verticalGuides = new int[0]; } return verticalGuides; } /** * @see SnapToHelper#snapRectangle(Request, int, PrecisionRectangle, * PrecisionRectangle) */ public int snapRectangle(Request request, int snapOrientation, PrecisionRectangle baseRect, PrecisionRectangle result) { if (request instanceof GroupRequest && ((GroupRequest) request).getEditParts().size() > 1) return snapOrientation; baseRect = baseRect.getPreciseCopy(); makeRelative(container.getContentPane(), baseRect); PrecisionRectangle correction = new PrecisionRectangle(); makeRelative(container.getContentPane(), correction); if ((snapOrientation & HORIZONTAL) != 0) { double xcorrect = getCorrectionFor(getVerticalGuides(), baseRect.preciseX(), baseRect.preciseRight(), request.getExtendedData(), true); if (xcorrect != getThreshold()) { snapOrientation &= ~HORIZONTAL; correction.setPreciseX(correction.preciseX() + xcorrect); } } if ((snapOrientation & VERTICAL) != 0) { double ycorrect = getCorrectionFor(getHorizontalGuides(), baseRect.preciseY(), baseRect.preciseBottom(), request.getExtendedData(), false); if (ycorrect != getThreshold()) { snapOrientation &= ~VERTICAL; correction.setPreciseY(correction.preciseY() + ycorrect); } } boolean snapped = false; if (!snapped && (snapOrientation & WEST) != 0) { double leftCorrection = getCorrectionFor(getVerticalGuides(), baseRect.preciseX(), request.getExtendedData(), true, -1); if (leftCorrection != getThreshold()) { snapOrientation &= ~WEST; correction.setPreciseWidth(correction.preciseWidth() - leftCorrection); correction.setPreciseX(correction.preciseX() + leftCorrection); } } if (!snapped && (snapOrientation & EAST) != 0) { double rightCorrection = getCorrectionFor(getVerticalGuides(), baseRect.preciseRight() - 1, request.getExtendedData(), true, 1); if (rightCorrection != getThreshold()) { snapped = true; snapOrientation &= ~EAST; correction.setPreciseWidth(correction.preciseWidth() + rightCorrection); } } snapped = false; if (!snapped && (snapOrientation & NORTH) != 0) { double topCorrection = getCorrectionFor(getHorizontalGuides(), baseRect.preciseY(), request.getExtendedData(), false, -1); if (topCorrection != getThreshold()) { snapOrientation &= ~NORTH; correction.setPreciseHeight(correction.preciseHeight() - topCorrection); correction.setPreciseY(correction.preciseY() + topCorrection); } } if (!snapped && (snapOrientation & SOUTH) != 0) { double bottom = getCorrectionFor(getHorizontalGuides(), baseRect.preciseBottom() - 1, request.getExtendedData(), false, 1); if (bottom != getThreshold()) { snapped = true; snapOrientation &= ~SOUTH; correction .setPreciseHeight(correction.preciseHeight() + bottom); } } makeAbsolute(container.getContentPane(), correction); result.setPreciseX(result.preciseX() + correction.preciseX()); result.setPreciseY(result.preciseY() + correction.preciseY()); result.setPreciseWidth(result.preciseWidth() + correction.preciseWidth()); result.setPreciseHeight(result.preciseHeight() + correction.preciseHeight()); return snapOrientation; } } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/SnapToHelper.java000066400000000000000000000163671166301720600256500ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.PositionConstants; import org.eclipse.draw2d.geometry.PrecisionPoint; import org.eclipse.draw2d.geometry.PrecisionRectangle; import org.eclipse.draw2d.geometry.Translatable; /** * A helper used temporarily by Tools for snapping certain mouse interactions. * SnapToHelpers should not be reused by tools or by the editparts which provide * them to the tools. For example, for a move operation, the life-cycle of a * SnapToHelper begins when a drag is initiated, and ends when the drag is over. * If another drag is initiated right after the first one is completed, new * SnapToHelpers are employed. This means that helpers can assume that * everything else is static, and there is no need to track changes outside of * the helper. * * @since 3.0 * @author Randy Hudson * @author Pratik Shah */ public abstract class SnapToHelper implements PositionConstants { /** * Translates from a given figure to absolute coordinates. * * @param figure * the reference figure * @param t * the object to translate */ protected void makeAbsolute(IFigure figure, Translatable t) { figure.translateToAbsolute(t); } /** * Translates from absolute to coordinates relative to the given figure. * * @param figure * the reference figure * @param t * the object to translate */ protected void makeRelative(IFigure figure, Translatable t) { figure.translateToRelative(t); } /** * Applies a snapping correction to the given result. Snapping can occur in * the four primary directions: NORTH, SOUTH, EAST, WEST, as defined on * {@link PositionConstants}. By default a Point is treated as an empty * Rectangle. Only NORTH and WEST should be used in general. But SOUTH and * EAST may also be used. Similarly, VERTICAL and HORIZONTAL may be used to * allow a point to snap to the "center" or "middle" as defined by the * concrete subclass. *

    * The returned value should be a subset of the given snapDirections based * on what correction was applied to the result. e.g., if the x value * was adjusted, the returned value should not contain WEST, EAST, or * HORIZONTAL. *

    * All coordinate information received and returned by this method should be * in absolute coordinates. * * @param request * a request or null * @param snapDirections * the directions in which snapping should occur. * @param where * the rectangle used to determine snapping * @param result * the result * @return the remaining snap locations */ public int snapPoint(Request request, int snapDirections, PrecisionPoint where, PrecisionPoint result) { PrecisionRectangle rect = new PrecisionRectangle(); PrecisionRectangle resultRect = new PrecisionRectangle(); rect.setPreciseX(where.preciseX()); rect.setPreciseY(where.preciseY()); snapDirections = snapRectangle(request, snapDirections, rect, resultRect); result.setPreciseX(result.preciseX() + resultRect.preciseX()); result.setPreciseY(result.preciseY() + resultRect.preciseY()); return snapDirections; } /** * A convenience method for snapping a Point based on an array of * rectangles. By default, this method will construct an empty rectangle at * the same locations as the provided point, and call * {@link #snapRectangle(Request, int, PrecisionRectangle[], PrecisionRectangle)} * . The intended usage of this method is when dragging one or more parts in * a diagram. *

    * The returned value should be a subset of the given snapDirections based * on what correction was applied to the result. e.g., if the x value * was adjusted, the returned value should not contain WEST, EAST, or * HORIZONTAL. *

    * All coordinate information received and returned by this method should be * in absolute coordinates. * * @param request * the request or null * @param snapLocations * the types of snapping to perform * @param rects * an array of one or more rectangles used to perform the * snapping * @param result * the correction will be applied to this point * @return the remaining snap locations */ public int snapPoint(Request request, int snapLocations, PrecisionRectangle rects[], PrecisionPoint result) { PrecisionRectangle resultRect = new PrecisionRectangle(); snapLocations = snapRectangle(request, snapLocations, rects, resultRect); result.setPreciseX(result.preciseX() + resultRect.preciseX()); result.setPreciseY(result.preciseY() + resultRect.preciseY()); return snapLocations; } /** * A convenience method for snapping a Rectangle based on one or more * rectangles. This method will call * {@link #snapRectangle(Request, int, PrecisionRectangle, PrecisionRectangle)} * for each rectangle in the array or until no more snap locations remain. *

    * All coordinate information received and returned by this method should be * in absolute coordinates. * * @param request * the request or null * @param baseRects * the prioritized rectangles to snap to * @param result * the output * @param snapOrientation * the input snap locations * @return the remaining snap locations */ public int snapRectangle(Request request, int snapOrientation, PrecisionRectangle baseRects[], PrecisionRectangle result) { for (int i = 0; i < baseRects.length && snapOrientation != 0; i++) snapOrientation = snapRectangle(request, snapOrientation, baseRects[i], result); return snapOrientation; } /** * Applies a snap correction to a Rectangle based on a given Rectangle. The * provided baseRect will be used as a reference for snapping. The types of * snapping to be performed are indicated by the snapOrientation parameter. * The correction is applied to the result field. *

    * The baseRect is not modified. The correction is applied to the result. * The request's {@link Request#getExtendedData() extended data} may contain * additional information about the snapping which was performed. *

    * All coordinate information received and returned by this method should be * in absolute coordinates. * * @since 3.0 * @param request * the request or null * @param baseRect * the input rectangle * @param result * the correction is applied to this rectangle * @param snapOrientation * the input snap locations * @return the remaining snap locations */ public abstract int snapRectangle(Request request, int snapOrientation, PrecisionRectangle baseRect, PrecisionRectangle result); } eclipse-gef-3.7.1/org.eclipse.gef/src/org/eclipse/gef/Tool.java000066400000000000000000000223661166301720600242150ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.gef; import java.util.Map; import org.eclipse.swt.dnd.DragSourceEvent; import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseTrackListener; import org.eclipse.swt.events.TraverseEvent; import org.eclipse.swt.widgets.Event; /** * A Tool interprets Mouse and Keyboard input from an * {@link EditDomain} and its {@link EditPartViewer EditPartViewers}. The active * Tool and its state determines how the EditDomain will interpret input. Input * flows from a Viewer, to the EditDomain, to the EditDomain's active Tool. *

    * Tools process low-level events and turn them into higher-level * operations. These operations are encapsulated by {@link Request Requests}. * The Requests are then used to communicate with EditParts in the Viewer to * perform the User's operation. Using Requests, Tools will: *