diff -Nru libjlatexmath-java-0.9.6/build.xml libjlatexmath-java-0.9.7/build.xml --- libjlatexmath-java-0.9.6/build.xml 2011-05-08 18:07:16.000000000 +0000 +++ libjlatexmath-java-0.9.7/build.xml 2011-11-22 17:18:16.000000000 +0000 @@ -47,8 +47,17 @@ + + + + + + + + + @@ -158,13 +167,14 @@ - - + + + - + @@ -180,14 +190,14 @@ - + - + @@ -203,11 +213,11 @@ - + - + diff -Nru libjlatexmath-java-0.9.6/debian/changelog libjlatexmath-java-0.9.7/debian/changelog --- libjlatexmath-java-0.9.6/debian/changelog 2011-12-08 20:31:01.000000000 +0000 +++ libjlatexmath-java-0.9.7/debian/changelog 2011-12-19 21:24:16.000000000 +0000 @@ -1,3 +1,9 @@ +libjlatexmath-java (0.9.7-1) unstable; urgency=low + + * New upstream release + + -- Sylvestre Ledru Mon, 19 Dec 2011 22:24:07 +0100 + libjlatexmath-java (0.9.6-2) unstable; urgency=low [ Giovanni Mascellani ] diff -Nru libjlatexmath-java-0.9.6/examples/Basic/Example2.java libjlatexmath-java-0.9.7/examples/Basic/Example2.java --- libjlatexmath-java-0.9.6/examples/Basic/Example2.java 2011-05-08 17:42:04.000000000 +0000 +++ libjlatexmath-java-0.9.7/examples/Basic/Example2.java 2011-12-19 19:20:12.000000000 +0000 @@ -61,13 +61,10 @@ latex += "\\begin{array}{rl} s &= \\int_a^b\\left\\|\\frac{d}{dt}\\vec{r}\\,(u(t),v(t))\\right\\|\\,dt \\\\ &= \\int_a^b \\sqrt{u'(t)^2\\,\\vec{r}_u\\cdot\\vec{r}_u + 2u'(t)v'(t)\\, \\vec{r}_u\\cdot\\vec{r}_v+ v'(t)^2\\,\\vec{r}_v\\cdot\\vec{r}_v}\\,\\,\\, dt. \\end{array}\\\\"; latex += "\\end{array}"; - latex = "copyright\\copyright A\\degree\\textcircled{\\raisebox{0.2ex}{c}}"; - - TeXFormula formula = new TeXFormula(true, latex); + TeXFormula formula = new TeXFormula(latex); TeXIcon icon = formula.createTeXIcon(TeXConstants.STYLE_DISPLAY, 20); icon.setInsets(new Insets(5, 5, 5, 5)); - BufferedImage image = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = image.createGraphics(); g2.setColor(Color.white); diff -Nru libjlatexmath-java-0.9.6/LICENSE libjlatexmath-java-0.9.7/LICENSE --- libjlatexmath-java-0.9.6/LICENSE 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/LICENSE 2011-11-22 17:18:16.000000000 +0000 @@ -3,7 +3,7 @@ many more LaTeX commands, drop of the jdom dependency and easy evolution capabilities. -Copyright (C) 2009 DENIZET Calixte +Copyright (C) 2009-2011 DENIZET Calixte Copyright (C) Kris Coolsaet Copyright (C) Nico Van Cleemput Copyright (C) Kurt Vermeulen @@ -22,7 +22,8 @@ You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +MA 02110-1301, USA. @@ -35,4 +36,8 @@ 4) the fonts cmbsy10.ttf, cmbx10.ttf, cmbxti10.ttf, cmex10.ttf, cmmi10.ttf, cmr10.ttf, cmss10.ttf, cmssbx10.ttf, cmsy10.ttf and cmtt10.ttf are under Knuth License. -You can find a copy of these licenses in the fonts directory. +5) the greek fonts fcmbipg.ttf, fcmripg.tff, fcmrpg.ttf, fcsropg.ttf, fcmbpg.ttf, fcsbpg.ttf, fctrpg.ttf, fcsrpg.ttf are under GNU GPL version 2. + +6) the cyrillic fonts wnbx10.ttf, wnss10.ttf, wnti10.ttf, wnr10.ttf, wnssi10.ttf, wnbxti10.ttf, wnssbx10.ttf, wntt10.ttf are under Knuth License. + +You can find a copy of these licenses in org/scilab/forge/jlatexmath/fonts/licences. \ No newline at end of file diff -Nru libjlatexmath-java-0.9.6/plugin/fop/dist/build.xml libjlatexmath-java-0.9.7/plugin/fop/dist/build.xml --- libjlatexmath-java-0.9.6/plugin/fop/dist/build.xml 2011-05-08 18:16:46.000000000 +0000 +++ libjlatexmath-java-0.9.7/plugin/fop/dist/build.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,105 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -Nru libjlatexmath-java-0.9.6/plugin/fop/dist/COPYING libjlatexmath-java-0.9.7/plugin/fop/dist/COPYING --- libjlatexmath-java-0.9.6/plugin/fop/dist/COPYING 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/plugin/fop/dist/COPYING 1970-01-01 00:00:00.000000000 +0000 @@ -1,280 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS diff -Nru libjlatexmath-java-0.9.6/plugin/fop/dist/examples/conf.xml libjlatexmath-java-0.9.7/plugin/fop/dist/examples/conf.xml --- libjlatexmath-java-0.9.6/plugin/fop/dist/examples/conf.xml 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/plugin/fop/dist/examples/conf.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,158 +0,0 @@ - - - - - - - - - - - . - - - 72 - - 72 - - - - - - - - - - - flate - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Binary files /tmp/Cwu3pjs0fn/libjlatexmath-java-0.9.6/plugin/fop/dist/examples/latex_docbook.pdf and /tmp/LIIfw1myf3/libjlatexmath-java-0.9.7/plugin/fop/dist/examples/latex_docbook.pdf differ diff -Nru libjlatexmath-java-0.9.6/plugin/fop/dist/examples/latex_docbook.xml libjlatexmath-java-0.9.7/plugin/fop/dist/examples/latex_docbook.xml --- libjlatexmath-java-0.9.6/plugin/fop/dist/examples/latex_docbook.xml 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/plugin/fop/dist/examples/latex_docbook.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,116 +0,0 @@ - - - Very simple book with mathematical formulas - - <latex xmlns="http://forge.scilab.org/p/jlatexmath">\JLaTeXMath</latex> - - The Java package \JLaTeXMath combining with FOP gives the possibility to write \LaTeX commands in Docbook. - - - This example has been written in using the CM Unicode fonts available at http://sourceforge.net/projects/cm-unicode/ . - - - For example : - - - - - - - - We can use an example block : - - - - - - - - The formulas can be in displaystyle \sum_{n=1}^{+\infty}\frac1{n^2}=\frac{\pi^2}{6} or in textstyle \sum_{n=1}^{+\infty}\frac1{n^2}=\frac{\pi^2}{6}. - - - - Several centered formulas with gather environment : - - - - - - - - Several formulas with flalign environment : - - - - - - - - Several formulas with split environment : - - - - - - - - Splitting a long formula on several lines with multline environment : - - - - - - - - An array with vertical and horizontal lines and different sizes of font : - - - - - - - - diff -Nru libjlatexmath-java-0.9.6/plugin/fop/dist/examples/latex.fo libjlatexmath-java-0.9.7/plugin/fop/dist/examples/latex.fo --- libjlatexmath-java-0.9.6/plugin/fop/dist/examples/latex.fo 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/plugin/fop/dist/examples/latex.fo 1970-01-01 00:00:00.000000000 +0000 @@ -1,96 +0,0 @@ - - - - - - - - - - - - \JLaTeXMath Extension - - - Page - - - - The \JLaTeXMath Extension - - -The \JLaTeXMath extension is an addition to FOP that can be used to draw \LaTeX expressions. - - - Examples - - -This is a 12pt block with a formula : - - - -\int_0^{+\infty} e^{-x^2}\mathrm{d}x=\frac{\sqrt\pi}{2} - - - -But you can prefer a red block with a font set to 15pt: - - - - - - - -An other one: - - - - - - - -Another formula with a \mathfrak : - - - - - - - -But you can prefer a formula in the text - - - - - -in \displaystyle or in \textstyle - - - - - - - - - - - Binary files /tmp/Cwu3pjs0fn/libjlatexmath-java-0.9.6/plugin/fop/dist/examples/latex.pdf and /tmp/LIIfw1myf3/libjlatexmath-java-0.9.7/plugin/fop/dist/examples/latex.pdf differ diff -Nru libjlatexmath-java-0.9.6/plugin/fop/dist/examples/latex.xsl libjlatexmath-java-0.9.7/plugin/fop/dist/examples/latex.xsl --- libjlatexmath-java-0.9.6/plugin/fop/dist/examples/latex.xsl 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/plugin/fop/dist/examples/latex.xsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ - - - - - -CMUSerif-Roman -CMUSansSerif - -CMUTypewriter-Regular - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Binary files /tmp/Cwu3pjs0fn/libjlatexmath-java-0.9.6/plugin/fop/dist/examples/times.pdf and /tmp/LIIfw1myf3/libjlatexmath-java-0.9.7/plugin/fop/dist/examples/times.pdf differ Binary files /tmp/Cwu3pjs0fn/libjlatexmath-java-0.9.6/plugin/fop/dist/examples/toto.pdf and /tmp/LIIfw1myf3/libjlatexmath-java-0.9.7/plugin/fop/dist/examples/toto.pdf differ diff -Nru libjlatexmath-java-0.9.6/plugin/fop/dist/LICENSE libjlatexmath-java-0.9.7/plugin/fop/dist/LICENSE --- libjlatexmath-java-0.9.6/plugin/fop/dist/LICENSE 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/plugin/fop/dist/LICENSE 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -JLaTeXMath-FOP Library - Enables inclusion of LaTeX formulas in fo. - -Copyright (C) 2010 DENIZET Calixte - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. diff -Nru libjlatexmath-java-0.9.6/plugin/fop/dist/MANIFEST.MF libjlatexmath-java-0.9.7/plugin/fop/dist/MANIFEST.MF --- libjlatexmath-java-0.9.6/plugin/fop/dist/MANIFEST.MF 2011-05-08 13:53:12.000000000 +0000 +++ libjlatexmath-java-0.9.7/plugin/fop/dist/MANIFEST.MF 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -Class-Path: jlatexmath.jar diff -Nru libjlatexmath-java-0.9.6/plugin/fop/dist/src/META-INF/services/org.apache.fop.fo.ElementMapping libjlatexmath-java-0.9.7/plugin/fop/dist/src/META-INF/services/org.apache.fop.fo.ElementMapping --- libjlatexmath-java-0.9.6/plugin/fop/dist/src/META-INF/services/org.apache.fop.fo.ElementMapping 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/plugin/fop/dist/src/META-INF/services/org.apache.fop.fo.ElementMapping 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -org.scilab.forge.jlatexmath.fop.JLaTeXMathElementMapping \ No newline at end of file diff -Nru libjlatexmath-java-0.9.6/plugin/fop/dist/src/META-INF/services/org.apache.fop.render.XMLHandler libjlatexmath-java-0.9.7/plugin/fop/dist/src/META-INF/services/org.apache.fop.render.XMLHandler --- libjlatexmath-java-0.9.6/plugin/fop/dist/src/META-INF/services/org.apache.fop.render.XMLHandler 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/plugin/fop/dist/src/META-INF/services/org.apache.fop.render.XMLHandler 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -org.scilab.forge.jlatexmath.fop.JLaTeXMathXMLHandler diff -Nru libjlatexmath-java-0.9.6/plugin/fop/dist/src/META-INF/services/org.apache.xmlgraphics.image.loader.spi.ImageConverter libjlatexmath-java-0.9.7/plugin/fop/dist/src/META-INF/services/org.apache.xmlgraphics.image.loader.spi.ImageConverter --- libjlatexmath-java-0.9.6/plugin/fop/dist/src/META-INF/services/org.apache.xmlgraphics.image.loader.spi.ImageConverter 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/plugin/fop/dist/src/META-INF/services/org.apache.xmlgraphics.image.loader.spi.ImageConverter 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -org.scilab.forge.jlatexmath.fop.image.loader.ImageConverterJLaTeXMathToG2D \ No newline at end of file diff -Nru libjlatexmath-java-0.9.6/plugin/fop/dist/src/META-INF/services/org.apache.xmlgraphics.image.loader.spi.ImageLoaderFactory libjlatexmath-java-0.9.7/plugin/fop/dist/src/META-INF/services/org.apache.xmlgraphics.image.loader.spi.ImageLoaderFactory --- libjlatexmath-java-0.9.6/plugin/fop/dist/src/META-INF/services/org.apache.xmlgraphics.image.loader.spi.ImageLoaderFactory 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/plugin/fop/dist/src/META-INF/services/org.apache.xmlgraphics.image.loader.spi.ImageLoaderFactory 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -org.scilab.forge.jlatexmath.fop.image.loader.ImageLoaderFactoryJLaTeXMath \ No newline at end of file diff -Nru libjlatexmath-java-0.9.6/plugin/fop/dist/src/META-INF/services/org.apache.xmlgraphics.image.loader.spi.ImagePreloader libjlatexmath-java-0.9.7/plugin/fop/dist/src/META-INF/services/org.apache.xmlgraphics.image.loader.spi.ImagePreloader --- libjlatexmath-java-0.9.6/plugin/fop/dist/src/META-INF/services/org.apache.xmlgraphics.image.loader.spi.ImagePreloader 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/plugin/fop/dist/src/META-INF/services/org.apache.xmlgraphics.image.loader.spi.ImagePreloader 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -org.scilab.forge.jlatexmath.fop.image.loader.PreloaderJLaTeXMath diff -Nru libjlatexmath-java-0.9.6/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/image/ImageJLaTeXMath.java libjlatexmath-java-0.9.7/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/image/ImageJLaTeXMath.java --- libjlatexmath-java-0.9.6/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/image/ImageJLaTeXMath.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/image/ImageJLaTeXMath.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -/* ImageJLaTeXMath.java - * ========================================================================= - * This file is part of the JLaTeXMath Library - http://forge.scilab.org/jlatexmath - * - * Copyright (C) 2010 DENIZET Calixte - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * A copy of the GNU General Public License can be found in the file - * LICENSE.txt provided with the source distribution of this program (see - * the META-INF directory in the source jar). This license can also be - * found on the GNU website at http://www.gnu.org/licenses/gpl.html. - * - * If you did not receive a copy of the GNU General Public License along - * with this program, contact the lead developer, or write to the Free - * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - * - */ - -/* This file is largely inspired by files wrote by Jeremias Maerki, - * for the fop plugin of barcode4j available at - * http://barcode4j.sourceforge.net/ - */ - -package org.scilab.forge.jlatexmath.fop.image; - -import org.scilab.forge.jlatexmath.TeXIcon; -import org.scilab.forge.jlatexmath.fop.JLaTeXMathObj; - -import org.apache.xmlgraphics.image.loader.Image; -import org.apache.xmlgraphics.image.loader.ImageFlavor; -import org.apache.xmlgraphics.image.loader.ImageInfo; -import org.apache.xmlgraphics.image.loader.impl.AbstractImage; - -/** - * Image implementation - * @author Calixte DENIZET - */ -public class ImageJLaTeXMath extends AbstractImage { - - public static final ImageFlavor FLAVOR = new ImageFlavor(JLaTeXMathObj.MIME_TYPE); - - private TeXIcon icon; - - public ImageJLaTeXMath(ImageInfo info, TeXIcon icon) { - super(info); - this.icon = icon; - } - - public TeXIcon getIcon() { - return icon; - } - - public boolean isCacheable() { - return true; - } - - public ImageFlavor getFlavor() { - return FLAVOR; - } -} diff -Nru libjlatexmath-java-0.9.6/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/image/loader/Graphics2DImagePainterJLaTeXMath.java libjlatexmath-java-0.9.7/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/image/loader/Graphics2DImagePainterJLaTeXMath.java --- libjlatexmath-java-0.9.6/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/image/loader/Graphics2DImagePainterJLaTeXMath.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/image/loader/Graphics2DImagePainterJLaTeXMath.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -/* Graphics2DImagePainterJLaTeXMath.java - * ========================================================================= - * This file is part of the JLaTeXMath Library - http://forge.scilab.org/jlatexmath - * - * Copyright (C) 2010 DENIZET Calixte - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * A copy of the GNU General Public License can be found in the file - * LICENSE.txt provided with the source distribution of this program (see - * the META-INF directory in the source jar). This license can also be - * found on the GNU website at http://www.gnu.org/licenses/gpl.html. - * - * If you did not receive a copy of the GNU General Public License along - * with this program, contact the lead developer, or write to the Free - * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - * - */ - -/* This file is largely inspired by files wrote by Jeremias Maerki, - * for the fop plugin of barcode4j available at - * http://barcode4j.sourceforge.net/ - */ - -package org.scilab.forge.jlatexmath.fop.image.loader; - -import org.scilab.forge.jlatexmath.TeXIcon; -import org.scilab.forge.jlatexmath.fop.JLaTeXMathElement; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics2D; -import java.awt.geom.Rectangle2D; - -import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; - -/** - * @author Calixte DENIZET - */ -public class Graphics2DImagePainterJLaTeXMath implements Graphics2DImagePainter { - - private Dimension dim; - private TeXIcon icon; - - public Graphics2DImagePainterJLaTeXMath(Document doc) { - Element e = doc.getDocumentElement(); - float size = Float.parseFloat(e.getAttribute("size")); - Color fg = new Color(Integer.parseInt(e.getAttribute("fg"))); - icon = JLaTeXMathElement.calculate(doc, size); - icon.setForeground(fg); - dim = new Dimension((int) (icon.getTrueIconWidth() * 1000), (int) (icon.getTrueIconHeight() * 1000)); - } - - public Graphics2DImagePainterJLaTeXMath(TeXIcon icon) { - this.icon = icon; - dim = new Dimension((int) (icon.getTrueIconWidth() * 1000), (int) (icon.getTrueIconHeight() * 1000)); - } - - public int getDepth() { - return (int) (icon.getTrueIconDepth() * 1000); - } - - public Dimension getImageSize() { - return dim; - } - - public void paint(Graphics2D g2d, Rectangle2D rect2d) { - g2d.scale(rect2d.getWidth() / dim.width * 1000, rect2d.getHeight() / dim.height * 1000); - icon.paintIcon(null, g2d, (int) rect2d.getX(), (int) rect2d.getY()); - } -} diff -Nru libjlatexmath-java-0.9.6/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/image/loader/ImageConverterJLaTeXMathToG2D.java libjlatexmath-java-0.9.7/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/image/loader/ImageConverterJLaTeXMathToG2D.java --- libjlatexmath-java-0.9.6/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/image/loader/ImageConverterJLaTeXMathToG2D.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/image/loader/ImageConverterJLaTeXMathToG2D.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -/* ImageConverterJLaTeXMathToG2D.java - * ========================================================================= - * This file is part of the JLaTeXMath Library - http://forge.scilab.org/jlatexmath - * - * Copyright (C) 2010 DENIZET Calixte - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * A copy of the GNU General Public License can be found in the file - * LICENSE.txt provided with the source distribution of this program (see - * the META-INF directory in the source jar). This license can also be - * found on the GNU website at http://www.gnu.org/licenses/gpl.html. - * - * If you did not receive a copy of the GNU General Public License along - * with this program, contact the lead developer, or write to the Free - * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - * - */ - -/* This file is largely inspired by files wrote by Jeremias Maerki, - * for the fop plugin of barcode4j available at - * http://barcode4j.sourceforge.net/ - */ - -package org.scilab.forge.jlatexmath.fop.image.loader; - -import java.util.Map; - -import org.scilab.forge.jlatexmath.fop.image.ImageJLaTeXMath; - -import org.apache.xmlgraphics.image.loader.Image; -import org.apache.xmlgraphics.image.loader.ImageException; -import org.apache.xmlgraphics.image.loader.ImageFlavor; -import org.apache.xmlgraphics.image.loader.impl.AbstractImageConverter; -import org.apache.xmlgraphics.image.loader.impl.ImageGraphics2D; - -/** - * Convert a LaTeX label to a Graphics2d Painter. - * @author Calixte DENIZET - */ -public class ImageConverterJLaTeXMathToG2D extends AbstractImageConverter { - - /** - * Default Constructor. - */ - public ImageConverterJLaTeXMathToG2D() { } - - /** {@inheritDoc} */ - public Image convert(Image src, Map hints) throws ImageException { - return new ImageGraphics2D(src.getInfo(), new Graphics2DImagePainterJLaTeXMath(((ImageJLaTeXMath) src).getIcon())); - } - - /** {@inheritDoc} */ - public ImageFlavor getSourceFlavor() { - return ImageJLaTeXMath.FLAVOR; - } - - /** {@inheritDoc} */ - public ImageFlavor getTargetFlavor() { - return ImageFlavor.GRAPHICS2D; - } -} diff -Nru libjlatexmath-java-0.9.6/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/image/loader/ImageLoaderFactoryJLaTeXMath.java libjlatexmath-java-0.9.7/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/image/loader/ImageLoaderFactoryJLaTeXMath.java --- libjlatexmath-java-0.9.6/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/image/loader/ImageLoaderFactoryJLaTeXMath.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/image/loader/ImageLoaderFactoryJLaTeXMath.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -/* ImageLoaderFactoryJLaTeXMath.java - * ========================================================================= - * This file is part of the JLaTeXMath Library - http://forge.scilab.org/jlatexmath - * - * Copyright (C) 2010 DENIZET Calixte - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * A copy of the GNU General Public License can be found in the file - * LICENSE.txt provided with the source distribution of this program (see - * the META-INF directory in the source jar). This license can also be - * found on the GNU website at http://www.gnu.org/licenses/gpl.html. - * - * If you did not receive a copy of the GNU General Public License along - * with this program, contact the lead developer, or write to the Free - * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - * - */ - -/* This file is largely inspired by files wrote by Jeremias Maerki, - * for the fop plugin of barcode4j available at - * http://barcode4j.sourceforge.net/ - */ - -package org.scilab.forge.jlatexmath.fop.image.loader; - -import org.scilab.forge.jlatexmath.fop.JLaTeXMathObj; -import org.scilab.forge.jlatexmath.fop.image.ImageJLaTeXMath; - -import org.apache.xmlgraphics.image.loader.ImageFlavor; -import org.apache.xmlgraphics.image.loader.impl.AbstractImageLoaderFactory; -import org.apache.xmlgraphics.image.loader.spi.ImageLoader; - -/** - * @author Calixte DENIZET - */ -public class ImageLoaderFactoryJLaTeXMath extends AbstractImageLoaderFactory { - - private static final ImageFlavor[] FLAVORS = new ImageFlavor[] { ImageJLaTeXMath.FLAVOR }; - private static final String[] MIMES = new String[] { JLaTeXMathObj.MIME_TYPE }; - - /** - * Default Constructor. - */ - public ImageLoaderFactoryJLaTeXMath() { } - - /** {@inheritDoc} */ - public String[] getSupportedMIMETypes() { - return ImageLoaderFactoryJLaTeXMath.MIMES.clone(); - } - - /** {@inheritDoc} */ - public ImageFlavor[] getSupportedFlavors(final String mime) { - return ImageLoaderFactoryJLaTeXMath.FLAVORS.clone(); - } - - /** {@inheritDoc} */ - public ImageLoader newImageLoader(final ImageFlavor targetFlavor) { - return new ImageLoaderJLaTeXMath(targetFlavor); - } - - /** {@inheritDoc} */ - public int getUsagePenalty(final String mime, final ImageFlavor flavor) { - return 0; - } - - /** {@inheritDoc} */ - public boolean isAvailable() { - return true; - } -} diff -Nru libjlatexmath-java-0.9.6/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/image/loader/ImageLoaderJLaTeXMath.java libjlatexmath-java-0.9.7/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/image/loader/ImageLoaderJLaTeXMath.java --- libjlatexmath-java-0.9.6/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/image/loader/ImageLoaderJLaTeXMath.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/image/loader/ImageLoaderJLaTeXMath.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ -/* JLaTeXMathObj.java - * ========================================================================= - * This file is part of the JLaTeXMath Library - http://forge.scilab.org/jlatexmath - * - * Copyright (C) 2010 DENIZET Calixte - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * A copy of the GNU General Public License can be found in the file - * LICENSE.txt provided with the source distribution of this program (see - * the META-INF directory in the source jar). This license can also be - * found on the GNU website at http://www.gnu.org/licenses/gpl.html. - * - * If you did not receive a copy of the GNU General Public License along - * with this program, contact the lead developer, or write to the Free - * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - * - */ - -/* This file is largely inspired by files wrote by Jeremias Maerki, - * for the fop plugin of barcode4j available at - * http://barcode4j.sourceforge.net/ - */ - -package org.scilab.forge.jlatexmath.fop.image.loader; - -import java.io.IOException; -import java.util.Map; - -import org.scilab.forge.jlatexmath.fop.image.ImageJLaTeXMath; - -import org.apache.xmlgraphics.image.loader.Image; -import org.apache.xmlgraphics.image.loader.ImageException; -import org.apache.xmlgraphics.image.loader.ImageFlavor; -import org.apache.xmlgraphics.image.loader.ImageInfo; -import org.apache.xmlgraphics.image.loader.ImageSessionContext; -import org.apache.xmlgraphics.image.loader.impl.AbstractImageLoader; -import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM; - -import org.scilab.forge.jlatexmath.fop.JLaTeXMathObj; - -public class ImageLoaderJLaTeXMath extends AbstractImageLoader { - - private final ImageFlavor targetFlavor; - - /** - * Main constructor. - */ - public ImageLoaderJLaTeXMath(final ImageFlavor target) { - if (!(ImageJLaTeXMath.FLAVOR.equals(target))) { - throw new IllegalArgumentException("Unsupported target ImageFlavor: " + target); - } - this.targetFlavor = target; - } - - /** {@inheritDoc} */ - public ImageFlavor getTargetFlavor() { - return this.targetFlavor; - } - - /** {@inheritDoc} */ - public Image loadImage(ImageInfo info, Map hints, ImageSessionContext session) throws ImageException, IOException { - if (!JLaTeXMathObj.MIME_TYPE.equals(info.getMimeType())) { - throw new IllegalArgumentException("ImageInfo must be from an LaTeX image"); - } - - final Image img = info.getOriginalImage(); - if (!(img instanceof ImageJLaTeXMath)) { - throw new IllegalArgumentException("ImageInfo was expected to contain the JLaTeXMath image"); - } - - ImageJLaTeXMath jlmImage = (ImageJLaTeXMath) img; - - return jlmImage; - } -} diff -Nru libjlatexmath-java-0.9.6/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/image/loader/PreloaderJLaTeXMath.java libjlatexmath-java-0.9.7/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/image/loader/PreloaderJLaTeXMath.java --- libjlatexmath-java-0.9.6/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/image/loader/PreloaderJLaTeXMath.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/image/loader/PreloaderJLaTeXMath.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,97 +0,0 @@ -/* PreloaderJLaTeXMath.java - * ========================================================================= - * This file is part of the JLaTeXMath Library - http://forge.scilab.org/jlatexmath - * - * Copyright (C) 2010 DENIZET Calixte - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * A copy of the GNU General Public License can be found in the file - * LICENSE.txt provided with the source distribution of this program (see - * the META-INF directory in the source jar). This license can also be - * found on the GNU website at http://www.gnu.org/licenses/gpl.html. - * - * If you did not receive a copy of the GNU General Public License along - * with this program, contact the lead developer, or write to the Free - * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - * - */ - -/* This file is largely inspired by files wrote by Jeremias Maerki, - * for the fop plugin of barcode4j available at - * http://barcode4j.sourceforge.net/ - */ - -package org.scilab.forge.jlatexmath.fop.image.loader; - -import java.awt.Color; - -import javax.xml.transform.Source; -import javax.xml.transform.dom.DOMSource; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -import org.scilab.forge.jlatexmath.TeXIcon; -import org.scilab.forge.jlatexmath.fop.JLaTeXMathObj; -import org.scilab.forge.jlatexmath.fop.JLaTeXMathElement; -import org.scilab.forge.jlatexmath.fop.image.ImageJLaTeXMath; - -import org.apache.xmlgraphics.image.loader.ImageContext; -import org.apache.xmlgraphics.image.loader.ImageInfo; -import org.apache.xmlgraphics.image.loader.ImageSize; -import org.apache.xmlgraphics.image.loader.impl.AbstractImagePreloader; - -/** - * Preloader - * @author Calixte DENIZET - */ -public class PreloaderJLaTeXMath extends AbstractImagePreloader { - - public PreloaderJLaTeXMath() { } - - /** {@inheritDoc} */ - public ImageInfo preloadImage(String uri, Source src, ImageContext context) { - Document doc; - Element e; - if (src instanceof DOMSource) { - doc = (Document) ((DOMSource) src).getNode(); - e = doc.getDocumentElement(); - } - else { - return null; - } - - if (e.getTagName() != "latex") { - return null; - } - - ImageInfo info = new ImageInfo(uri, JLaTeXMathObj.MIME_TYPE); - ImageSize size = new ImageSize(); - - float s = Float.parseFloat(e.getAttribute("size")); - Color fg = new Color(Integer.parseInt(e.getAttribute("fg"))); - TeXIcon icon = JLaTeXMathElement.calculate(doc, s); - icon.setForeground(fg); - - size.setSizeInMillipoints((int) (icon.getTrueIconWidth() * 1000), (int) (icon.getTrueIconHeight() * 1000)); - size.setBaselinePositionFromBottom((int) (icon.getTrueIconDepth() * 1000)); - size.setResolution(context.getSourceResolution()); - size.calcPixelsFromSize(); - info.setSize(size); - - ImageJLaTeXMath jlmImage = new ImageJLaTeXMath(info, icon); - info.getCustomObjects().put(ImageInfo.ORIGINAL_IMAGE, jlmImage); - - return info; - } -} diff -Nru libjlatexmath-java-0.9.6/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/JLaTeXMathElement.java libjlatexmath-java-0.9.7/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/JLaTeXMathElement.java --- libjlatexmath-java-0.9.6/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/JLaTeXMathElement.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/JLaTeXMathElement.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,172 +0,0 @@ -/* JLaTeXMathElement.java - * ========================================================================= - * This file is part of the JLaTeXMath Library - http://forge.scilab.org/jlatexmath - * - * Copyright (C) 2010 DENIZET Calixte - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * A copy of the GNU General Public License can be found in the file - * LICENSE.txt provided with the source distribution of this program (see - * the META-INF directory in the source jar). This license can also be - * found on the GNU website at http://www.gnu.org/licenses/gpl.html. - * - * If you did not receive a copy of the GNU General Public License along - * with this program, contact the lead developer, or write to the Free - * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - * - */ - -/* This file is largely inspired by files wrote by Jeremias Maerki, - * for the fop plugin of barcode4j available at - * http://barcode4j.sourceforge.net/ - */ - -package org.scilab.forge.jlatexmath.fop; - -import org.scilab.forge.jlatexmath.TeXIcon; -import org.scilab.forge.jlatexmath.TeXConstants; -import org.scilab.forge.jlatexmath.TeXFormula; -import org.scilab.forge.jlatexmath.SpaceAtom; - -import java.awt.Color; -import java.awt.geom.Point2D; -import java.util.List; -import java.util.LinkedList; -import java.util.StringTokenizer; - -import org.apache.fop.apps.FOPException; -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.datatypes.Length; -import org.apache.fop.fo.FOEventHandler; -import org.apache.fop.fo.FONode; -import org.apache.fop.fo.XMLObj; -import org.apache.fop.fo.PropertyList; -import org.apache.fop.fo.properties.CommonFont; -import org.apache.fop.fo.properties.FixedLength; -import org.apache.fop.fo.properties.Property; -import org.apache.fop.fo.properties.PercentLength; -import org.apache.fop.datatypes.LengthBase; -import org.apache.fop.fo.properties.LengthProperty; -import org.apache.fop.fo.flow.BlockContainer; -import org.apache.fop.fo.FONode; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.xml.sax.Attributes; -import org.xml.sax.Locator; - -public class JLaTeXMathElement extends JLaTeXMathObj { - - private float size; - private Color fg; - private TeXIcon icon = null; - private boolean bool = true; - private String PR_COLOR = "PR_COLOR"; - - public JLaTeXMathElement(FONode parent) { - super(parent); - } - - public void processNode(final String elementName, final Locator locator, - final Attributes attlist, final PropertyList propertyList) - throws FOPException { - super.processNode(elementName, locator, attlist, propertyList); - Element e = createBasicDocument().getDocumentElement(); - e.setAttribute("size", "" + size); - e.setAttribute("fg", "" + fg.getRGB()); - } - - public Point2D getDimension(Point2D p) { - if (icon == null) { - icon = calculate(doc, size); - } - return new Point2D.Float(icon.getTrueIconWidth(), icon.getTrueIconHeight()); - } - - public Length getIntrinsicAlignmentAdjust() { - if (icon == null) { - icon = calculate(doc, size); - } - return FixedLength.getInstance(-icon.getTrueIconDepth(), "px"); - } - - public static float getFWidth(String str) { - StringTokenizer tok = new StringTokenizer(str, ","); - int sum = 0; - while (tok.hasMoreTokens()) { - int i = 0; - String s = tok.nextToken(); - for (; i < s.length() && !Character.isLetter(s.charAt(i)); i++); - double w = 0; - try { - w = Double.parseDouble(s.substring(0, i)); - } catch (NumberFormatException e) { - return 0.0f; - } - - String unit = "px"; - if (i != s.length()) { - unit = s.substring(i).toLowerCase(); - } - - sum += FixedLength.getInstance(w, unit).getValue(); - } - - return (float) (sum / 1000f); - } - - public static TeXIcon calculate(Document doc, float size) { - TeXIcon icon; - Element e = doc.getDocumentElement(); - String code = e.getTextContent(); - String style = e.getAttribute("style"); - int st = TeXConstants.STYLE_DISPLAY; - if ("text".equals(style)) { - st = TeXConstants.STYLE_TEXT; - } else if ("script".equals(style)) { - st = TeXConstants.STYLE_SCRIPT; - } else if ("script_script".equals(style)) { - st = TeXConstants.STYLE_SCRIPT_SCRIPT; - } - - String stfw = e.getAttribute("fwidth"); - - if (stfw.length() != 0) { - icon = new TeXFormula(code).createTeXIcon(st, size, TeXConstants.UNIT_PIXEL, getFWidth(stfw), TeXConstants.ALIGN_CENTER); - } else { - icon = new TeXFormula(code).createTeXIcon(st, size, true); - } - - return icon; - } - - protected PropertyList createPropertyList(final PropertyList pList, - final FOEventHandler foEventHandler) throws FOPException { - FOUserAgent userAgent = this.getUserAgent(); - CommonFont commonFont = pList.getFontProps(); - this.size = (float) commonFont.fontSize.getNumericValue() / 1000; - - int n = org.apache.fop.fo.Constants.PR_COLOR; - try { - n = org.apache.fop.fo.Constants.class.getDeclaredField(PR_COLOR).getInt(null); - } catch (Exception e) { - System.err.println("Error in getting field:\n" + e); - } - - Property colorProp = pList.get(n); - - this.fg = colorProp != null ? colorProp.getColor(userAgent) : null; - - return super.createPropertyList(pList, foEventHandler); - } -} \ No newline at end of file diff -Nru libjlatexmath-java-0.9.6/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/JLaTeXMathElementMapping.java libjlatexmath-java-0.9.7/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/JLaTeXMathElementMapping.java --- libjlatexmath-java-0.9.6/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/JLaTeXMathElementMapping.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/JLaTeXMathElementMapping.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ -/* JLaTeXMathElementMapping.java - * ========================================================================= - * This file is part of the JLaTeXMath Library - http://forge.scilab.org/jlatexmath - * - * Copyright (C) 2010 DENIZET Calixte - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * A copy of the GNU General Public License can be found in the file - * LICENSE.txt provided with the source distribution of this program (see - * the META-INF directory in the source jar). This license can also be - * found on the GNU website at http://www.gnu.org/licenses/gpl.html. - * - * If you did not receive a copy of the GNU General Public License along - * with this program, contact the lead developer, or write to the Free - * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - * - */ - -/* This file is largely inspired by files wrote by Jeremias Maerki, - * for the fop plugin of barcode4j available at - * http://barcode4j.sourceforge.net/ - */ - -package org.scilab.forge.jlatexmath.fop; - -import java.util.HashMap; - -import org.apache.fop.fo.ElementMapping; -import org.apache.fop.fo.FONode; -import org.w3c.dom.DOMImplementation; - -/** - * This class provides the element mapping for FOP. - */ -public class JLaTeXMathElementMapping extends ElementMapping { - - public JLaTeXMathElementMapping() { - this.namespaceURI = JLaTeXMathObj.JLATEXMATH_NS; - } - - public DOMImplementation getDOMImplementation() { - return ElementMapping.getDefaultDOMImplementation(); - } - - protected void initialize() { - if (this.foObjs == null) { - this.foObjs = new HashMap(); - this.foObjs.put("latex", new JLMEMaker()); - this.foObjs.put(ElementMapping.DEFAULT, new JLMMaker()); - } - } - - public final class JLMMaker extends ElementMapping.Maker { - private JLMMaker() { } - public FONode make(final FONode parent) { - return new JLaTeXMathObj(parent); - } - } - - public final class JLMEMaker extends ElementMapping.Maker { - private JLMEMaker() { } - public FONode make(final FONode parent) { - return new JLaTeXMathElement(parent); - } - } -} diff -Nru libjlatexmath-java-0.9.6/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/JLaTeXMathObj.java libjlatexmath-java-0.9.7/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/JLaTeXMathObj.java --- libjlatexmath-java-0.9.6/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/JLaTeXMathObj.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/JLaTeXMathObj.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -/* JLaTeXMathObj.java - * ========================================================================= - * This file is part of the JLaTeXMath Library - http://forge.scilab.org/jlatexmath - * - * Copyright (C) 2010 DENIZET Calixte - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * A copy of the GNU General Public License can be found in the file - * LICENSE.txt provided with the source distribution of this program (see - * the META-INF directory in the source jar). This license can also be - * found on the GNU website at http://www.gnu.org/licenses/gpl.html. - * - * If you did not receive a copy of the GNU General Public License along - * with this program, contact the lead developer, or write to the Free - * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - * - */ - -/* This file is largely inspired by files wrote by Jeremias Maerki, - * for the fop plugin of barcode4j available at - * http://barcode4j.sourceforge.net/ - */ - -package org.scilab.forge.jlatexmath.fop; - -import org.apache.fop.fo.FONode; -import org.apache.fop.fo.XMLObj; - -public class JLaTeXMathObj extends XMLObj { - - public static final String JLATEXMATH_NS = "http://forge.scilab.org/p/jlatexmath"; - public static final String MIME_TYPE = "image/latex"; - - public JLaTeXMathObj(FONode parent) { - super(parent); - } - - public String getNamespaceURI() { - return JLATEXMATH_NS; - } - - public String getNormalNamespacePrefix() { - return "latex"; - } -} diff -Nru libjlatexmath-java-0.9.6/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/JLaTeXMathXMLHandler.java libjlatexmath-java-0.9.7/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/JLaTeXMathXMLHandler.java --- libjlatexmath-java-0.9.6/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/JLaTeXMathXMLHandler.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/plugin/fop/dist/src/org/scilab/forge/jlatexmath/fop/JLaTeXMathXMLHandler.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ -/* JLaTeXMathXMLHandler.java - * ========================================================================= - * This file is part of the JLaTeXMath Library - http://forge.scilab.org/jlatexmath - * - * Copyright (C) 2010 DENIZET Calixte - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * A copy of the GNU General Public License can be found in the file - * LICENSE.txt provided with the source distribution of this program (see - * the META-INF directory in the source jar). This license can also be - * found on the GNU website at http://www.gnu.org/licenses/gpl.html. - * - * If you did not receive a copy of the GNU General Public License along - * with this program, contact the lead developer, or write to the Free - * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - * - */ - -/* This file is largely inspired by files wrote by Jeremias Maerki, - * for the fop plugin of barcode4j available at - * http://barcode4j.sourceforge.net/ - */ - -package org.scilab.forge.jlatexmath.fop; - -import org.apache.fop.render.Graphics2DAdapter; -import org.apache.fop.render.Renderer; -import org.apache.fop.render.RendererContext; -import org.apache.fop.render.XMLHandler; - -import org.scilab.forge.jlatexmath.fop.image.loader.Graphics2DImagePainterJLaTeXMath; - -import org.w3c.dom.Document; - -/** - * XMLHandler which draws LaTeX through a fop G2DAdapter. - */ -public class JLaTeXMathXMLHandler implements XMLHandler { - - public JLaTeXMathXMLHandler() { } - - public void handleXML(RendererContext context, Document document, String ns) throws Exception { - Graphics2DAdapter g2dAdapter = context.getRenderer().getGraphics2DAdapter(); - - if (g2dAdapter != null) { - g2dAdapter.paintImage(new Graphics2DImagePainterJLaTeXMath(document), context, - ((Integer) context.getProperty("xpos")).intValue(), - ((Integer) context.getProperty("ypos")).intValue(), - ((Integer) context.getProperty("width")).intValue(), - ((Integer) context.getProperty("height")).intValue()); - } - } - - public boolean supportsRenderer(Renderer renderer) { - return renderer.getGraphics2DAdapter() != null; - } - - public String getMimeType() { - return JLaTeXMathObj.MIME_TYPE; - } - - public String getNamespace() { - return JLaTeXMathObj.JLATEXMATH_NS; - } -} Binary files /tmp/Cwu3pjs0fn/libjlatexmath-java-0.9.6/plugin/fop/examples/toto.pdf and /tmp/LIIfw1myf3/libjlatexmath-java-0.9.7/plugin/fop/examples/toto.pdf differ diff -Nru libjlatexmath-java-0.9.6/plugin/fop/LICENSE libjlatexmath-java-0.9.7/plugin/fop/LICENSE --- libjlatexmath-java-0.9.6/plugin/fop/LICENSE 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/plugin/fop/LICENSE 2011-11-22 17:18:16.000000000 +0000 @@ -1,6 +1,6 @@ JLaTeXMath-FOP Library - Enables inclusion of LaTeX formulas in fo. -Copyright (C) 2010 DENIZET Calixte +Copyright (C) 2010-2011 DENIZET Calixte This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -14,4 +14,5 @@ You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +MA 02110-1301, USA. diff -Nru libjlatexmath-java-0.9.6/plugin/fop/src/org/scilab/forge/jlatexmath/fop/JLaTeXMathElement.java libjlatexmath-java-0.9.7/plugin/fop/src/org/scilab/forge/jlatexmath/fop/JLaTeXMathElement.java --- libjlatexmath-java-0.9.6/plugin/fop/src/org/scilab/forge/jlatexmath/fop/JLaTeXMathElement.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/plugin/fop/src/org/scilab/forge/jlatexmath/fop/JLaTeXMathElement.java 2011-11-22 17:18:16.000000000 +0000 @@ -27,7 +27,7 @@ */ /* This file is largely inspired by files wrote by Jeremias Maerki, - * for the fop plugin of barcode4j available at + * for the fop plugin of barcode4j available at * http://barcode4j.sourceforge.net/ */ @@ -40,8 +40,10 @@ import java.awt.Color; import java.awt.geom.Point2D; +import java.util.HashMap; import java.util.List; import java.util.LinkedList; +import java.util.Map; import java.util.StringTokenizer; import org.apache.fop.apps.FOPException; @@ -62,11 +64,12 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; import org.xml.sax.Attributes; import org.xml.sax.Locator; public class JLaTeXMathElement extends JLaTeXMathObj { - + private float size; private Color fg; private TeXIcon icon = null; @@ -76,7 +79,7 @@ public JLaTeXMathElement(FONode parent) { super(parent); } - + public void processNode(final String elementName, final Locator locator, final Attributes attlist, final PropertyList propertyList) throws FOPException { @@ -85,49 +88,49 @@ e.setAttribute("size", "" + size); e.setAttribute("fg", "" + fg.getRGB()); } - + public Point2D getDimension(Point2D p) { if (icon == null) { - icon = calculate(doc, size); + icon = calculate(doc, size); } - return new Point2D.Float(icon.getTrueIconWidth(), icon.getTrueIconHeight()); + return new Point2D.Float(icon.getTrueIconWidth(), icon.getTrueIconHeight()); } - + public Length getIntrinsicAlignmentAdjust() { if (icon == null) { - icon = calculate(doc, size); + icon = calculate(doc, size); } - return FixedLength.getInstance(-icon.getTrueIconDepth(), "px"); + return FixedLength.getInstance(-icon.getTrueIconDepth(), "px"); } public static float getFWidth(String str) { - StringTokenizer tok = new StringTokenizer(str, ","); - int sum = 0; - while (tok.hasMoreTokens()) { - int i = 0; - String s = tok.nextToken(); - for (; i < s.length() && !Character.isLetter(s.charAt(i)); i++); - double w = 0; - try { - w = Double.parseDouble(s.substring(0, i)); - } catch (NumberFormatException e) { - return 0.0f; - } - - String unit = "px"; - if (i != s.length()) { - unit = s.substring(i).toLowerCase(); - } - - sum += FixedLength.getInstance(w, unit).getValue(); - } + StringTokenizer tok = new StringTokenizer(str, ","); + int sum = 0; + while (tok.hasMoreTokens()) { + int i = 0; + String s = tok.nextToken(); + for (; i < s.length() && !Character.isLetter(s.charAt(i)); i++); + double w = 0; + try { + w = Double.parseDouble(s.substring(0, i)); + } catch (NumberFormatException e) { + return 0.0f; + } + + String unit = "px"; + if (i != s.length()) { + unit = s.substring(i).toLowerCase(); + } - return (float) (sum / 1000f); + sum += FixedLength.getInstance(w, unit).getValue(); + } + + return (float) (sum / 1000f); } - + public static TeXIcon calculate(Document doc, float size) { TeXIcon icon; - Element e = doc.getDocumentElement(); + Element e = doc.getDocumentElement(); String code = e.getTextContent(); String style = e.getAttribute("style"); int st = TeXConstants.STYLE_DISPLAY; @@ -138,18 +141,24 @@ } else if ("script_script".equals(style)) { st = TeXConstants.STYLE_SCRIPT_SCRIPT; } - - String stfw = e.getAttribute("fwidth"); - - if (stfw.length() != 0) { - icon = new TeXFormula(code).createTeXIcon(st, size, TeXConstants.UNIT_PIXEL, getFWidth(stfw), TeXConstants.ALIGN_CENTER); - } else { - icon = new TeXFormula(code).createTeXIcon(st, size, true); - } - - return icon; - } - + + NamedNodeMap attributes = e.getAttributes(); + int len = attributes.getLength(); + Map map = new HashMap(); + for (int i = 0; i < len; i++) { + map.put(attributes.item(i).getNodeName(), attributes.item(i).getNodeValue()); + } + + String stfw = e.getAttribute("fwidth"); + if (stfw.length() != 0) { + icon = new TeXFormula(code, map).createTeXIcon(st, size, TeXConstants.UNIT_PIXEL, getFWidth(stfw), TeXConstants.ALIGN_CENTER); + } else { + icon = new TeXFormula(code, map).createTeXIcon(st, size, true); + } + + return icon; + } + protected PropertyList createPropertyList(final PropertyList pList, final FOEventHandler foEventHandler) throws FOPException { FOUserAgent userAgent = this.getUserAgent(); @@ -157,16 +166,16 @@ this.size = (float) commonFont.fontSize.getNumericValue() / 1000; int n = org.apache.fop.fo.Constants.PR_COLOR; - try { - n = org.apache.fop.fo.Constants.class.getDeclaredField(PR_COLOR).getInt(null); - } catch (Exception e) { - System.err.println("Error in getting field:\n" + e); - } + try { + n = org.apache.fop.fo.Constants.class.getDeclaredField(PR_COLOR).getInt(null); + } catch (Exception e) { + System.err.println("Error in getting field:\n" + e); + } + + Property colorProp = pList.get(n); - Property colorProp = pList.get(n); - this.fg = colorProp != null ? colorProp.getColor(userAgent) : null; - + return super.createPropertyList(pList, foEventHandler); } } \ No newline at end of file diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/Box.java libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/Box.java --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/Box.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/Box.java 2011-11-22 17:18:16.000000000 +0000 @@ -1,30 +1,30 @@ /* Box.java * ========================================================================= * This file is originally part of the JMathTeX Library - http://jmathtex.sourceforge.net - * + * * Copyright (C) 2004-2007 Universiteit Gent * Copyright (C) 2009 DENIZET Calixte - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. - * + * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. - * + * * A copy of the GNU General Public License can be found in the file * LICENSE.txt provided with the source distribution of this program (see * the META-INF directory in the source jar). This license can also be * found on the GNU website at http://www.gnu.org/licenses/gpl.html. - * + * * If you did not receive a copy of the GNU General Public License along * with this program, contact the lead developer, or write to the Free * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. - * + * */ /* Modified by Calixte Denizet */ @@ -50,248 +50,276 @@ * (that paints the box). This implementation must start with calling the method * {@link #startDraw(Graphics2D, float, float)} and end with calling the method * {@link #endDraw(Graphics2D)} to set and restore the color's that must be used for - * painting the box and to draw the background! They must also implement the abstract + * painting the box and to draw the background! They must also implement the abstract * {@link #getLastFontId()} method (the last font * that will be used when this box will be painted). */ public abstract class Box { - + public static boolean DEBUG = false;; /** * The foreground color of the whole box. Child boxes can override this color. - * If it's null and it has a parent box, the foreground color of the parent will + * If it's null and it has a parent box, the foreground color of the parent will * be used. If it has no parent, the foreground color of the component on which it * will be painted, will be used. */ protected Color foreground; - + /** * The background color of the whole box. Child boxes can paint a background on top of * this background. If it's null, no background will be painted. */ protected Color background; - + private Color prevColor; // used temporarily in startDraw and endDraw - + /** - * The width of this box, i.e. the value that will be used for further - * calculations. + * The width of this box, i.e. the value that will be used for further + * calculations. */ protected float width = 0; - + /** - * The height of this box, i.e. the value that will be used for further + * The height of this box, i.e. the value that will be used for further * calculations. */ protected float height = 0; - + /** - * The depth of this box, i.e. the value that will be used for further + * The depth of this box, i.e. the value that will be used for further * calculations. */ protected float depth = 0; - + /** * The shift amount: the meaning depends on the particular kind of box * (up, down, left, right) */ protected float shift = 0; - + protected int type = -1; - + /** * List of child boxes */ protected LinkedList children = new LinkedList(); - + protected Box parent; + protected Box elderParent; + protected Color markForDEBUG; + /** * Inserts the given box at the end of the list of child boxes. - * + * * @param b the box to be inserted */ public void add(Box b) { - children.add(b); + children.add(b); + b.parent = this; + b.elderParent = elderParent; } - + /** * Inserts the given box at the given position in the list of child boxes. - * + * * @param pos the position at which to insert the given box * @param b the box to be inserted */ public void add(int pos, Box b) { - children.add(pos, b); + children.add(pos, b); + b.parent = this; + b.elderParent = elderParent; } - + /** * Creates an empty box (no children) with all dimensions set to 0 and no * foreground and background color set (default values will be used: null) */ protected Box() { - this(null, null); + this(null, null); } - + /** * Creates an empty box (no children) with all dimensions set to 0 and sets * the foreground and background color of the box. - * + * * @param fg the foreground color * @param bg the background color */ protected Box(Color fg, Color bg) { - foreground = fg; - background = bg; + foreground = fg; + background = bg; + } + + public void setParent(Box parent) { + this.parent = parent; + } + + public Box getParent() { + return parent; } - + + public void setElderParent(Box elderParent) { + this.elderParent = elderParent; + } + + public Box getElderParent() { + return elderParent; + } + /** * Get the width of this box. - * + * * @return the width of this box */ public float getWidth() { - return width; + return width; } - + public void negWidth() { - width = -width; + width = -width; } - + /** * Get the height of this box. - * + * * @return the height of this box */ public float getHeight() { - return height; + return height; } - + /** * Get the depth of this box. - * + * * @return the depth of this box */ public float getDepth() { - return depth; + return depth; } - + /** * Get the shift amount for this box. - * + * * @return the shift amount */ public float getShift() { - return shift; + return shift; } - + /** * Set the width for this box. - * + * * @param w the width */ public void setWidth(float w) { - width = w; + width = w; } - + /** * Set the depth for this box. - * + * * @param d the depth */ public void setDepth(float d) { - depth = d; + depth = d; } - + /** * Set the height for this box. - * + * * @param h the height */ public void setHeight(float h) { - height = h; + height = h; } - + /** * Set the shift amount for this box. - * + * * @param s the shift amount */ public void setShift(float s) { - shift = s; + shift = s; } - + /** * Paints this box at the given coordinates using the given graphics context. - * + * * @param g2 the graphics (2D) context to use for painting * @param x the x-coordinate * @param y the y-coordinate */ public abstract void draw(Graphics2D g2, float x, float y); - + /** * Get the id of the font that will be used the last when this box will be painted. - * + * * @return the id of the last font that will be used. */ public abstract int getLastFontId(); - + /** - * Stores the old color setting, draws the background of the box (if not null) + * Stores the old color setting, draws the background of the box (if not null) * and sets the foreground color (if not null). - * + * * @param g2 the graphics (2D) context * @param x the x-coordinate * @param y the y-coordinate */ protected void startDraw(Graphics2D g2, float x, float y) { - // old color - prevColor = g2.getColor(); - - if (background != null) { // draw background - g2.setColor(background); - g2.fill(new Rectangle2D.Float(x, y - height, width, height + depth)); - } - if (foreground == null) { - g2.setColor(prevColor); // old foreground color - } else { - g2.setColor(foreground); // overriding foreground color - } - drawDebug(g2, x, y); + // old color + prevColor = g2.getColor(); + if (background != null) { // draw background + g2.setColor(background); + g2.fill(new Rectangle2D.Float(x, y - height, width, height + depth)); + } + if (foreground == null) { + g2.setColor(prevColor); // old foreground color + } else { + g2.setColor(foreground); // overriding foreground color + } + drawDebug(g2, x, y); } protected void drawDebug(Graphics2D g2, float x, float y, boolean showDepth) { - if (DEBUG) { - Stroke st = g2.getStroke(); - g2.setStroke(new BasicStroke((float) (Math.abs(1 / g2.getTransform().getScaleX())), BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER)); - if (width < 0) { - x += width; - width = -width; - } - g2.draw(new Rectangle2D.Float(x, y - height, width, height + depth)); - if (showDepth) { - Color c = g2.getColor(); - g2.setColor(Color.LIGHT_GRAY); - g2.fill(new Rectangle2D.Float(x, y, width, depth)); - g2.setColor(c); - g2.draw(new Rectangle2D.Float(x, y, width, depth)); - } - g2.setStroke(st); - } + if (DEBUG) { + Stroke st = g2.getStroke(); + if (markForDEBUG != null) { + Color c = g2.getColor(); + g2.setColor(markForDEBUG); + g2.fill(new Rectangle2D.Float(x, y - height, width, height + depth)); + g2.setColor(c); + } + g2.setStroke(new BasicStroke((float) (Math.abs(1 / g2.getTransform().getScaleX())), BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER)); + if (width < 0) { + x += width; + width = -width; + } + g2.draw(new Rectangle2D.Float(x, y - height, width, height + depth)); + if (showDepth) { + Color c = g2.getColor(); + g2.setColor(Color.LIGHT_GRAY); + g2.fill(new Rectangle2D.Float(x, y, width, depth)); + g2.setColor(c); + g2.draw(new Rectangle2D.Float(x, y, width, depth)); + } + g2.setStroke(st); + } } protected void drawDebug(Graphics2D g2, float x, float y) { - if (DEBUG) { - drawDebug(g2, x, y, false); - } + if (DEBUG) { + drawDebug(g2, x, y, false); + } } - + /** * Restores the previous color setting. - * + * * @param g2 the graphics (2D) context */ protected void endDraw(Graphics2D g2) { - g2.setColor(prevColor); + g2.setColor(prevColor); } } diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/BreakFormula.java libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/BreakFormula.java --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/BreakFormula.java 1970-01-01 00:00:00.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/BreakFormula.java 2011-11-22 17:18:16.000000000 +0000 @@ -0,0 +1,133 @@ +/* BreakFormula.java + * ========================================================================= + * This file is part of the JLaTeXMath Library - http://forge.scilab.org/jlatexmath + * + * Copyright (C) 2011 DENIZET Calixte + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * A copy of the GNU General Public License can be found in the file + * LICENSE.txt provided with the source distribution of this program (see + * the META-INF directory in the source jar). This license can also be + * found on the GNU website at http://www.gnu.org/licenses/gpl.html. + * + * If you did not receive a copy of the GNU General Public License along + * with this program, contact the lead developer, or write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + * + */ + +package org.scilab.forge.jlatexmath; + +import java.util.List; +import java.util.Stack; + +public final class BreakFormula { + + public static Box split(Box box, float width, float interline) { + if (!(box instanceof HorizontalBox)) { + return box; + } + + HorizontalBox hbox = (HorizontalBox) box; + VerticalBox vbox = new VerticalBox(); + HorizontalBox first; + HorizontalBox second = null; + Stack positions = new Stack(); + + while (hbox.width > width && canBreak(positions, hbox, width) != hbox.width) { + Position pos = positions.pop(); + HorizontalBox[] hboxes = pos.hbox.split(pos.index - 1); + first = hboxes[0]; + second = hboxes[1]; + while (!positions.isEmpty()) { + pos = positions.pop(); + hboxes = pos.hbox.splitRemove(pos.index); + hboxes[0].add(first); + hboxes[1].add(0, second); + first = hboxes[0]; + second = hboxes[1]; + } + vbox.add(first, interline); + hbox = second; + } + + if (second != null) { + vbox.add(second, interline); + return vbox; + } + + return box; + } + + private static float canBreak(Stack stack, HorizontalBox hbox, float width) { + List children = hbox.children; + float[] cumWidth = new float[children.size() + 1]; + cumWidth[0] = 0; + for (int i = 0; i < children.size(); i++) { + Box box = children.get(i); + cumWidth[i + 1] = cumWidth[i] + box.width; + if (cumWidth[i + 1] > width) { + int pos = getBreakPosition(hbox, i); + if (box instanceof HorizontalBox) { + Stack newStack = new Stack(); + float w = canBreak(newStack, (HorizontalBox) box, width - cumWidth[i]); + if (cumWidth[i] + w <= width || pos == -1) { + stack.push(new Position(i - 1, hbox)); + stack.addAll(newStack); + return cumWidth[i] + w; + } + } + + if (pos != -1) { + stack.push(new Position(pos, hbox)); + return cumWidth[pos]; + } + } + } + + return hbox.width; + } + + private static int getBreakPosition(HorizontalBox hb, int i) { + if (hb.breakPositions == null) { + return -1; + } + + if (hb.breakPositions.size() == 1 && hb.breakPositions.get(0) <= i) { + return hb.breakPositions.get(0); + } + + int pos = 0; + for (; pos < hb.breakPositions.size(); pos++) { + if (hb.breakPositions.get(pos) > i) { + if (pos == 0) { + return -1; + } + return hb.breakPositions.get(pos - 1); + } + } + + return hb.breakPositions.get(pos - 1); + } + + private static class Position { + + int index; + HorizontalBox hbox; + + Position(int index, HorizontalBox hbox) { + this.index = index; + this.hbox = hbox; + } + } +} diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/BreakMarkAtom.java libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/BreakMarkAtom.java --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/BreakMarkAtom.java 1970-01-01 00:00:00.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/BreakMarkAtom.java 2011-11-22 17:18:16.000000000 +0000 @@ -0,0 +1,41 @@ +/* BreakMarkAtom.java + * ========================================================================= + * This file is part of the JLaTeXMath Library - http://forge.scilab.org/jlatexmath + * + * Copyright (C) 2010 DENIZET Calixte + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * A copy of the GNU General Public License can be found in the file + * LICENSE.txt provided with the source distribution of this program (see + * the META-INF directory in the source jar). This license can also be + * found on the GNU website at http://www.gnu.org/licenses/gpl.html. + * + * If you did not receive a copy of the GNU General Public License along + * with this program, contact the lead developer, or write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + * + */ + +package org.scilab.forge.jlatexmath; + +/** + * An empty atom just to add a mark. + */ +public class BreakMarkAtom extends Atom { + + public BreakMarkAtom() { } + + public Box createBox(TeXEnvironment env) { + return new StrutBox(0, 0, 0, 0); + } +} diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/cache/JLaTeXMathCache.java libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/cache/JLaTeXMathCache.java --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/cache/JLaTeXMathCache.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/cache/JLaTeXMathCache.java 2011-11-22 17:18:16.000000000 +0000 @@ -52,7 +52,7 @@ public final class JLaTeXMathCache { private static final AffineTransform identity = new AffineTransform(); - private static ConcurrentMap> cache = new ConcurrentHashMap(128); + private static ConcurrentMap> cache = new ConcurrentHashMap>(128); private static int max = Integer.MAX_VALUE; private static ReferenceQueue queue = new ReferenceQueue(); @@ -65,7 +65,7 @@ public static void setMaxCachedObjects(int max) { JLaTeXMathCache.max = Math.max(max, 1); cache.clear(); - cache = new ConcurrentHashMap(JLaTeXMathCache.max); + cache = new ConcurrentHashMap>(JLaTeXMathCache.max); } /** @@ -149,7 +149,7 @@ * @param o an Object to identify the image in the cache */ public static void removeCachedTeXFormula(Object o) throws ParseException { - if (o == null || o instanceof CachedTeXFormula) { + if (o != null && o instanceof CachedTeXFormula) { cache.remove((CachedTeXFormula) o); } } @@ -233,7 +233,7 @@ icon.paintIcon(null, g2, 0, 0); g2.dispose(); cached.setDimensions(icon.getIconWidth(), icon.getIconHeight(), icon.getIconDepth()); - SoftReference img = new SoftReference(new CachedImage(image, cached), queue); + SoftReference img = new SoftReference(new CachedImage(image, cached), queue); if (cache.size() >= max) { Reference soft; @@ -246,7 +246,10 @@ Iterator iter = cache.keySet().iterator(); if (iter.hasNext()) { CachedTeXFormula c = iter.next(); - cache.get(c).clear(); + SoftReference cachedImage = cache.get(c); + if (cachedImage != null) { + cachedImage.clear(); + } cache.remove(c); } } @@ -276,7 +279,7 @@ int width = -1; int height; int depth; - Color fgcolor; + Color fgcolor; CachedTeXFormula(String f, int style, int type, int size, int inset, Color fgcolor) { this.f = f; @@ -284,7 +287,7 @@ this.type = type; this.size = size; this.inset = inset; - this.fgcolor = fgcolor; + this.fgcolor = fgcolor; } void setDimensions(int width, int height, int depth) { diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/CharAtom.java libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/CharAtom.java --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/CharAtom.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/CharAtom.java 2011-11-22 17:18:16.000000000 +0000 @@ -71,6 +71,10 @@ return box; } + public char getCharacter() { + return c; + } + /* * Get the Char-object representing this character ("c") in the right text style */ diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/CharBox.java libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/CharBox.java --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/CharBox.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/CharBox.java 2011-11-22 17:18:16.000000000 +0000 @@ -79,4 +79,8 @@ public int getLastFontId() { return cf.fontId; } + + public String toString() { + return super.toString() + "=" + cf.c; + } } diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/ColorAtom.java libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/ColorAtom.java --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/ColorAtom.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/ColorAtom.java 2011-12-02 14:46:16.000000000 +0000 @@ -1,190 +1,263 @@ /* ColorAtom.java * ========================================================================= * This file is originally part of the JMathTeX Library - http://jmathtex.sourceforge.net - * + * * Copyright (C) 2004-2007 Universiteit Gent * Copyright (C) 2009 DENIZET Calixte - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. - * + * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. - * + * * A copy of the GNU General Public License can be found in the file * LICENSE.txt provided with the source distribution of this program (see * the META-INF directory in the source jar). This license can also be * found on the GNU website at http://www.gnu.org/licenses/gpl.html. - * + * * If you did not receive a copy of the GNU General Public License along * with this program, contact the lead developer, or write to the Free * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. - * + * */ package org.scilab.forge.jlatexmath; import java.awt.Color; import java.util.HashMap; +import java.util.Map; +import java.util.StringTokenizer; /** - * An atom representing the foreground and background color of an other atom. + * An atom representing the foreground and background color of an other atom. */ public class ColorAtom extends Atom implements Row { - public static HashMap Colors = new HashMap(); + public static Map Colors = new HashMap(); // background color private final Color background; - + // foreground color private final Color color; - + // RowAtom for which the colorsettings apply private final RowAtom elements; - + static { - initColors(); + initColors(); } /** * Creates a new ColorAtom that sets the given colors for the given atom. * Null for a color means: no specific color set for this atom. - * - * @param atom the atom for which the given colors have to be set + * + * @param atom the atom for which the given colors have to be set * @param bg the background color * @param c the foreground color */ public ColorAtom(Atom atom, Color bg, Color c) { - elements = new RowAtom(atom); - background = bg; - color = c; + elements = new RowAtom(atom); + background = bg; + color = c; } - + /** * Creates a ColorAtom that overrides the colors of the given ColorAtom if the given * colors are not null. If they're null, the old values are used. - * + * * @param bg the background color * @param c the foreground color * @param old the ColorAtom for which the colorsettings should be overriden with the - * given colors. + * given colors. */ public ColorAtom(Color bg, Color c, ColorAtom old) { - elements = new RowAtom(old.elements); - background = (bg == null ? old.background : bg); - color = (c == null ? old.color : c); + elements = new RowAtom(old.elements); + background = (bg == null ? old.background : bg); + color = (c == null ? old.color : c); } - + public Box createBox(TeXEnvironment env) { - env.isColored = true; - TeXEnvironment copy = env.copy(); - if (background != null) - copy.setBackground(background); - if (color != null) - copy.setColor(color); - return elements.createBox(copy); + env.isColored = true; + TeXEnvironment copy = env.copy(); + if (background != null) + copy.setBackground(background); + if (color != null) + copy.setColor(color); + return elements.createBox(copy); } - + public int getLeftType() { - return elements.getLeftType(); + return elements.getLeftType(); } - + public int getRightType() { - return elements.getRightType(); + return elements.getRightType(); } - + public void setPreviousAtom(Dummy prev) { - elements.setPreviousAtom(prev); + elements.setPreviousAtom(prev); + } + + public static Color getColor(String s) { + if (s != null && s.length() != 0) { + s = s.trim(); + if (s.charAt(0) == '#') { + return Color.decode(s); + } else if (s.indexOf(',') != -1) { + StringTokenizer toks = new StringTokenizer(s, ";,"); + int n = toks.countTokens(); + if (n == 3) { + // RGB model + try { + String R = toks.nextToken().trim(); + String G = toks.nextToken().trim(); + String B = toks.nextToken().trim(); + + float r = Float.parseFloat(R); + float g = Float.parseFloat(G); + float b = Float.parseFloat(B); + + if (r == (int) r && g == (int) g && b == (int) b && R.indexOf('.') == -1 && G.indexOf('.') == -1 && B.indexOf('.') == -1) { + int ir = (int) Math.min(255, Math.max(0 ,r)); + int ig = (int) Math.min(255, Math.max(0 ,g)); + int ib = (int) Math.min(255, Math.max(0 ,b)); + return new Color(ir, ig, ib); + } else { + r = (float) Math.min(1, Math.max(0 ,r)); + g = (float) Math.min(1, Math.max(0 ,g)); + b = (float) Math.min(1, Math.max(0 ,b)); + return new Color(r, g, b); + } + } catch (NumberFormatException e) { + return Color.black; + } + } else if (n == 4) { + // CMYK model + try { + float c = Float.parseFloat(toks.nextToken().trim()); + float m = Float.parseFloat(toks.nextToken().trim()); + float y = Float.parseFloat(toks.nextToken().trim()); + float k = Float.parseFloat(toks.nextToken().trim()); + + c = (float) Math.min(1, Math.max(0 ,c)); + m = (float) Math.min(1, Math.max(0 ,m)); + y = (float) Math.min(1, Math.max(0 ,y)); + k = (float) Math.min(1, Math.max(0 ,k)); + + return convColor(c, m, y, k); + } catch (NumberFormatException e) { + return Color.black; + } + } + } + + Color c = Colors.get(s); + if (c != null) { + return c; + } else { + if (s.indexOf('.') != -1) { + try { + float g = (float) Math.min(1, Math.max(Float.parseFloat(s), 0)); + + return new Color(g, g, g); + } catch (NumberFormatException e) { } + } + + return Color.decode("#" + s); + } + } + + return Color.black; } private static void initColors() { - Colors.put("black", Color.black); - Colors.put("white", Color.white); - Colors.put("red", Color.red); - Colors.put("green", Color.green); - Colors.put("blue", Color.blue); - Colors.put("cyan", Color.cyan); - Colors.put("magenta", Color.magenta); - Colors.put("yellow", Color.yellow); - Colors.put("GreenYellow", convColor(0.15f,0f,0.69f,0f)); - Colors.put("Yellow", convColor(0f,0f,1f,0f)); - Colors.put("Goldenrod", convColor(0f,0.10f,0.84f,0f)); - Colors.put("Dandelion", convColor(0f,0.29f,0.84f,0f)); - Colors.put("Apricot", convColor(0f,0.32f,0.52f,0f)); - Colors.put("Peach", convColor(0f,0.50f,0.70f,0f)); - Colors.put("Melon", convColor(0f,0.46f,0.50f,0f)); - Colors.put("YellowOrange", convColor(0f,0.42f,1f,0f)); - Colors.put("Orange", convColor(0f,0.61f,0.87f,0f)); - Colors.put("BurntOrange", convColor(0f,0.51f,1f,0f)); - Colors.put("Bittersweet", convColor(0f,0.75f,1f,0.24f)); - Colors.put("RedOrange", convColor(0f,0.77f,0.87f,0f)); - Colors.put("Mahogany", convColor(0f,0.85f,0.87f,0.35f)); - Colors.put("Maroon", convColor(0f,0.87f,0.68f,0.32f)); - Colors.put("BrickRed", convColor(0f,0.89f,0.94f,0.28f)); - Colors.put("Red", convColor(0f,1f,1f,0f)); - Colors.put("OrangeRed", convColor(0f,1f,0.50f,0f)); - Colors.put("RubineRed", convColor(0f,1f,0.13f,0f)); - Colors.put("WildStrawberry", convColor(0f,0.96f,0.39f,0f)); - Colors.put("Salmon", convColor(0f,0.53f,0.38f,0f)); - Colors.put("CarnationPink", convColor(0f,0.63f,0f,0f)); - Colors.put("Magenta", convColor(0f,1f,0f,0f)); - Colors.put("VioletRed", convColor(0f,0.81f,0f,0f)); - Colors.put("Rhodamine", convColor(0f,0.82f,0f,0f)); - Colors.put("Mulberry", convColor(0.34f,0.90f,0f,0.02f)); - Colors.put("RedViolet", convColor(0.07f,0.90f,0f,0.34f)); - Colors.put("Fuchsia", convColor(0.47f,0.91f,0f,0.08f)); - Colors.put("Lavender", convColor(0f,0.48f,0f,0f)); - Colors.put("Thistle", convColor(0.12f,0.59f,0f,0f)); - Colors.put("Orchid", convColor(0.32f,0.64f,0f,0f)); - Colors.put("DarkOrchid", convColor(0.40f,0.80f,0.20f,0f)); - Colors.put("Purple", convColor(0.45f,0.86f,0f,0f)); - Colors.put("Plum", convColor(0.50f,1f,0f,0f)); - Colors.put("Violet", convColor(0.79f,0.88f,0f,0f)); - Colors.put("RoyalPurple", convColor(0.75f,0.90f,0f,0f)); - Colors.put("BlueViolet", convColor(0.86f,0.91f,0f,0.04f)); - Colors.put("Periwinkle", convColor(0.57f,0.55f,0f,0f)); - Colors.put("CadetBlue", convColor(0.62f,0.57f,0.23f,0f)); - Colors.put("CornflowerBlue", convColor(0.65f,0.13f,0f,0f)); - Colors.put("MidnightBlue", convColor(0.98f,0.13f,0f,0.43f)); - Colors.put("NavyBlue", convColor(0.94f,0.54f,0f,0f)); - Colors.put("RoyalBlue", convColor(1f,0.50f,0f,0f)); - Colors.put("Blue", convColor(1f,1f,0f,0f)); - Colors.put("Cerulean", convColor(0.94f,0.11f,0f,0f)); - Colors.put("Cyan", convColor(1f,0f,0f,0f)); - Colors.put("ProcessBlue", convColor(0.96f,0f,0f,0f)); - Colors.put("SkyBlue", convColor(0.62f,0f,0.12f,0f)); - Colors.put("Turquoise", convColor(0.85f,0f,0.20f,0f)); - Colors.put("TealBlue", convColor(0.86f,0f,0.34f,0.02f)); - Colors.put("Aquamarine", convColor(0.82f,0f,0.30f,0f)); - Colors.put("BlueGreen", convColor(0.85f,0f,0.33f,0f)); - Colors.put("Emerald", convColor(1f,0f,0.50f,0f)); - Colors.put("JungleGreen", convColor(0.99f,0f,0.52f,0f)); - Colors.put("SeaGreen", convColor(0.69f,0f,0.50f,0f)); - Colors.put("Green", convColor(1f,0f,1f,0f)); - Colors.put("ForestGreen", convColor(0.91f,0f,0.88f,0.12f)); - Colors.put("PineGreen", convColor(0.92f,0f,0.59f,0.25f)); - Colors.put("LimeGreen", convColor(0.50f,0f,1f,0f)); - Colors.put("YellowGreen", convColor(0.44f,0f,0.74f,0f)); - Colors.put("SpringGreen", convColor(0.26f,0f,0.76f,0f)); - Colors.put("OliveGreen", convColor(0.64f,0f,0.95f,0.40f)); - Colors.put("RawSienna", convColor(0f,0.72f,1f,0.45f)); - Colors.put("Sepia", convColor(0f,0.83f,1f,0.70f)); - Colors.put("Brown", convColor(0f,0.81f,1f,0.60f)); - Colors.put("Tan", convColor(0.14f,0.42f,0.56f,0f)); - Colors.put("Gray", convColor(0f,0f,0f,0.50f)); - Colors.put("Black", convColor(0f,0f,0f,1f)); - Colors.put("White", convColor(0f,0f,0f,0f)); - } - - private static Color convColor(float c, float m, float y, float k) { - k = 1 - k; - return new Color(k*(1-c), k*(1-m), k*(1-y)); + Colors.put("black", Color.black); + Colors.put("white", Color.white); + Colors.put("red", Color.red); + Colors.put("green", Color.green); + Colors.put("blue", Color.blue); + Colors.put("cyan", Color.cyan); + Colors.put("magenta", Color.magenta); + Colors.put("yellow", Color.yellow); + Colors.put("GreenYellow", convColor(0.15f, 0f, 0.69f, 0f)); + Colors.put("Yellow", convColor(0f, 0f, 1f, 0f)); + Colors.put("Goldenrod", convColor(0f, 0.10f, 0.84f, 0f)); + Colors.put("Dandelion", convColor(0f, 0.29f, 0.84f, 0f)); + Colors.put("Apricot", convColor(0f, 0.32f, 0.52f, 0f)); + Colors.put("Peach", convColor(0f, 0.50f, 0.70f, 0f)); + Colors.put("Melon", convColor(0f, 0.46f, 0.50f, 0f)); + Colors.put("YellowOrange", convColor(0f, 0.42f, 1f, 0f)); + Colors.put("Orange", convColor(0f, 0.61f, 0.87f, 0f)); + Colors.put("BurntOrange", convColor(0f, 0.51f, 1f, 0f)); + Colors.put("Bittersweet", convColor(0f, 0.75f, 1f, 0.24f)); + Colors.put("RedOrange", convColor(0f, 0.77f, 0.87f, 0f)); + Colors.put("Mahogany", convColor(0f, 0.85f, 0.87f, 0.35f)); + Colors.put("Maroon", convColor(0f, 0.87f, 0.68f, 0.32f)); + Colors.put("BrickRed", convColor(0f, 0.89f, 0.94f, 0.28f)); + Colors.put("Red", convColor(0f, 1f, 1f, 0f)); + Colors.put("OrangeRed", convColor(0f, 1f, 0.50f, 0f)); + Colors.put("RubineRed", convColor(0f, 1f, 0.13f, 0f)); + Colors.put("WildStrawberry", convColor(0f, 0.96f, 0.39f, 0f)); + Colors.put("Salmon", convColor(0f, 0.53f, 0.38f, 0f)); + Colors.put("CarnationPink", convColor(0f, 0.63f, 0f, 0f)); + Colors.put("Magenta", convColor(0f, 1f, 0f, 0f)); + Colors.put("VioletRed", convColor(0f, 0.81f, 0f, 0f)); + Colors.put("Rhodamine", convColor(0f, 0.82f, 0f, 0f)); + Colors.put("Mulberry", convColor(0.34f, 0.90f, 0f, 0.02f)); + Colors.put("RedViolet", convColor(0.07f, 0.90f, 0f, 0.34f)); + Colors.put("Fuchsia", convColor(0.47f, 0.91f, 0f, 0.08f)); + Colors.put("Lavender", convColor(0f, 0.48f, 0f, 0f)); + Colors.put("Thistle", convColor(0.12f, 0.59f, 0f, 0f)); + Colors.put("Orchid", convColor(0.32f, 0.64f, 0f, 0f)); + Colors.put("DarkOrchid", convColor(0.40f, 0.80f, 0.20f, 0f)); + Colors.put("Purple", convColor(0.45f, 0.86f, 0f, 0f)); + Colors.put("Plum", convColor(0.50f, 1f, 0f, 0f)); + Colors.put("Violet", convColor(0.79f, 0.88f, 0f, 0f)); + Colors.put("RoyalPurple", convColor(0.75f, 0.90f, 0f, 0f)); + Colors.put("BlueViolet", convColor(0.86f, 0.91f, 0f, 0.04f)); + Colors.put("Periwinkle", convColor(0.57f, 0.55f, 0f, 0f)); + Colors.put("CadetBlue", convColor(0.62f, 0.57f, 0.23f, 0f)); + Colors.put("CornflowerBlue", convColor(0.65f, 0.13f, 0f, 0f)); + Colors.put("MidnightBlue", convColor(0.98f, 0.13f, 0f, 0.43f)); + Colors.put("NavyBlue", convColor(0.94f, 0.54f, 0f, 0f)); + Colors.put("RoyalBlue", convColor(1f, 0.50f, 0f, 0f)); + Colors.put("Blue", convColor(1f, 1f, 0f, 0f)); + Colors.put("Cerulean", convColor(0.94f, 0.11f, 0f, 0f)); + Colors.put("Cyan", convColor(1f, 0f, 0f, 0f)); + Colors.put("ProcessBlue", convColor(0.96f, 0f, 0f, 0f)); + Colors.put("SkyBlue", convColor(0.62f, 0f, 0.12f, 0f)); + Colors.put("Turquoise", convColor(0.85f, 0f, 0.20f, 0f)); + Colors.put("TealBlue", convColor(0.86f, 0f, 0.34f, 0.02f)); + Colors.put("Aquamarine", convColor(0.82f, 0f, 0.30f, 0f)); + Colors.put("BlueGreen", convColor(0.85f, 0f, 0.33f, 0f)); + Colors.put("Emerald", convColor(1f, 0f, 0.50f, 0f)); + Colors.put("JungleGreen", convColor(0.99f, 0f, 0.52f, 0f)); + Colors.put("SeaGreen", convColor(0.69f, 0f, 0.50f, 0f)); + Colors.put("Green", convColor(1f, 0f, 1f, 0f)); + Colors.put("ForestGreen", convColor(0.91f, 0f, 0.88f, 0.12f)); + Colors.put("PineGreen", convColor(0.92f, 0f, 0.59f, 0.25f)); + Colors.put("LimeGreen", convColor(0.50f, 0f, 1f, 0f)); + Colors.put("YellowGreen", convColor(0.44f, 0f, 0.74f, 0f)); + Colors.put("SpringGreen", convColor(0.26f, 0f, 0.76f, 0f)); + Colors.put("OliveGreen", convColor(0.64f, 0f, 0.95f, 0.40f)); + Colors.put("RawSienna", convColor(0f, 0.72f, 1f, 0.45f)); + Colors.put("Sepia", convColor(0f, 0.83f, 1f, 0.70f)); + Colors.put("Brown", convColor(0f, 0.81f, 1f, 0.60f)); + Colors.put("Tan", convColor(0.14f, 0.42f, 0.56f, 0f)); + Colors.put("Gray", convColor(0f, 0f, 0f, 0.50f)); + Colors.put("Black", convColor(0f, 0f, 0f, 1f)); + Colors.put("White", convColor(0f, 0f, 0f, 0f)); } + private static Color convColor(final float c, final float m, final float y, final float k) { + final float kk = 1 - k; + return new Color(kk * (1 - c), kk * (1 - m), kk * (1 - y)); + } } diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/cyrillic/LICENSE libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/cyrillic/LICENSE --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/cyrillic/LICENSE 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/cyrillic/LICENSE 2011-11-22 17:18:16.000000000 +0000 @@ -3,7 +3,7 @@ many more LaTeX commands, drop of the jdom dependency and easy evolution capabilities. -Copyright (C) 2009 DENIZET Calixte +Copyright (C) 2009-2011 DENIZET Calixte Copyright (C) Kris Coolsaet Copyright (C) Nico Van Cleemput Copyright (C) Kurt Vermeulen @@ -22,7 +22,8 @@ You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +MA 02110-1301, USA. diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/DefaultTeXFont.java libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/DefaultTeXFont.java --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/DefaultTeXFont.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/DefaultTeXFont.java 2011-11-22 17:18:16.000000000 +0000 @@ -74,8 +74,8 @@ protected static final int WIDTH = 0, HEIGHT = 1, DEPTH = 2, IT = 3; - public static List loadedAlphabets = new ArrayList(); - public static Map registeredAlphabets = new HashMap(); + public static List loadedAlphabets = new ArrayList(); + public static Map registeredAlphabets = new HashMap(); protected float factor = 1f; diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/Dummy.java libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/Dummy.java --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/Dummy.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/Dummy.java 2011-11-22 17:18:16.000000000 +0000 @@ -1,38 +1,38 @@ /* Dummy.java * ========================================================================= * This file is originally part of the JMathTeX Library - http://jmathtex.sourceforge.net - * + * * Copyright (C) 2004-2007 Universiteit Gent * Copyright (C) 2009 DENIZET Calixte - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. - * + * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. - * + * * A copy of the GNU General Public License can be found in the file * LICENSE.txt provided with the source distribution of this program (see * the META-INF directory in the source jar). This license can also be * found on the GNU website at http://www.gnu.org/licenses/gpl.html. - * + * * If you did not receive a copy of the GNU General Public License along * with this program, contact the lead developer, or write to the Free * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. - * + * */ package org.scilab.forge.jlatexmath; /** - * Used by RowAtom. The "textSymbol"-property and the type of an atom can change - * (according to the TeX-algorithms used). Or this atom can be replaced by a ligature, - * (if it was a CharAtom). But atoms cannot be changed, otherwise + * Used by RowAtom. The "textSymbol"-property and the type of an atom can change + * (according to the TeX-algorithms used). Or this atom can be replaced by a ligature, + * (if it was a CharAtom). But atoms cannot be changed, otherwise * different boxes could be made from the same TeXFormula, and that is not desired! * This "dummy atom" makes sure that changes to an atom (during the createBox-method of * a RowAtom) will be reset. @@ -40,87 +40,96 @@ public class Dummy { private Atom el; - + private boolean textSymbol = false; - + private int type = -1; - + /** * Creates a new Dummy for the given atom. - * + * * @param a an atom */ public Dummy(Atom a) { - el = a; + el = a; } - + /** * Changes the type of the atom - * + * * @param t the new type */ public void setType(int t) { - type = t; + type = t; } - + /** - * + * Changes the type of the atom + * + * @param t the new type + */ + public int getType() { + return type; + } + + /** + * * @return the changed type, or the old left type if it hasn't been changed */ public int getLeftType() { - return (type >= 0 ? type : el.getLeftType()); + return (type >= 0 ? type : el.getLeftType()); } - + /** - * + * * @return the changed type, or the old right type if it hasn't been changed */ public int getRightType() { - return (type >= 0 ? type : el.getRightType()); + return (type >= 0 ? type : el.getRightType()); } - + public boolean isCharSymbol() { - return el instanceof CharSymbol; + return el instanceof CharSymbol; } - + /** * This method will only be called if isCharSymbol returns true. */ public CharFont getCharFont(TeXFont tf) { - return ((CharSymbol) el).getCharFont(tf); + return ((CharSymbol) el).getCharFont(tf); } - + /** * Changes this atom into the given "ligature atom". - * + * * @param a the ligature atom */ public void changeAtom(FixedCharAtom a) { - textSymbol = false; - type = -1; - el = a; + textSymbol = false; + type = -1; + el = a; } - + public Box createBox(TeXEnvironment rs) { - if (textSymbol) - ((CharSymbol) el).markAsTextSymbol(); - Box b = el.createBox(rs); - if (textSymbol) - ((CharSymbol) el).removeMark(); // atom remains unchanged! - return b; + if (textSymbol) + ((CharSymbol) el).markAsTextSymbol(); + Box b = el.createBox(rs); + if (textSymbol) + ((CharSymbol) el).removeMark(); // atom remains unchanged! + return b; } - + public void markAsTextSymbol() { - textSymbol = true; + textSymbol = true; } - + public boolean isKern() { - return el instanceof SpaceAtom; + return el instanceof SpaceAtom; } - + // only for Row-elements public void setPreviousAtom(Dummy prev) { - if (el instanceof Row) - ((Row) el).setPreviousAtom(prev); + if (el instanceof Row) + ((Row) el).setPreviousAtom(prev); } } diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/dynamic/DynamicAtom.java libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/dynamic/DynamicAtom.java --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/dynamic/DynamicAtom.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/dynamic/DynamicAtom.java 2011-11-22 17:18:16.000000000 +0000 @@ -30,6 +30,7 @@ import org.scilab.forge.jlatexmath.Atom; import org.scilab.forge.jlatexmath.Box; +import org.scilab.forge.jlatexmath.EmptyAtom; import org.scilab.forge.jlatexmath.StrutBox; import org.scilab.forge.jlatexmath.TeXEnvironment; import org.scilab.forge.jlatexmath.TeXFormula; @@ -46,12 +47,17 @@ private ExternalConverter converter; private TeXFormula formula = new TeXFormula(); private String externalCode; - - public DynamicAtom(String externalCode) { + private boolean insert; + private boolean refreshed; + + public DynamicAtom(String externalCode, String option) { this.externalCode = externalCode; if (ecFactory != null) { this.converter = ecFactory.getExternalConverter(); } + if (option != null && option.equals("i")) { + insert = true; + } } public static boolean hasAnExternalConverterFactory() { @@ -62,11 +68,35 @@ ecFactory = factory; } + public boolean getInsertMode() { + return insert; + } + + public Atom getAtom() { + if (!refreshed) { + formula.setLaTeX(converter.getLaTeXString(externalCode)); + refreshed = true; + } + + if (formula.root == null) { + return new EmptyAtom(); + } + + return formula.root; + } + public Box createBox(TeXEnvironment env) { if (converter != null) { - formula.setLaTeX(converter.getLaTeXString(externalCode)); - return formula.root.createBox(env); + if (refreshed) { + refreshed = false; + } else { + formula.setLaTeX(converter.getLaTeXString(externalCode)); + } + if (formula.root != null) { + return formula.root.createBox(env); + } } + return new StrutBox(0, 0, 0, 0); } } \ No newline at end of file diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/EmptyAtom.java libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/EmptyAtom.java --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/EmptyAtom.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/EmptyAtom.java 2011-11-22 17:18:16.000000000 +0000 @@ -38,4 +38,4 @@ public Box createBox(TeXEnvironment env) { return new StrutBox(0, 0, 0, 0); } -} \ No newline at end of file +} diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/FencedAtom.java libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/FencedAtom.java --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/FencedAtom.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/FencedAtom.java 2011-11-22 17:18:16.000000000 +0000 @@ -1,30 +1,30 @@ /* FencedAtom.java * ========================================================================= * This file is originally part of the JMathTeX Library - http://jmathtex.sourceforge.net - * + * * Copyright (C) 2004-2007 Universiteit Gent * Copyright (C) 2009 DENIZET Calixte - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. - * + * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. - * + * * A copy of the GNU General Public License can be found in the file * LICENSE.txt provided with the source distribution of this program (see * the META-INF directory in the source jar). This license can also be * found on the GNU website at http://www.gnu.org/licenses/gpl.html. - * + * * If you did not receive a copy of the GNU General Public License along * with this program, contact the lead developer, or write to the Free * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. - * + * */ /* Modified by Calixte Denizet */ @@ -38,117 +38,117 @@ * according to the height of the base. */ public class FencedAtom extends Atom { - + // parameters used in the TeX algorithm private static final int DELIMITER_FACTOR = 901; - + private static final float DELIMITER_SHORTFALL = 5f; // base atom private final Atom base; - + // delimiters - private SymbolAtom left = null; + private SymbolAtom left = null; private SymbolAtom right = null; private final List middle; - + /** * Creates a new FencedAtom from the given base and delimiters - * + * * @param base the base to be surrounded with delimiters * @param l the left delimiter * @param r the right delimiter */ public FencedAtom(Atom base, SymbolAtom l, SymbolAtom r) { - this(base, l, null, r); + this(base, l, null, r); } - + public FencedAtom(Atom base, SymbolAtom l, List m, SymbolAtom r) { - if (base == null) - this.base = new RowAtom(); // empty base - else - this.base = base; - if (l == null || !l.getName().equals("normaldot")) { - left = l; - } - if (r == null || !r.getName().equals("normaldot")) { - right = r; - } - middle = m; + if (base == null) + this.base = new RowAtom(); // empty base + else + this.base = base; + if (l == null || !l.getName().equals("normaldot")) { + left = l; + } + if (r == null || !r.getName().equals("normaldot")) { + right = r; + } + middle = m; } - + public int getLeftType() { - return TeXConstants.TYPE_OPENING; + return TeXConstants.TYPE_INNER; } - + public int getRightType() { - return TeXConstants.TYPE_CLOSING; + return TeXConstants.TYPE_INNER; } - + /** - * Centers the given box with resprect to the given axis, by setting an appropriate - * shift value. - * - * @param box - * box to be vertically centered with respect to the axis - */ + * Centers the given box with resprect to the given axis, by setting an appropriate + * shift value. + * + * @param box + * box to be vertically centered with respect to the axis + */ private static void center(Box box, float axis) { - float h = box.getHeight(), total = h + box.getDepth(); - box.setShift(-(total / 2 - h) - axis); + float h = box.getHeight(), total = h + box.getDepth(); + box.setShift(-(total / 2 - h) - axis); } - + public Box createBox(TeXEnvironment env) { - TeXFont tf = env.getTeXFont(); - Box content = base.createBox(env); - float shortfall = DELIMITER_SHORTFALL * SpaceAtom.getFactor(TeXConstants.UNIT_POINT, env); - float axis = tf.getAxisHeight(env.getStyle()); - float delta = Math.max(content.getHeight() - axis, content.getDepth() + axis); - float minHeight = Math.max((delta / 500) * DELIMITER_FACTOR, 2 * delta - shortfall); - - // construct box - HorizontalBox hBox = new HorizontalBox(); - - if (middle != null) { - for (int i = 0; i < middle.size(); i++) { - MiddleAtom at = middle.get(i); - if (at.base instanceof SymbolAtom) { - Box b = DelimiterFactory.create(((SymbolAtom) at.base).getName(), env, minHeight); - center(b, axis); - at.box = b; - } - } - if (middle.size() != 0) { - content = base.createBox(env); - } - } - - // left delimiter - if (left != null) { - Box b = DelimiterFactory.create(left.getName(), env, minHeight); - center(b, axis); - hBox.add(b); - } - - // glue between left delimiter and content (if not whitespace) - if (!(base instanceof SpaceAtom)) { - hBox.add(Glue.get(TeXConstants.TYPE_OPENING, base.getLeftType(), env)); - } - - // add content - hBox.add(content); - - // glue between right delimiter and content (if not whitespace) - if (!(base instanceof SpaceAtom)) { - hBox.add(Glue.get(base.getRightType(), TeXConstants.TYPE_CLOSING, env)); - } - - // right delimiter - if (right != null) { - Box b = DelimiterFactory.create(right.getName(), env, minHeight); - center(b, axis); - hBox.add(b); - } + TeXFont tf = env.getTeXFont(); + Box content = base.createBox(env); + float shortfall = DELIMITER_SHORTFALL * SpaceAtom.getFactor(TeXConstants.UNIT_POINT, env); + float axis = tf.getAxisHeight(env.getStyle()); + float delta = Math.max(content.getHeight() - axis, content.getDepth() + axis); + float minHeight = Math.max((delta / 500) * DELIMITER_FACTOR, 2 * delta - shortfall); + + // construct box + HorizontalBox hBox = new HorizontalBox(); + + if (middle != null) { + for (int i = 0; i < middle.size(); i++) { + MiddleAtom at = middle.get(i); + if (at.base instanceof SymbolAtom) { + Box b = DelimiterFactory.create(((SymbolAtom) at.base).getName(), env, minHeight); + center(b, axis); + at.box = b; + } + } + if (middle.size() != 0) { + content = base.createBox(env); + } + } + + // left delimiter + if (left != null) { + Box b = DelimiterFactory.create(left.getName(), env, minHeight); + center(b, axis); + hBox.add(b); + } + + // glue between left delimiter and content (if not whitespace) + if (!(base instanceof SpaceAtom)) { + hBox.add(Glue.get(TeXConstants.TYPE_OPENING, base.getLeftType(), env)); + } + + // add content + hBox.add(content); + + // glue between right delimiter and content (if not whitespace) + if (!(base instanceof SpaceAtom)) { + hBox.add(Glue.get(base.getRightType(), TeXConstants.TYPE_CLOSING, env)); + } + + // right delimiter + if (right != null) { + Box b = DelimiterFactory.create(right.getName(), env, minHeight); + center(b, axis); + hBox.add(b); + } - return hBox; - } + return hBox; + } } diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/FontInfo.java libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/FontInfo.java --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/FontInfo.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/FontInfo.java 2011-11-22 17:18:16.000000000 +0000 @@ -43,7 +43,7 @@ */ public static final int NUMBER_OF_CHAR_CODES = 256; - private static Map fonts = new HashMap(); + private static Map fonts = new HashMap(); private class CharCouple { @@ -113,7 +113,7 @@ this.itVersion = itVersion; int num = NUMBER_OF_CHAR_CODES; if (unicode != 0) { - this.unicode = new HashMap(unicode); + this.unicode = new HashMap(unicode); num = unicode; } metrics = new float[num][]; diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/fonts/base/jlm_base.map.xml libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/fonts/base/jlm_base.map.xml --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/fonts/base/jlm_base.map.xml 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/fonts/base/jlm_base.map.xml 2011-11-22 17:18:16.000000000 +0000 @@ -14,7 +14,7 @@ - + Binary files /tmp/Cwu3pjs0fn/libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/fonts/latin/optional/jlm_cmssbx10.ttf and /tmp/LIIfw1myf3/libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/fonts/latin/optional/jlm_cmssbx10.ttf differ Binary files /tmp/Cwu3pjs0fn/libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/fonts/latin/optional/jlm_cmti10.ttf and /tmp/LIIfw1myf3/libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/fonts/latin/optional/jlm_cmti10.ttf differ Binary files /tmp/Cwu3pjs0fn/libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/fonts/latin/optional/jlm_cmtt10.ttf and /tmp/LIIfw1myf3/libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/fonts/latin/optional/jlm_cmtt10.ttf differ diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/greek/LICENSE libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/greek/LICENSE --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/greek/LICENSE 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/greek/LICENSE 2011-11-22 17:18:16.000000000 +0000 @@ -3,7 +3,7 @@ many more LaTeX commands, drop of the jdom dependency and easy evolution capabilities. -Copyright (C) 2009 DENIZET Calixte +Copyright (C) 2009-2011 DENIZET Calixte Copyright (C) Kris Coolsaet Copyright (C) Nico Van Cleemput Copyright (C) Kurt Vermeulen @@ -22,7 +22,8 @@ You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +MA 02110-1301, USA. diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/HorizontalBox.java libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/HorizontalBox.java --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/HorizontalBox.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/HorizontalBox.java 2011-11-22 17:18:16.000000000 +0000 @@ -31,82 +31,134 @@ import java.awt.Color; import java.awt.Graphics2D; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; import java.util.ListIterator; /** * A box composed of a horizontal row of child boxes. */ public class HorizontalBox extends Box { - + private float curPos = 0; // NOPMD - + protected List breakPositions; + public HorizontalBox(Box b, float w, int alignment) { - if (w != Float.POSITIVE_INFINITY) { - float rest = w - b.getWidth(); - if (alignment == TeXConstants.ALIGN_CENTER || alignment == TeXConstants.ALIGN_NONE) { - StrutBox s = new StrutBox(rest / 2, 0, 0, 0); - add(s); - add(b); - add(s); - } else if (alignment == TeXConstants.ALIGN_LEFT) { - add(b); - add(new StrutBox(rest, 0, 0, 0)); - } else if (alignment == TeXConstants.ALIGN_RIGHT) { - add(new StrutBox(rest, 0, 0, 0)); - add(b); - } else - add(b); - } else { - add(b); - } + if (w != Float.POSITIVE_INFINITY) { + float rest = w - b.getWidth(); + if (alignment == TeXConstants.ALIGN_CENTER || alignment == TeXConstants.ALIGN_NONE) { + StrutBox s = new StrutBox(rest / 2, 0, 0, 0); + add(s); + add(b); + add(s); + } else if (alignment == TeXConstants.ALIGN_LEFT) { + add(b); + add(new StrutBox(rest, 0, 0, 0)); + } else if (alignment == TeXConstants.ALIGN_RIGHT) { + add(new StrutBox(rest, 0, 0, 0)); + add(b); + } else + add(b); + } else { + add(b); + } } - + public HorizontalBox(Box b) { add(b); } - + public HorizontalBox() { // basic horizontal box } - + public HorizontalBox(Color fg, Color bg) { super(fg, bg); } - + + public HorizontalBox cloneBox() { + HorizontalBox b = new HorizontalBox(foreground, background); + b.shift = shift; + + return b; + } + public void draw(Graphics2D g2, float x, float y) { startDraw(g2, x, y); - float xPos = x; + float xPos = x; for (Box box: children) { + /*int i = children.indexOf(box); + if (breakPositions != null && breakPositions.indexOf(i) != -1) { + box.markForDEBUG = java.awt.Color.BLUE; + }*/ + box.draw(g2, xPos, y + box.shift); xPos += box.getWidth(); } endDraw(g2); } - + public final void add(Box b) { recalculate(b); super.add(b); } - + public final void add(int pos, Box b) { recalculate(b); super.add(pos, b); } - + private void recalculate(Box b) { curPos += b.getWidth(); width = Math.max(width, curPos); height = Math.max((children.size() == 0 ? Float.NEGATIVE_INFINITY : height), b.height - b.shift); depth = Math.max((children.size() == 0 ? Float.NEGATIVE_INFINITY : depth), b.depth + b.shift); } - + public int getLastFontId() { // iterate from the last child box to the first untill a font id is found // that's not equal to NO_FONT int fontId = TeXFont.NO_FONT; for (ListIterator it = children.listIterator(children.size()); fontId == TeXFont.NO_FONT && it.hasPrevious();) fontId = ((Box) it.previous()).getLastFontId(); - + return fontId; } + + public void addBreakPosition(int pos) { + if (breakPositions == null) { + breakPositions = new ArrayList(); + } + breakPositions.add(pos); + } + + protected HorizontalBox[] split(int position) { + return split(position, 1); + } + + protected HorizontalBox[] splitRemove(int position) { + return split(position, 2); + } + + private HorizontalBox[] split(int position, int shift) { + HorizontalBox hb1 = cloneBox(); + HorizontalBox hb2 = cloneBox(); + for (int i = 0; i <= position; i++) { + hb1.add(children.get(i)); + } + for (int i = position + shift; i < children.size(); i++) { + hb2.add(children.get(i)); + } + + if (breakPositions != null) { + for (int i = 0; i < breakPositions.size(); i++) { + if (breakPositions.get(i) > position + 1) { + hb2.addBreakPosition(breakPositions.get(i) - position - 1); + } + } + } + + return new HorizontalBox[]{hb1, hb2}; + } } diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/MatrixAtom.java libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/MatrixAtom.java --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/MatrixAtom.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/MatrixAtom.java 2011-11-22 17:18:16.000000000 +0000 @@ -58,7 +58,7 @@ private ArrayOfAtoms matrix; private int[] position; - private Map vlines = new HashMap(); + private Map vlines = new HashMap(); private boolean isAlign; private boolean isAlignat; private boolean isFl; @@ -101,7 +101,7 @@ } } else { position = new int[matrix.col]; - for (int i = 0; i < matrix.col; i += 2) { + for (int i = 0; i < matrix.col; i++) { position[i] = TeXConstants.ALIGN_CENTER; } } @@ -117,7 +117,7 @@ char ch; TeXFormula tf; TeXParser tp; - List lposition = new ArrayList(); + List lposition = new ArrayList(); while (pos < len) { ch = opt.charAt(pos); switch (ch) { @@ -328,7 +328,7 @@ env.setStyle(TeXConstants.STYLE_SCRIPT); } - List listMulti = new ArrayList(); + List listMulti = new ArrayList(); for (int i = 0; i < row; i++) { lineDepth[i] = 0; diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/PredefinedCommands.java libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/PredefinedCommands.java --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/PredefinedCommands.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/PredefinedCommands.java 2011-12-02 14:11:22.000000000 +0000 @@ -231,7 +231,7 @@ MacroInfo.Commands.put("k", new PredefMacroInfo(195, 1)); MacroInfo.Commands.put("cong", new PredefMacroInfo(196, 0)); MacroInfo.Commands.put("doteq", new PredefMacroInfo(197, 0)); - MacroInfo.Commands.put("jlmDynamic", new PredefMacroInfo(198, 1)); + MacroInfo.Commands.put("jlmDynamic", new PredefMacroInfo(198, 1, 1)); MacroInfo.Commands.put("jlmExternalFont", new PredefMacroInfo(199, 1)); MacroInfo.Commands.put("jlmText", new PredefMacroInfo(200, 1)); MacroInfo.Commands.put("jlmTextit", new PredefMacroInfo(201, 1)); @@ -304,5 +304,9 @@ MacroInfo.Commands.put("oint", new PredefMacroInfo(268, 0)); MacroInfo.Commands.put("lmoustache", new PredefMacroInfo(269, 0)); MacroInfo.Commands.put("rmoustache", new PredefMacroInfo(270, 0)); + MacroInfo.Commands.put("-", new PredefMacroInfo(271, 0)); + MacroInfo.Commands.put("jlmXML", new PredefMacroInfo(272, 1)); + MacroInfo.Commands.put("above", new PredefMacroInfo(273, 0)); + MacroInfo.Commands.put("abovewithdelims", new PredefMacroInfo(274, 2)); } } diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/PredefinedTeXFormulaParser.java libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/PredefinedTeXFormulaParser.java --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/PredefinedTeXFormulaParser.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/PredefinedTeXFormulaParser.java 2011-11-22 17:18:16.000000000 +0000 @@ -80,9 +80,9 @@ // parse and build the formula and add it to the table if ("TeXFormula".equals(this.type)) - predefinedTeXFormulas.put(name, (TeXFormula)new TeXFormulaParser(name, formula, this.type).parse()); + predefinedTeXFormulas.put(name, (TeXFormula) new TeXFormulaParser(name, formula, this.type).parse()); else - predefinedTeXFormulas.put(name, (MacroInfo)new TeXFormulaParser(name, formula, this.type).parse()); + predefinedTeXFormulas.put(name, (MacroInfo) new TeXFormulaParser(name, formula, this.type).parse()); } } } diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/PredefinedTeXFormulas.java libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/PredefinedTeXFormulas.java --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/PredefinedTeXFormulas.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/PredefinedTeXFormulas.java 2011-11-22 17:18:16.000000000 +0000 @@ -88,7 +88,7 @@ TeXFormula.predefinedTeXFormulasAsString.put("sinh", "\\mathop{\\mathrm{sinh}}\\nolimits"); TeXFormula.predefinedTeXFormulasAsString.put("cos", "\\mathop{\\mathrm{cos}}\\nolimits"); TeXFormula.predefinedTeXFormulasAsString.put("arccos", "\\mathop{\\mathrm{arccos}}\\nolimits"); - TeXFormula.predefinedTeXFormulasAsString.put("cot", "\\mathop{\\mathrm{cos}}\\nolimits"); + TeXFormula.predefinedTeXFormulasAsString.put("cot", "\\mathop{\\mathrm{cot}}\\nolimits"); TeXFormula.predefinedTeXFormulasAsString.put("arccot", "\\mathop{\\mathrm{arccot}}\\nolimits"); TeXFormula.predefinedTeXFormulasAsString.put("cosh", "\\mathop{\\mathrm{cosh}}\\nolimits"); TeXFormula.predefinedTeXFormulasAsString.put("tan", "\\mathop{\\mathrm{tan}}\\nolimits"); diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/PredefMacroInfo.java libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/PredefMacroInfo.java --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/PredefMacroInfo.java 2011-05-08 11:41:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/PredefMacroInfo.java 2011-12-02 14:14:50.000000000 +0000 @@ -512,38 +512,46 @@ return PredefMacros.textsc_macro(tp, args); case 250: return PredefMacros.sc_macro(tp, args); - case 251: - case 252: - case 253: - case 254: - case 255: - case 256: - case 257: - case 258: - case 259: - case 260: + case 251: + case 252: + case 253: + case 254: + case 255: + case 256: + case 257: + case 258: + case 259: + case 260: return PredefMacros.muskip_macros(tp, args); - case 261: + case 261: return PredefMacros.quad_macro(tp, args); case 262: return PredefMacros.surd_macro(tp, args); - case 263: + case 263: return PredefMacros.iint_macro(tp, args); - case 264: + case 264: return PredefMacros.iiint_macro(tp, args); - case 265: + case 265: return PredefMacros.iiiint_macro(tp, args); - case 266: + case 266: return PredefMacros.idotsint_macro(tp, args); - case 267: + case 267: return PredefMacros.int_macro(tp, args); case 268: return PredefMacros.oint_macro(tp, args); case 269: return PredefMacros.lmoustache_macro(tp, args); - case 270: + case 270: return PredefMacros.rmoustache_macro(tp, args); - default: + case 271: + return PredefMacros.insertBreakMark_macro(tp, args); + case 272: + return PredefMacros.jlmXML_macro(tp, args); + case 273: + return PredefMacros.above_macro(tp, args); + case 274: + return PredefMacros.abovewithdelims_macro(tp, args); + default: return null; } } catch (Exception e) { diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/PredefMacros.java libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/PredefMacros.java --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/PredefMacros.java 2011-05-08 17:39:24.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/PredefMacros.java 2011-12-02 14:15:20.000000000 +0000 @@ -30,6 +30,7 @@ import java.awt.Color; import java.awt.Font; +import java.util.Map; import java.util.StringTokenizer; import org.scilab.forge.jlatexmath.dynamic.DynamicAtom; @@ -101,12 +102,12 @@ public static final Atom Braket_macro(final TeXParser tp, final String[] args) throws ParseException { String str = args[1].replaceAll("\\|", "\\\\middle\\\\vert "); - return new TeXFormula(tp.getIsPartial(), "\\left\\langle " + str + "\\right\\rangle").root; + return new TeXFormula(tp, "\\left\\langle " + str + "\\right\\rangle").root; } public static final Atom Set_macro(final TeXParser tp, final String[] args) throws ParseException { String str = args[1].replaceFirst("\\|", "\\\\middle\\\\vert "); - return new TeXFormula(tp.getIsPartial(), "\\left\\{" + str + "\\right\\}").root; + return new TeXFormula(tp, "\\left\\{" + str + "\\right\\}").root; } public static final Atom spATbreve_macro(final TeXParser tp, final String[] args) throws ParseException { @@ -148,11 +149,11 @@ } public static final Atom clrlap_macro(final TeXParser tp, final String[] args) throws ParseException { - return new LapedAtom(new TeXFormula(tp.getIsPartial(), args[1]).root, args[0].charAt(0)); + return new LapedAtom(new TeXFormula(tp, args[1]).root, args[0].charAt(0)); } public static final Atom mathclrlap_macro(final TeXParser tp, final String[] args) throws ParseException { - return new LapedAtom(new TeXFormula(tp.getIsPartial(), args[1]).root, args[0].charAt(4)); + return new LapedAtom(new TeXFormula(tp, args[1]).root, args[0].charAt(4)); } public static final Atom includegraphics_macro(final TeXParser tp, final String[] args) throws ParseException { @@ -185,8 +186,8 @@ } else if ("l".equals(args[3])) { alig = TeXConstants.ALIGN_LEFT; } - TeXFormula num = new TeXFormula(tp.getIsPartial(), args[1], false); - TeXFormula denom = new TeXFormula(tp.getIsPartial(), args[2], false); + TeXFormula num = new TeXFormula(tp, args[1], false); + TeXFormula denom = new TeXFormula(tp, args[2], false); if (num.root == null || denom.root == null) { throw new ParseException("Both numerator and denominator of a fraction can't be empty!"); } @@ -197,16 +198,16 @@ } public static final Atom frac_macro(final TeXParser tp, final String[] args) throws ParseException { - TeXFormula num = new TeXFormula(tp.getIsPartial(), args[1], false); - TeXFormula denom = new TeXFormula(tp.getIsPartial(), args[2], false); + TeXFormula num = new TeXFormula(tp, args[1], false); + TeXFormula denom = new TeXFormula(tp, args[2], false); if (num.root == null || denom.root == null) throw new ParseException("Both numerator and denominator of a fraction can't be empty!"); return new FractionAtom(num.root, denom.root, true); } public static final Atom sfrac_macro(final TeXParser tp, final String[] args) throws ParseException { - TeXFormula num = new TeXFormula(tp.getIsPartial(), args[1], false); - TeXFormula denom = new TeXFormula(tp.getIsPartial(), args[2], false); + TeXFormula num = new TeXFormula(tp, args[1], false); + TeXFormula denom = new TeXFormula(tp, args[2], false); if (num.root == null || denom.root == null) throw new ParseException("Both numerator and denominator of a fraction can't be empty!"); @@ -239,13 +240,13 @@ } public static final Atom genfrac_macro(final TeXParser tp, final String[] args) throws ParseException { - TeXFormula left = new TeXFormula(tp.getIsPartial(), args[1], false); + TeXFormula left = new TeXFormula(tp, args[1], false); SymbolAtom L = null, R = null; if (left != null && left.root instanceof SymbolAtom) { L = (SymbolAtom) left.root; } - TeXFormula right = new TeXFormula(tp.getIsPartial(), args[2], false); + TeXFormula right = new TeXFormula(tp, args[2], false); if (right != null && right.root instanceof SymbolAtom) { R = (SymbolAtom) right.root; } @@ -261,8 +262,8 @@ if (args[4].length() != 0) { style = Integer.parseInt(args[4]); } - TeXFormula num = new TeXFormula(tp.getIsPartial(), args[5], false); - TeXFormula denom = new TeXFormula(tp.getIsPartial(), args[6], false); + TeXFormula num = new TeXFormula(tp, args[5], false); + TeXFormula denom = new TeXFormula(tp, args[6], false); if (num.root == null || denom.root == null) throw new ParseException("Both numerator and denominator of a fraction can't be empty!"); Atom at = new FractionAtom(num.root, denom.root, rule, (int) ths[0], ths[1]); @@ -274,7 +275,7 @@ public static final Atom over_macro(final TeXParser tp, final String[] args) throws ParseException { Atom num = tp.getFormulaAtom(); - Atom denom = new TeXFormula(tp.getIsPartial(), tp.getOverArgument(), false).root; + Atom denom = new TeXFormula(tp, tp.getOverArgument(), false).root; if (num == null || denom == null) throw new ParseException("Both numerator and denominator of a fraction can't be empty!"); return new FractionAtom(num, denom, true); @@ -282,15 +283,15 @@ public static final Atom overwithdelims_macro(final TeXParser tp, final String[] args) throws ParseException { Atom num = tp.getFormulaAtom(); - Atom denom = new TeXFormula(tp.getIsPartial(), tp.getOverArgument(), false).root; + Atom denom = new TeXFormula(tp, tp.getOverArgument(), false).root; if (num == null || denom == null) throw new ParseException("Both numerator and denominator of a fraction can't be empty!"); - Atom left = new TeXFormula(tp.getIsPartial(), args[1], false).root; + Atom left = new TeXFormula(tp, args[1], false).root; if (left instanceof BigDelimiterAtom) left = ((BigDelimiterAtom)left).delim; - Atom right = new TeXFormula(tp.getIsPartial(), args[2], false).root; + Atom right = new TeXFormula(tp, args[2], false).root; if (right instanceof BigDelimiterAtom) right = ((BigDelimiterAtom)right).delim; if (left instanceof SymbolAtom && right instanceof SymbolAtom) { @@ -306,7 +307,7 @@ public static final Atom atop_macro(final TeXParser tp, final String[] args) throws ParseException { Atom num = tp.getFormulaAtom(); - Atom denom = new TeXFormula(tp.getIsPartial(), tp.getOverArgument(), false).root; + Atom denom = new TeXFormula(tp, tp.getOverArgument(), false).root; if (num == null || denom == null) throw new ParseException("Both numerator and denominator of a fraction can't be empty!"); return new FractionAtom(num, denom, false); @@ -314,15 +315,15 @@ public static final Atom atopwithdelims_macro(final TeXParser tp, final String[] args) throws ParseException { Atom num = tp.getFormulaAtom(); - Atom denom = new TeXFormula(tp.getIsPartial(), tp.getOverArgument(), false).root; + Atom denom = new TeXFormula(tp, tp.getOverArgument(), false).root; if (num == null || denom == null) throw new ParseException("Both numerator and denominator of a fraction can't be empty!"); - Atom left = new TeXFormula(tp.getIsPartial(), args[1], false).root; + Atom left = new TeXFormula(tp, args[1], false).root; if (left instanceof BigDelimiterAtom) left = ((BigDelimiterAtom)left).delim; - Atom right = new TeXFormula(tp.getIsPartial(), args[2], false).root; + Atom right = new TeXFormula(tp, args[2], false).root; if (right instanceof BigDelimiterAtom) right = ((BigDelimiterAtom)right).delim; if (left instanceof SymbolAtom && right instanceof SymbolAtom) { @@ -338,20 +339,60 @@ public static final Atom choose_macro(final TeXParser tp, final String[] args) throws ParseException { Atom num = tp.getFormulaAtom(); - Atom denom = new TeXFormula(tp.getIsPartial(), tp.getOverArgument(), false).root; + Atom denom = new TeXFormula(tp, tp.getOverArgument(), false).root; if (num == null || denom == null) throw new ParseException("Both numerator and denominator of choose can't be empty!"); return new FencedAtom(new FractionAtom(num, denom, false), new SymbolAtom("lbrack", TeXConstants.TYPE_OPENING, true), new SymbolAtom("rbrack", TeXConstants.TYPE_CLOSING, true)); } public static final Atom binom_macro(final TeXParser tp, final String[] args) throws ParseException { - TeXFormula num = new TeXFormula(tp.getIsPartial(), args[1], false); - TeXFormula denom = new TeXFormula(tp.getIsPartial(), args[2], false); + TeXFormula num = new TeXFormula(tp, args[1], false); + TeXFormula denom = new TeXFormula(tp, args[2], false); if (num.root == null || denom.root == null) throw new ParseException("Both binomial coefficients must be not empty !!"); return new FencedAtom(new FractionAtom(num.root, denom.root, false), new SymbolAtom("lbrack", TeXConstants.TYPE_OPENING, true), new SymbolAtom("rbrack", TeXConstants.TYPE_CLOSING, true)); } + public static final Atom above_macro(final TeXParser tp, final String[] args) throws ParseException { + Atom num = tp.getFormulaAtom(); + float[] dim = tp.getLength(); + Atom denom = new TeXFormula(tp, tp.getOverArgument(), false).root; + if (dim == null || dim.length != 2) { + throw new ParseException("Invalid length in above macro"); + } + if (num == null || denom == null) + throw new ParseException("Both numerator and denominator of a fraction can't be empty!"); + + return new FractionAtom(num, denom, (int) dim[0], dim[1]); + } + + public static final Atom abovewithdelims_macro(final TeXParser tp, final String[] args) throws ParseException { + Atom num = tp.getFormulaAtom(); + float[] dim = tp.getLength(); + Atom denom = new TeXFormula(tp, tp.getOverArgument(), false).root; + if (dim == null || dim.length != 2) { + throw new ParseException("Invalid length in above macro"); + } + if (num == null || denom == null) + throw new ParseException("Both numerator and denominator of a fraction can't be empty!"); + + Atom left = new TeXFormula(tp, args[1], false).root; + if (left instanceof BigDelimiterAtom) + left = ((BigDelimiterAtom)left).delim; + Atom right = new TeXFormula(tp, args[2], false).root; + if (right instanceof BigDelimiterAtom) + right = ((BigDelimiterAtom)right).delim; + if (left instanceof SymbolAtom && right instanceof SymbolAtom) { + return new FencedAtom(new FractionAtom(num, denom, (int) dim[0], dim[1]), (SymbolAtom) left, (SymbolAtom) right); + } + + RowAtom ra = new RowAtom(); + ra.add(left); + ra.add(new FractionAtom(num, denom, true)); + ra.add(right); + return ra; + } + public static final Atom textstyle_macros(final TeXParser tp, final String[] args) throws ParseException { String style = args[0]; if ("frak".equals(args[0])) @@ -359,7 +400,7 @@ else if ("Bbb".equals(args[0])) style = "mathbb"; else if ("bold".equals(args[0])) - return new BoldAtom(new TeXFormula(tp.getIsPartial(), args[1], false).root); + return new BoldAtom(new TeXFormula(tp, args[1], false).root); else if ("cal".equals(args[0])) style = "mathcal"; @@ -367,7 +408,7 @@ if (fontInfos != null) { TeXFormula.externalFontMap.put(Character.UnicodeBlock.BASIC_LATIN, null); } - Atom at = new TeXFormula(tp.getIsPartial(), args[1], false).root; + Atom at = new TeXFormula(tp, args[1], false).root; if (fontInfos != null) { TeXFormula.externalFontMap.put(Character.UnicodeBlock.BASIC_LATIN, fontInfos); } @@ -377,13 +418,13 @@ public static final Atom mbox_macro(final TeXParser tp, final String[] args) throws ParseException { String str = args[1].replaceAll("_", "\\\\_"); - Atom group = new RomanAtom(new TeXFormula(tp.getIsPartial(), str, "mathnormal", false, false).root); + Atom group = new RomanAtom(new TeXFormula(tp, str, "mathnormal", false, false).root); return new StyleAtom(TeXConstants.STYLE_TEXT, group); } public static final Atom text_macro(final TeXParser tp, final String[] args) throws ParseException { String str = args[1].replaceAll("_", "\\\\_"); - return new RomanAtom(new TeXFormula(tp.getIsPartial(), str, "mathnormal", false, false).root); + return new RomanAtom(new TeXFormula(tp, str, "mathnormal", false, false).root); } public static final Atom underscore_macro(final TeXParser tp, final String[] args) throws ParseException { @@ -391,15 +432,15 @@ } public static final Atom accent_macros(final TeXParser tp, final String[] args) throws ParseException { - return new AccentedAtom(new TeXFormula(tp.getIsPartial(), args[1], false).root, args[0]); + return new AccentedAtom(new TeXFormula(tp, args[1], false).root, args[0]); } public static final Atom grkaccent_macro(final TeXParser tp, final String[] args) throws ParseException { - return new AccentedAtom(new TeXFormula(tp.getIsPartial(), args[2], false).root, new TeXFormula(tp.getIsPartial(), args[1], false).root, false); + return new AccentedAtom(new TeXFormula(tp, args[2], false).root, new TeXFormula(tp, args[1], false).root, false); } public static final Atom accent_macro(final TeXParser tp, final String[] args) throws ParseException { - return new AccentedAtom(new TeXFormula(tp.getIsPartial(), args[2], false).root, new TeXFormula(tp.getIsPartial(), args[1], false).root); + return new AccentedAtom(new TeXFormula(tp, args[2], false).root, new TeXFormula(tp, args[1], false).root); } public static final Atom accentbis_macros(final TeXParser tp, final String[] args) throws ParseException { @@ -445,11 +486,11 @@ acc = "cyrbreve"; } - return new AccentedAtom(new TeXFormula(tp.getIsPartial(), args[1], false).root, acc); + return new AccentedAtom(new TeXFormula(tp, args[1], false).root, acc); } public static final Atom cedilla_macro(final TeXParser tp, final String[] args) throws ParseException { - return new CedillaAtom(new TeXFormula(tp.getIsPartial(), args[1]).root); + return new CedillaAtom(new TeXFormula(tp, args[1]).root); } public static final Atom IJ_macro(final TeXParser tp, final String[] args) throws ParseException { @@ -469,7 +510,7 @@ } public static final Atom ogonek_macro(final TeXParser tp, final String[] args) throws ParseException { - return new OgonekAtom(new TeXFormula(tp.getIsPartial(), args[1]).root); + return new OgonekAtom(new TeXFormula(tp, args[1]).root); } public static final Atom nbsp_macro(final TeXParser tp, final String[] args) throws ParseException { @@ -478,45 +519,45 @@ public static final Atom sqrt_macro(final TeXParser tp, final String[] args) throws ParseException { if (args[2] == null) - return new NthRoot(new TeXFormula(tp.getIsPartial(), args[1], false).root, null); - return new NthRoot(new TeXFormula(tp.getIsPartial(), args[1], false).root, new TeXFormula(tp.getIsPartial(), args[2], false).root); + return new NthRoot(new TeXFormula(tp, args[1], false).root, null); + return new NthRoot(new TeXFormula(tp, args[1], false).root, new TeXFormula(tp, args[2], false).root); } public static final Atom overrightarrow_macro(final TeXParser tp, final String[] args) throws ParseException { - return new UnderOverArrowAtom(new TeXFormula(tp.getIsPartial(), args[1], false).root, false, true); + return new UnderOverArrowAtom(new TeXFormula(tp, args[1], false).root, false, true); } public static final Atom overleftarrow_macro(final TeXParser tp, final String[] args) throws ParseException { - return new UnderOverArrowAtom(new TeXFormula(tp.getIsPartial(), args[1], false).root, true, true); + return new UnderOverArrowAtom(new TeXFormula(tp, args[1], false).root, true, true); } public static final Atom overleftrightarrow_macro(final TeXParser tp, final String[] args) throws ParseException { - return new UnderOverArrowAtom(new TeXFormula(tp.getIsPartial(), args[1], false).root, true); + return new UnderOverArrowAtom(new TeXFormula(tp, args[1], false).root, true); } public static final Atom underrightarrow_macro(final TeXParser tp, final String[] args) throws ParseException { - return new UnderOverArrowAtom(new TeXFormula(tp.getIsPartial(), args[1], false).root, false, false); + return new UnderOverArrowAtom(new TeXFormula(tp, args[1], false).root, false, false); } public static final Atom underleftarrow_macro(final TeXParser tp, final String[] args) throws ParseException { - return new UnderOverArrowAtom(new TeXFormula(tp.getIsPartial(), args[1], false).root, true, false); + return new UnderOverArrowAtom(new TeXFormula(tp, args[1], false).root, true, false); } public static final Atom underleftrightarrow_macro(final TeXParser tp, final String[] args) throws ParseException { - return new UnderOverArrowAtom(new TeXFormula(tp.getIsPartial(), args[1], false).root, false); + return new UnderOverArrowAtom(new TeXFormula(tp, args[1], false).root, false); } public static final Atom xleftarrow_macro(final TeXParser tp, final String[] args) throws ParseException { - return new XArrowAtom(new TeXFormula(tp.getIsPartial(), args[1], false).root, new TeXFormula(tp.getIsPartial(), args[2]).root, true); + return new XArrowAtom(new TeXFormula(tp, args[1], false).root, new TeXFormula(tp, args[2]).root, true); } public static final Atom xrightarrow_macro(final TeXParser tp, final String[] args) throws ParseException { - return new XArrowAtom(new TeXFormula(tp.getIsPartial(), args[1], false).root, new TeXFormula(tp.getIsPartial(), args[2]).root, false); + return new XArrowAtom(new TeXFormula(tp, args[1], false).root, new TeXFormula(tp, args[2]).root, false); } public static final Atom sideset_macro(final TeXParser tp, final String[] args) throws ParseException { TeXFormula tf = new TeXFormula(); - tf.add(new PhantomAtom(new TeXFormula(tp.getIsPartial(), args[3]).root, false, true, true)); + tf.add(new PhantomAtom(new TeXFormula(tp, args[3]).root, false, true, true)); tf.append(tp.getIsPartial(), args[1]); tf.add(new SpaceAtom(TeXConstants.UNIT_MU, -0.3f, 0f, 0f)); tf.append(tp.getIsPartial(), args[3] + "\\nolimits" + args[2]); @@ -524,76 +565,76 @@ } public static final Atom prescript_macro(final TeXParser tp, final String[] args) throws ParseException { - Atom base = new TeXFormula(tp.getIsPartial(), args[3]).root; - tp.addAtom(new ScriptsAtom(new PhantomAtom(base, false, true, true), new TeXFormula(tp.getIsPartial(), args[2]).root, new TeXFormula(tp.getIsPartial(), args[1]).root, false)); + Atom base = new TeXFormula(tp, args[3]).root; + tp.addAtom(new ScriptsAtom(new PhantomAtom(base, false, true, true), new TeXFormula(tp, args[2]).root, new TeXFormula(tp, args[1]).root, false)); tp.addAtom(new SpaceAtom(TeXConstants.UNIT_MU, -0.3f, 0f, 0f)); return new TypedAtom(TeXConstants.TYPE_ORDINARY, TeXConstants.TYPE_ORDINARY, base); } public static final Atom underbrace_macro(final TeXParser tp, final String[] args) throws ParseException { - return new OverUnderDelimiter(new TeXFormula(tp.getIsPartial(), args[1], false).root, null, SymbolAtom.get("rbrace"), TeXConstants.UNIT_EX, 0, false); + return new OverUnderDelimiter(new TeXFormula(tp, args[1], false).root, null, SymbolAtom.get("rbrace"), TeXConstants.UNIT_EX, 0, false); } public static final Atom overbrace_macro(final TeXParser tp, final String[] args) throws ParseException { - return new OverUnderDelimiter(new TeXFormula(tp.getIsPartial(), args[1], false).root, null, SymbolAtom.get("lbrace"), TeXConstants.UNIT_EX, 0, true); + return new OverUnderDelimiter(new TeXFormula(tp, args[1], false).root, null, SymbolAtom.get("lbrace"), TeXConstants.UNIT_EX, 0, true); } public static final Atom underbrack_macro(final TeXParser tp, final String[] args) throws ParseException { - return new OverUnderDelimiter(new TeXFormula(tp.getIsPartial(), args[1], false).root, null, SymbolAtom.get("rsqbrack"), TeXConstants.UNIT_EX, 0, false); + return new OverUnderDelimiter(new TeXFormula(tp, args[1], false).root, null, SymbolAtom.get("rsqbrack"), TeXConstants.UNIT_EX, 0, false); } public static final Atom overbrack_macro(final TeXParser tp, final String[] args) throws ParseException { - return new OverUnderDelimiter(new TeXFormula(tp.getIsPartial(), args[1], false).root, null, SymbolAtom.get("lsqbrack"), TeXConstants.UNIT_EX, 0, true); + return new OverUnderDelimiter(new TeXFormula(tp, args[1], false).root, null, SymbolAtom.get("lsqbrack"), TeXConstants.UNIT_EX, 0, true); } public static final Atom underparen_macro(final TeXParser tp, final String[] args) throws ParseException { - return new OverUnderDelimiter(new TeXFormula(tp.getIsPartial(), args[1], false).root, null, SymbolAtom.get("rbrack"), TeXConstants.UNIT_EX, 0, false); + return new OverUnderDelimiter(new TeXFormula(tp, args[1], false).root, null, SymbolAtom.get("rbrack"), TeXConstants.UNIT_EX, 0, false); } public static final Atom overparen_macro(final TeXParser tp, final String[] args) throws ParseException { - return new OverUnderDelimiter(new TeXFormula(tp.getIsPartial(), args[1], false).root, null, SymbolAtom.get("lbrack"), TeXConstants.UNIT_EX, 0, true); + return new OverUnderDelimiter(new TeXFormula(tp, args[1], false).root, null, SymbolAtom.get("lbrack"), TeXConstants.UNIT_EX, 0, true); } public static final Atom overline_macro(final TeXParser tp, final String[] args) throws ParseException { - return new OverlinedAtom(new TeXFormula(tp.getIsPartial(), args[1], false).root); + return new OverlinedAtom(new TeXFormula(tp, args[1], false).root); } public static final Atom underline_macro(final TeXParser tp, final String[] args) throws ParseException { - return new UnderlinedAtom(new TeXFormula(tp.getIsPartial(), args[1], false).root); + return new UnderlinedAtom(new TeXFormula(tp, args[1], false).root); } public static final Atom mathop_macro(final TeXParser tp, final String[] args) throws ParseException { - TypedAtom at = new TypedAtom(TeXConstants.TYPE_BIG_OPERATOR, TeXConstants.TYPE_BIG_OPERATOR, new TeXFormula(tp.getIsPartial(), args[1], false).root); + TypedAtom at = new TypedAtom(TeXConstants.TYPE_BIG_OPERATOR, TeXConstants.TYPE_BIG_OPERATOR, new TeXFormula(tp, args[1], false).root); at.type_limits = TeXConstants.SCRIPT_NORMAL; return at; } public static final Atom mathpunct_macro(final TeXParser tp, final String[] args) throws ParseException { - return new TypedAtom(TeXConstants.TYPE_PUNCTUATION, TeXConstants.TYPE_PUNCTUATION, new TeXFormula(tp.getIsPartial(), args[1], false).root); + return new TypedAtom(TeXConstants.TYPE_PUNCTUATION, TeXConstants.TYPE_PUNCTUATION, new TeXFormula(tp, args[1], false).root); } public static final Atom mathord_macro(final TeXParser tp, final String[] args) throws ParseException { - return new TypedAtom(TeXConstants.TYPE_ORDINARY, TeXConstants.TYPE_ORDINARY, new TeXFormula(tp.getIsPartial(), args[1], false).root); + return new TypedAtom(TeXConstants.TYPE_ORDINARY, TeXConstants.TYPE_ORDINARY, new TeXFormula(tp, args[1], false).root); } public static final Atom mathrel_macro(final TeXParser tp, final String[] args) throws ParseException { - return new TypedAtom(TeXConstants.TYPE_RELATION, TeXConstants.TYPE_RELATION, new TeXFormula(tp.getIsPartial(), args[1], false).root); + return new TypedAtom(TeXConstants.TYPE_RELATION, TeXConstants.TYPE_RELATION, new TeXFormula(tp, args[1], false).root); } public static final Atom mathinner_macro(final TeXParser tp, final String[] args) throws ParseException { - return new TypedAtom(TeXConstants.TYPE_INNER, TeXConstants.TYPE_INNER, new TeXFormula(tp.getIsPartial(), args[1], false).root); + return new TypedAtom(TeXConstants.TYPE_INNER, TeXConstants.TYPE_INNER, new TeXFormula(tp, args[1], false).root); } public static final Atom mathbin_macro(final TeXParser tp, final String[] args) throws ParseException { - return new TypedAtom(TeXConstants.TYPE_BINARY_OPERATOR, TeXConstants.TYPE_BINARY_OPERATOR, new TeXFormula(tp.getIsPartial(), args[1], false).root); + return new TypedAtom(TeXConstants.TYPE_BINARY_OPERATOR, TeXConstants.TYPE_BINARY_OPERATOR, new TeXFormula(tp, args[1], false).root); } public static final Atom mathopen_macro(final TeXParser tp, final String[] args) throws ParseException { - return new TypedAtom(TeXConstants.TYPE_OPENING, TeXConstants.TYPE_OPENING, new TeXFormula(tp.getIsPartial(), args[1], false).root); + return new TypedAtom(TeXConstants.TYPE_OPENING, TeXConstants.TYPE_OPENING, new TeXFormula(tp, args[1], false).root); } public static final Atom mathclose_macro(final TeXParser tp, final String[] args) throws ParseException { - return new TypedAtom(TeXConstants.TYPE_CLOSING, TeXConstants.TYPE_CLOSING, new TeXFormula(tp.getIsPartial(), args[1], false).root); + return new TypedAtom(TeXConstants.TYPE_CLOSING, TeXConstants.TYPE_CLOSING, new TeXFormula(tp, args[1], false).root); } public static final Atom joinrel_macro(final TeXParser tp, final String[] args) throws ParseException { @@ -601,7 +642,7 @@ } public static final Atom smash_macro(final TeXParser tp, final String[] args) throws ParseException { - return new SmashedAtom(new TeXFormula(tp.getIsPartial(), args[1], false).root, args[2]); + return new SmashedAtom(new TeXFormula(tp, args[1], false).root, args[2]); } public static final Atom vdots_macro(final TeXParser tp, final String[] args) throws ParseException { @@ -636,36 +677,36 @@ public static final Atom left_macro(final TeXParser tp, final String[] args) throws ParseException { String grp = tp.getGroup("\\left", "\\right"); - Atom left = new TeXFormula(tp.getIsPartial(), args[1], false).root; + Atom left = new TeXFormula(tp, args[1], false).root; if (left instanceof BigDelimiterAtom) left = ((BigDelimiterAtom)left).delim; Atom right = tp.getArgument(); if (right instanceof BigDelimiterAtom) right = ((BigDelimiterAtom)right).delim; if (left instanceof SymbolAtom && right instanceof SymbolAtom) { - TeXFormula tf = new TeXFormula(tp.getIsPartial(), grp, false); + TeXFormula tf = new TeXFormula(tp, grp, false); return new FencedAtom(tf.root, (SymbolAtom)left, tf.middle, (SymbolAtom)right); } RowAtom ra = new RowAtom(); ra.add(left); - ra.add(new TeXFormula(tp.getIsPartial(), grp, false).root); + ra.add(new TeXFormula(tp, grp, false).root); ra.add(right); return ra; } public static final Atom leftparenthesis_macro(final TeXParser tp, final String[] args) throws ParseException { String grp = tp.getGroup("\\(", "\\)"); - return new MathAtom(new TeXFormula(tp.getIsPartial(), grp, false).root, TeXConstants.STYLE_TEXT); + return new MathAtom(new TeXFormula(tp, grp, false).root, TeXConstants.STYLE_TEXT); } public static final Atom leftbracket_macro(final TeXParser tp, final String[] args) throws ParseException { String grp = tp.getGroup("\\[", "\\]"); - return new MathAtom(new TeXFormula(tp.getIsPartial(), grp, false).root, TeXConstants.STYLE_DISPLAY); + return new MathAtom(new TeXFormula(tp, grp, false).root, TeXConstants.STYLE_DISPLAY); } public static final Atom middle_macro(final TeXParser tp, final String[] args) throws ParseException { - return new MiddleAtom(new TeXFormula(tp.getIsPartial(), args[1]).root); + return new MiddleAtom(new TeXFormula(tp, args[1]).root); } public static final Atom cr_macro(final TeXParser tp, final String[] args) throws ParseException { @@ -688,7 +729,7 @@ String str = args[1].replaceAll("\\^\\{\\\\prime\\}", "\'"); str = str.replaceAll("\\^\\{\\\\prime\\\\prime\\}", "\'\'"); - Atom at = new RomanAtom(new TeXFormula(tp.getIsPartial(), str, "mathnormal", false, false).root); + Atom at = new RomanAtom(new TeXFormula(tp, str, "mathnormal", false, false).root); at.type = TeXConstants.TYPE_INTERTEXT; tp.addAtom(at); tp.addRow(); @@ -713,7 +754,7 @@ public static final Atom multicolumn_macro(final TeXParser tp, final String[] args) throws ParseException { int n = Integer.parseInt(args[1]); - tp.addAtom(new MulticolumnAtom(n, args[2], new TeXFormula(tp.getIsPartial(), args[3]).root)); + tp.addAtom(new MulticolumnAtom(n, args[2], new TeXFormula(tp, args[3]).root)); ((ArrayOfAtoms)tp.formula).addCol(n); return null; } @@ -833,13 +874,13 @@ } public static final Atom shoveright_macro(final TeXParser tp, final String[] args) throws ParseException { - Atom at = new TeXFormula(tp.getIsPartial(), args[1]).root; + Atom at = new TeXFormula(tp, args[1]).root; at.alignment = TeXConstants.ALIGN_RIGHT; return at; } public static final Atom shoveleft_macro(final TeXParser tp, final String[] args) throws ParseException { - Atom at = new TeXFormula(tp.getIsPartial(), args[1]).root; + Atom at = new TeXFormula(tp, args[1]).root; at.alignment = TeXConstants.ALIGN_LEFT; return at; } @@ -914,84 +955,84 @@ } public static final Atom fbox_macro(final TeXParser tp, final String[] args) throws ParseException { - return new FBoxAtom(new TeXFormula(tp.getIsPartial(), args[1], false).root); + return new FBoxAtom(new TeXFormula(tp, args[1], false).root); } public static final Atom stackrel_macro(final TeXParser tp, final String[] args) throws ParseException { - Atom at = new UnderOverAtom(new TeXFormula(tp.getIsPartial(), args[2], false).root, new TeXFormula(tp.getIsPartial(), args[3], false).root, TeXConstants.UNIT_MU, 0.5f, true, new TeXFormula(tp.getIsPartial(), args[1], false).root, TeXConstants.UNIT_MU, 2.5f, true); + Atom at = new UnderOverAtom(new TeXFormula(tp, args[2], false).root, new TeXFormula(tp, args[3], false).root, TeXConstants.UNIT_MU, 0.5f, true, new TeXFormula(tp, args[1], false).root, TeXConstants.UNIT_MU, 2.5f, true); return new TypedAtom(TeXConstants.TYPE_RELATION, TeXConstants.TYPE_RELATION, at); } public static final Atom stackbin_macro(final TeXParser tp, final String[] args) throws ParseException { - Atom at = new UnderOverAtom(new TeXFormula(tp.getIsPartial(), args[2], false).root, new TeXFormula(tp.getIsPartial(), args[3], false).root, TeXConstants.UNIT_MU, 0.5f, true, new TeXFormula(tp.getIsPartial(), args[1], false).root, TeXConstants.UNIT_MU, 2.5f, true); + Atom at = new UnderOverAtom(new TeXFormula(tp, args[2], false).root, new TeXFormula(tp, args[3], false).root, TeXConstants.UNIT_MU, 0.5f, true, new TeXFormula(tp, args[1], false).root, TeXConstants.UNIT_MU, 2.5f, true); return new TypedAtom(TeXConstants.TYPE_BINARY_OPERATOR, TeXConstants.TYPE_BINARY_OPERATOR, at); } public static final Atom overset_macro(final TeXParser tp, final String[] args) throws ParseException { - Atom at = new UnderOverAtom(new TeXFormula(tp.getIsPartial(), args[2], false).root, new TeXFormula(tp.getIsPartial(), args[1], false).root, TeXConstants.UNIT_MU, 2.5f, true, true); + Atom at = new UnderOverAtom(new TeXFormula(tp, args[2], false).root, new TeXFormula(tp, args[1], false).root, TeXConstants.UNIT_MU, 2.5f, true, true); return new TypedAtom(TeXConstants.TYPE_RELATION, TeXConstants.TYPE_RELATION, at); } public static final Atom underset_macro(final TeXParser tp, final String[] args) throws ParseException { - Atom at = new UnderOverAtom(new TeXFormula(tp.getIsPartial(), args[2], false).root, new TeXFormula(tp.getIsPartial(), args[1], false).root, TeXConstants.UNIT_MU, 0.5f, true, false); + Atom at = new UnderOverAtom(new TeXFormula(tp, args[2], false).root, new TeXFormula(tp, args[1], false).root, TeXConstants.UNIT_MU, 0.5f, true, false); return new TypedAtom(TeXConstants.TYPE_RELATION, TeXConstants.TYPE_RELATION, at); } public static final Atom accentset_macro(final TeXParser tp, final String[] args) throws ParseException { - return new AccentedAtom(new TeXFormula(tp.getIsPartial(), args[2], false).root, new TeXFormula(tp.getIsPartial(), args[1], false).root); + return new AccentedAtom(new TeXFormula(tp, args[2], false).root, new TeXFormula(tp, args[1], false).root); } public static final Atom underaccent_macro(final TeXParser tp, final String[] args) throws ParseException { - return new UnderOverAtom(new TeXFormula(tp.getIsPartial(), args[2], false).root, new TeXFormula(tp.getIsPartial(), args[1], false).root, TeXConstants.UNIT_MU, 0.3f, true, false); + return new UnderOverAtom(new TeXFormula(tp, args[2], false).root, new TeXFormula(tp, args[1], false).root, TeXConstants.UNIT_MU, 0.3f, true, false); } public static final Atom undertilde_macro(final TeXParser tp, final String[] args) throws ParseException { - Atom at = new TeXFormula(tp.getIsPartial(), args[1], false).root; + Atom at = new TeXFormula(tp, args[1], false).root; return new UnderOverAtom(at, new AccentedAtom(new PhantomAtom(at, true, false, false), "widetilde"), TeXConstants.UNIT_MU, 0.3f, true, false); } public static final Atom boldsymbol_macro(final TeXParser tp, final String[] args) throws ParseException { - return new BoldAtom(new TeXFormula(tp.getIsPartial(), args[1], false).root); + return new BoldAtom(new TeXFormula(tp, args[1], false).root); } public static final Atom mathrm_macro(final TeXParser tp, final String[] args) throws ParseException { - return new RomanAtom(new TeXFormula(tp.getIsPartial(), args[1], false).root); + return new RomanAtom(new TeXFormula(tp, args[1], false).root); } public static final Atom rm_macro(final TeXParser tp, final String[] args) throws ParseException { - return new RomanAtom(new TeXFormula(tp.getIsPartial(), tp.getOverArgument(), null, false, tp.isIgnoreWhiteSpace()).root); + return new RomanAtom(new TeXFormula(tp, tp.getOverArgument(), null, false, tp.isIgnoreWhiteSpace()).root); } public static final Atom mathbf_macro(final TeXParser tp, final String[] args) throws ParseException { - return new BoldAtom(new RomanAtom(new TeXFormula(tp.getIsPartial(), args[1], false).root)); + return new BoldAtom(new RomanAtom(new TeXFormula(tp, args[1], false).root)); } public static final Atom bf_macro(final TeXParser tp, final String[] args) throws ParseException { - return new BoldAtom(new RomanAtom(new TeXFormula(tp.getIsPartial(), tp.getOverArgument(), null, false, tp.isIgnoreWhiteSpace()).root)); + return new BoldAtom(new RomanAtom(new TeXFormula(tp, tp.getOverArgument(), null, false, tp.isIgnoreWhiteSpace()).root)); } public static final Atom mathtt_macro(final TeXParser tp, final String[] args) throws ParseException { - return new TtAtom(new TeXFormula(tp.getIsPartial(), args[1], false).root); + return new TtAtom(new TeXFormula(tp, args[1], false).root); } public static final Atom tt_macro(final TeXParser tp, final String[] args) throws ParseException { - return new TtAtom(new TeXFormula(tp.getIsPartial(), tp.getOverArgument(), null, false, tp.isIgnoreWhiteSpace()).root); + return new TtAtom(new TeXFormula(tp, tp.getOverArgument(), null, false, tp.isIgnoreWhiteSpace()).root); } public static final Atom mathit_macro(final TeXParser tp, final String[] args) throws ParseException { - return new ItAtom(new TeXFormula(tp.getIsPartial(), args[1], false).root); + return new ItAtom(new TeXFormula(tp, args[1], false).root); } public static final Atom it_macro(final TeXParser tp, final String[] args) throws ParseException { - return new ItAtom(new TeXFormula(tp.getIsPartial(), tp.getOverArgument(), null, false, tp.isIgnoreWhiteSpace()).root); + return new ItAtom(new TeXFormula(tp, tp.getOverArgument(), null, false, tp.isIgnoreWhiteSpace()).root); } public static final Atom mathsf_macro(final TeXParser tp, final String[] args) throws ParseException { - return new SsAtom(new TeXFormula(tp.getIsPartial(), args[1], false).root); + return new SsAtom(new TeXFormula(tp, args[1], false).root); } public static final Atom sf_macro(final TeXParser tp, final String[] args) throws ParseException { - return new SsAtom(new TeXFormula(tp.getIsPartial(), tp.getOverArgument(), null, false, tp.isIgnoreWhiteSpace()).root); + return new SsAtom(new TeXFormula(tp, tp.getOverArgument(), null, false, tp.isIgnoreWhiteSpace()).root); } public static final Atom LaTeX_macro(final TeXParser tp, final String[] args) throws ParseException { @@ -1006,19 +1047,19 @@ } public static final Atom hphantom_macro(final TeXParser tp, final String[] args) throws ParseException { - return new PhantomAtom(new TeXFormula(tp.getIsPartial(), args[1], false).root, true, false, false); + return new PhantomAtom(new TeXFormula(tp, args[1], false).root, true, false, false); } public static final Atom vphantom_macro(final TeXParser tp, final String[] args) throws ParseException { - return new PhantomAtom(new TeXFormula(tp.getIsPartial(), args[1], false).root, false, true, true); + return new PhantomAtom(new TeXFormula(tp, args[1], false).root, false, true, true); } public static final Atom phantom_macro(final TeXParser tp, final String[] args) throws ParseException { - return new PhantomAtom(new TeXFormula(tp.getIsPartial(), args[1], false).root, true, true, true); + return new PhantomAtom(new TeXFormula(tp, args[1], false).root, true, true, true); } public static final Atom big_macro(final TeXParser tp, final String[] args) throws ParseException { - Atom at = new TeXFormula(tp.getIsPartial(), args[1], false).root; + Atom at = new TeXFormula(tp, args[1], false).root; if (!(at instanceof SymbolAtom)) { return at; } @@ -1026,7 +1067,7 @@ } public static final Atom Big_macro(final TeXParser tp, final String[] args) throws ParseException { - Atom at = new TeXFormula(tp.getIsPartial(), args[1], false).root; + Atom at = new TeXFormula(tp, args[1], false).root; if (!(at instanceof SymbolAtom)) { return at; } @@ -1034,7 +1075,7 @@ } public static final Atom bigg_macro(final TeXParser tp, final String[] args) throws ParseException { - Atom at = new TeXFormula(tp.getIsPartial(), args[1], false).root; + Atom at = new TeXFormula(tp, args[1], false).root; if (!(at instanceof SymbolAtom)) { return at; } @@ -1042,7 +1083,7 @@ } public static final Atom Bigg_macro(final TeXParser tp, final String[] args) throws ParseException { - Atom at = new TeXFormula(tp.getIsPartial(), args[1], false).root; + Atom at = new TeXFormula(tp, args[1], false).root; if (!(at instanceof SymbolAtom)) { return at; } @@ -1050,7 +1091,7 @@ } public static final Atom bigl_macro(final TeXParser tp, final String[] args) throws ParseException { - Atom at = new TeXFormula(tp.getIsPartial(), args[1], false).root; + Atom at = new TeXFormula(tp, args[1], false).root; if (!(at instanceof SymbolAtom)) { return at; } @@ -1060,7 +1101,7 @@ } public static final Atom Bigl_macro(final TeXParser tp, final String[] args) throws ParseException { - Atom at = new TeXFormula(tp.getIsPartial(), args[1], false).root; + Atom at = new TeXFormula(tp, args[1], false).root; if (!(at instanceof SymbolAtom)) { return at; } @@ -1070,7 +1111,7 @@ } public static final Atom biggl_macro(final TeXParser tp, final String[] args) throws ParseException { - Atom at = new TeXFormula(tp.getIsPartial(), args[1], false).root; + Atom at = new TeXFormula(tp, args[1], false).root; if (!(at instanceof SymbolAtom)) { return at; } @@ -1080,7 +1121,7 @@ } public static final Atom Biggl_macro(final TeXParser tp, final String[] args) throws ParseException { - Atom at = new TeXFormula(tp.getIsPartial(), args[1], false).root; + Atom at = new TeXFormula(tp, args[1], false).root; if (!(at instanceof SymbolAtom)) { return at; } @@ -1090,7 +1131,7 @@ } public static final Atom bigr_macro(final TeXParser tp, final String[] args) throws ParseException { - Atom at = new TeXFormula(tp.getIsPartial(), args[1], false).root; + Atom at = new TeXFormula(tp, args[1], false).root; if (!(at instanceof SymbolAtom)) { return at; } @@ -1100,7 +1141,7 @@ } public static final Atom Bigr_macro(final TeXParser tp, final String[] args) throws ParseException { - Atom at = new TeXFormula(tp.getIsPartial(), args[1], false).root; + Atom at = new TeXFormula(tp, args[1], false).root; if (!(at instanceof SymbolAtom)) { return at; } @@ -1110,7 +1151,7 @@ } public static final Atom biggr_macro(final TeXParser tp, final String[] args) throws ParseException { - Atom at = new TeXFormula(tp.getIsPartial(), args[1], false).root; + Atom at = new TeXFormula(tp, args[1], false).root; if (!(at instanceof SymbolAtom)) { return at; } @@ -1120,7 +1161,7 @@ } public static final Atom Biggr_macro(final TeXParser tp, final String[] args) throws ParseException { - Atom at = new TeXFormula(tp.getIsPartial(), args[1], false).root; + Atom at = new TeXFormula(tp, args[1], false).root; if (!(at instanceof SymbolAtom)) { return at; } @@ -1130,39 +1171,39 @@ } public static final Atom displaystyle_macro(final TeXParser tp, final String[] args) throws ParseException { - Atom group = new TeXFormula(tp.getIsPartial(), tp.getOverArgument(), false).root; + Atom group = new TeXFormula(tp, tp.getOverArgument(), false).root; return new StyleAtom(TeXConstants.STYLE_DISPLAY, group); } public static final Atom scriptstyle_macro(final TeXParser tp, final String[] args) throws ParseException { - Atom group = new TeXFormula(tp.getIsPartial(), tp.getOverArgument(), false).root; + Atom group = new TeXFormula(tp, tp.getOverArgument(), false).root; return new StyleAtom(TeXConstants.STYLE_SCRIPT, group); } public static final Atom textstyle_macro(final TeXParser tp, final String[] args) throws ParseException { - Atom group = new TeXFormula(tp.getIsPartial(), tp.getOverArgument(), false).root; + Atom group = new TeXFormula(tp, tp.getOverArgument(), false).root; return new StyleAtom(TeXConstants.STYLE_TEXT, group); } public static final Atom scriptscriptstyle_macro(final TeXParser tp, final String[] args) throws ParseException { - Atom group = new TeXFormula(tp.getIsPartial(), tp.getOverArgument(), false).root; + Atom group = new TeXFormula(tp, tp.getOverArgument(), false).root; return new StyleAtom(TeXConstants.STYLE_SCRIPT_SCRIPT, group); } public static final Atom rotatebox_macro(final TeXParser tp, final String[] args) throws ParseException { - return new RotateAtom(new TeXFormula(tp.getIsPartial(), args[2]).root, args[1] == null ? 0 : Double.parseDouble(args[1]), args[3]); + return new RotateAtom(new TeXFormula(tp, args[2]).root, args[1] == null ? 0 : Double.parseDouble(args[1]), args[3]); } public static final Atom reflectbox_macro(final TeXParser tp, final String[] args) throws ParseException { - return new ReflectAtom(new TeXFormula(tp.getIsPartial(), args[1]).root); + return new ReflectAtom(new TeXFormula(tp, args[1]).root); } public static final Atom scalebox_macro(final TeXParser tp, final String[] args) throws ParseException { - return new ScaleAtom(new TeXFormula(tp.getIsPartial(), args[2]).root, Double.parseDouble(args[1]), args[3] == null ? Double.parseDouble(args[1]) : Double.parseDouble(args[3])); + return new ScaleAtom(new TeXFormula(tp, args[2]).root, Double.parseDouble(args[1]), args[3] == null ? Double.parseDouble(args[1]) : Double.parseDouble(args[3])); } public static final Atom resizebox_macro(final TeXParser tp, final String[] args) throws ParseException { - return new ResizeAtom(new TeXFormula(tp.getIsPartial(), args[3]).root, args[1], args[2], false); + return new ResizeAtom(new TeXFormula(tp, args[3]).root, args[1], args[2], args[1].equals("!") || args[2].equals("!")); } public static final Atom raisebox_macro(final TeXParser tp, final String[] args) throws ParseException { @@ -1179,19 +1220,19 @@ depth = new float[]{-1, 0}; } - return new RaiseAtom(new TeXFormula(tp.getIsPartial(), args[2]).root, (int) raise[0], raise[1], (int) height[0], height[1], (int) depth[0], depth[1]); + return new RaiseAtom(new TeXFormula(tp, args[2]).root, (int) raise[0], raise[1], (int) height[0], height[1], (int) depth[0], depth[1]); } public static final Atom shadowbox_macro(final TeXParser tp, final String[] args) throws ParseException { - return new ShadowAtom(new TeXFormula(tp.getIsPartial(), args[1]).root); + return new ShadowAtom(new TeXFormula(tp, args[1]).root); } public static final Atom ovalbox_macro(final TeXParser tp, final String[] args) throws ParseException { - return new OvalAtom(new TeXFormula(tp.getIsPartial(), args[1]).root); + return new OvalAtom(new TeXFormula(tp, args[1]).root); } public static final Atom doublebox_macro(final TeXParser tp, final String[] args) throws ParseException { - return new DoubleFramedAtom(new TeXFormula(tp.getIsPartial(), args[1]).root); + return new DoubleFramedAtom(new TeXFormula(tp, args[1]).root); } public static final Atom definecolor_macro(final TeXParser tp, final String[] args) throws ParseException { @@ -1200,22 +1241,22 @@ float f = Float.parseFloat(args[3]); color = new Color(f, f, f); } else if ("rgb".equals(args[2])) { - StringTokenizer stok = new StringTokenizer(args[3], ","); + StringTokenizer stok = new StringTokenizer(args[3], ";,"); if (stok.countTokens() != 3) throw new ParseException("The color definition must have three components !"); - float r = Float.parseFloat(stok.nextToken()); - float g = Float.parseFloat(stok.nextToken()); - float b = Float.parseFloat(stok.nextToken()); + float r = Float.parseFloat(stok.nextToken().trim()); + float g = Float.parseFloat(stok.nextToken().trim()); + float b = Float.parseFloat(stok.nextToken().trim()); color = new Color(r, g, b); } else if ("cmyk".equals(args[2])) { - StringTokenizer stok = new StringTokenizer(args[3], ","); + StringTokenizer stok = new StringTokenizer(args[3], ",;"); if (stok.countTokens() != 4) throw new ParseException("The color definition must have four components !"); float[] cmyk = new float[4]; for (int i = 0; i < 4; i++) - cmyk[i] = Float.parseFloat(stok.nextToken()); + cmyk[i] = Float.parseFloat(stok.nextToken().trim()); float k = 1 - cmyk[3]; - color = new Color(k*(1-cmyk[0]), k*(1-cmyk[1]), k*(1-cmyk[2])); + color = new Color(k * (1 - cmyk[0]), k * (1 - cmyk[1]), k * (1 - cmyk[2])); } else throw new ParseException("The color model is incorrect !"); @@ -1224,40 +1265,32 @@ } public static final Atom fgcolor_macro(final TeXParser tp, final String[] args) throws ParseException { - String code = args[1] == null ? "#000000" : args[1].trim(); - if (!code.startsWith("#")) { - code = "#" + code; - } try { - return new ColorAtom(new TeXFormula(tp.getIsPartial(), args[2]).root, null, Color.decode(code)); + return new ColorAtom(new TeXFormula(tp, args[2]).root, null, ColorAtom.getColor(args[1])); } catch (NumberFormatException e) { throw new ParseException(e.toString()); } } public static final Atom bgcolor_macro(final TeXParser tp, final String[] args) throws ParseException { - String code = args[1] == null ? "#000000" : args[1].trim(); - if (!code.startsWith("#")) { - code = "#" + code; - } try { - return new ColorAtom(new TeXFormula(tp.getIsPartial(), args[2]).root, Color.decode(code), null); + return new ColorAtom(new TeXFormula(tp, args[2]).root, ColorAtom.getColor(args[1]), null); } catch (NumberFormatException e) { throw new ParseException(e.toString()); } } public static final Atom textcolor_macro(final TeXParser tp, final String[] args) throws ParseException { - return new ColorAtom(new TeXFormula(tp.getIsPartial(), args[2]).root, null, ColorAtom.Colors.get(args[1])); + return new ColorAtom(new TeXFormula(tp, args[2]).root, null, ColorAtom.getColor(args[1])); } public static final Atom colorbox_macro(final TeXParser tp, final String[] args) throws ParseException { - Color c = ColorAtom.Colors.get(args[1]); - return new FBoxAtom(new TeXFormula(tp.getIsPartial(), args[2]).root, c, c); + Color c = ColorAtom.getColor(args[1]); + return new FBoxAtom(new TeXFormula(tp, args[2]).root, c, c); } public static final Atom fcolorbox_macro(final TeXParser tp, final String[] args) throws ParseException { - return new FBoxAtom(new TeXFormula(tp.getIsPartial(), args[3]).root, ColorAtom.Colors.get(args[2]), ColorAtom.Colors.get(args[1])); + return new FBoxAtom(new TeXFormula(tp, args[3]).root, ColorAtom.getColor(args[2]), ColorAtom.getColor(args[1])); } public static final Atom cong_macro(final TeXParser tp, final String[] args) throws ParseException { @@ -1275,7 +1308,7 @@ public static final Atom jlmDynamic_macro(final TeXParser tp, final String[] args) throws ParseException { if (DynamicAtom.hasAnExternalConverterFactory()) { - return new DynamicAtom(args[1]); + return new DynamicAtom(args[1], args[2]); } else { throw new ParseException("No ExternalConverterFactory set !"); } @@ -1342,15 +1375,15 @@ f = 2.5f; } - return new MonoScaleAtom(new TeXFormula(tp.getIsPartial(), tp.getOverArgument(), null, false, tp.isIgnoreWhiteSpace()).root, f); + return new MonoScaleAtom(new TeXFormula(tp, tp.getOverArgument(), null, false, tp.isIgnoreWhiteSpace()).root, f); } public static final Atom jlatexmathcumsup_macro(final TeXParser tp, final String[] args) throws ParseException { - return new CumulativeScriptsAtom(tp.getLastAtom(), null, new TeXFormula(tp.getIsPartial(), args[1]).root); + return new CumulativeScriptsAtom(tp.getLastAtom(), null, new TeXFormula(tp, args[1]).root); } public static final Atom jlatexmathcumsub_macro(final TeXParser tp, final String[] args) throws ParseException { - return new CumulativeScriptsAtom(tp.getLastAtom(), new TeXFormula(tp.getIsPartial(), args[1]).root, null); + return new CumulativeScriptsAtom(tp.getLastAtom(), new TeXFormula(tp, args[1]).root, null); } public static final Atom dotminus_macro(final TeXParser tp, final String[] args) throws ParseException { @@ -1578,7 +1611,7 @@ } public static final Atom T_macro(final TeXParser tp, final String[] args) throws ParseException { - return new RotateAtom(new TeXFormula(tp.getIsPartial(), args[1]).root, 180, "origin=cc"); + return new RotateAtom(new TeXFormula(tp, args[1]).root, 180, "origin=cc"); } public static final Atom romannumeral_macro(final TeXParser tp, final String[] args) throws ParseException { @@ -1601,15 +1634,15 @@ } public static final Atom textcircled_macro(final TeXParser tp, final String[] args) throws ParseException { - return new TextCircledAtom(new RomanAtom(new TeXFormula(tp.getIsPartial(), args[1]).root)); + return new TextCircledAtom(new RomanAtom(new TeXFormula(tp, args[1]).root)); } public static final Atom textsc_macro(final TeXParser tp, final String[] args) throws ParseException { - return new SmallCapAtom(new TeXFormula(tp.getIsPartial(), args[1], false).root); + return new SmallCapAtom(new TeXFormula(tp, args[1], false).root); } public static final Atom sc_macro(final TeXParser tp, final String[] args) throws ParseException { - return new SmallCapAtom(new TeXFormula(tp.getIsPartial(), tp.getOverArgument(), null, false, tp.isIgnoreWhiteSpace()).root); + return new SmallCapAtom(new TeXFormula(tp, tp.getOverArgument(), null, false, tp.isIgnoreWhiteSpace()).root); } public static final Atom quad_macro(final TeXParser tp, final String[] args) throws ParseException { @@ -1722,4 +1755,38 @@ at.type = TeXConstants.TYPE_CLOSING; return at; } + + public static final Atom insertBreakMark_macro(final TeXParser tp, final String[] args) throws ParseException { + return new BreakMarkAtom(); + } + + public static final Atom jlmXML_macro(final TeXParser tp, final String[] args) throws ParseException { + Map map = tp.formula.jlmXMLMap; + String str = args[1]; + StringBuffer buffer = new StringBuffer(); + int start = 0; + int pos; + while ((pos = str.indexOf("$")) != -1) { + if (pos < str.length() - 1) { + start = pos; + while (++start < str.length() && Character.isLetter(str.charAt(start))); + String key = str.substring(pos + 1, start); + String value = map.get(key); + if (value != null) { + buffer.append(str.substring(0, pos)); + buffer.append(value); + } else { + buffer.append(str.substring(0, start)); + } + str = str.substring(start); + } else { + buffer.append(str); + str = ""; + } + } + buffer.append(str); + str = buffer.toString(); + + return new TeXFormula(tp, str).root; + } } diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/RowAtom.java libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/RowAtom.java --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/RowAtom.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/RowAtom.java 2011-11-22 17:18:16.000000000 +0000 @@ -36,23 +36,25 @@ import java.util.List; import java.util.ListIterator; +import org.scilab.forge.jlatexmath.dynamic.DynamicAtom; + /** * An atom representing a horizontal row of other atoms, to be seperated by glue. * It's also responsible for inserting kerns and ligatures. */ public class RowAtom extends Atom implements Row { - + // atoms to be displayed horizontally next to eachother protected LinkedList elements = new LinkedList(); - + public boolean lookAtLastAtom = false; - + // previous atom (for nested Row atoms) private Dummy previousAtom = null; - + // set of atom types that make a previous bin atom change to ord private static BitSet binSet; - + // set of atom types that can possibly need a kern or, together with the // previous atom, be replaced by a ligature private static BitSet ligKernSet; @@ -65,7 +67,7 @@ binSet.set(TeXConstants.TYPE_RELATION); binSet.set(TeXConstants.TYPE_OPENING); binSet.set(TeXConstants.TYPE_PUNCTUATION); - + // fill ligKernSet ligKernSet = new BitSet (16); ligKernSet.set(TeXConstants.TYPE_ORDINARY); @@ -76,11 +78,11 @@ ligKernSet.set(TeXConstants.TYPE_CLOSING); ligKernSet.set(TeXConstants.TYPE_PUNCTUATION); } - + protected RowAtom() { // empty } - + public RowAtom(Atom el) { if (el != null) { if (el instanceof RowAtom) @@ -90,20 +92,21 @@ elements.add(el); } } - + public Atom getLastAtom() { - if (elements.size() != 0) { - return elements.removeLast(); - } - - return new SpaceAtom(TeXConstants.UNIT_POINT, 0.0f, 0.0f, 0.0f); + if (elements.size() != 0) { + return elements.removeLast(); + } + + return new SpaceAtom(TeXConstants.UNIT_POINT, 0.0f, 0.0f, 0.0f); } - + public final void add(Atom el) { - if (el != null) + if (el != null) { elements.add(el); + } } - + /** * * @param cur @@ -113,42 +116,69 @@ */ private void changeToOrd(Dummy cur, Dummy prev, Atom next) { int type = cur.getLeftType(); - if (type == TeXConstants.TYPE_BINARY_OPERATOR - && (prev == null || binSet.get(prev.getRightType()))) + if (type == TeXConstants.TYPE_BINARY_OPERATOR && ((prev == null || binSet.get(prev.getRightType())) || next == null)) { cur.setType(TeXConstants.TYPE_ORDINARY); - else if (next != null - && cur.getRightType() == TeXConstants.TYPE_BINARY_OPERATOR) { + } else if (next != null && cur.getRightType() == TeXConstants.TYPE_BINARY_OPERATOR) { int nextType = next.getLeftType(); - if (nextType == TeXConstants.TYPE_RELATION - || nextType == TeXConstants.TYPE_CLOSING - || nextType == TeXConstants.TYPE_PUNCTUATION) + if (nextType == TeXConstants.TYPE_RELATION || nextType == TeXConstants.TYPE_CLOSING || nextType == TeXConstants.TYPE_PUNCTUATION) { cur.setType(TeXConstants.TYPE_ORDINARY); + } } } - + public Box createBox(TeXEnvironment env) { TeXFont tf = env.getTeXFont(); HorizontalBox hBox = new HorizontalBox(env.getColor(), env.getBackground()); + int position = 0; env.reset(); - + // convert atoms to boxes and add to the horizontal box - for (ListIterator it = elements.listIterator(); it.hasNext();) { - Dummy atom = new Dummy((Atom) it.next()); + for (ListIterator it = elements.listIterator(); it.hasNext();) { + Atom at = it.next(); + position++; + + boolean markAdded = false; + while (at instanceof BreakMarkAtom) { + if (!markAdded) { + markAdded = true; + } + if (it.hasNext()) { + at = it.next(); + position++; + } else { + break; + } + } + if (at instanceof DynamicAtom && ((DynamicAtom) at).getInsertMode()) { + Atom a = ((DynamicAtom) at).getAtom(); + if (a instanceof RowAtom) { + elements.remove(position - 1); + elements.addAll(position - 1, ((RowAtom) a).elements); + it = elements.listIterator(position - 1); + at = it.next(); + } else { + at = a; + } + } + + Dummy atom = new Dummy(at); + // if necessary, change BIN type to ORD Atom nextAtom = null; if (it.hasNext()) { - nextAtom = (Atom) it.next(); + nextAtom = it.next(); it.previous(); } changeToOrd(atom, previousAtom, nextAtom); - + // check for ligatures or kerning float kern = 0; - // Calixte : I put a while to handle the case where there are - // several ligatures as in ffi or ffl + // Calixte : I put a while to handle the case where there are + // several ligatures as in ffi or ffl while (it.hasNext() && atom.getRightType() == TeXConstants.TYPE_ORDINARY && atom.isCharSymbol()) { - Atom next = (Atom) it.next(); + Atom next = it.next(); + position++; if (next instanceof CharSymbol && ligKernSet.get(next.getLeftType())) { atom.markAsTextSymbol(); CharFont l = atom.getCharFont(tf), r = ((CharSymbol) next).getCharFont(tf); @@ -156,62 +186,70 @@ if (lig == null) { kern = tf.getKern(l, r, env.getStyle()); it.previous(); - break; // iterator remains unchanged (no ligature!) - } + position--; + break; // iterator remains unchanged (no ligature!) + } else { // ligature - atom.changeAtom(new FixedCharAtom(lig)); // go on with the - // ligature + atom.changeAtom(new FixedCharAtom(lig)); // go on with the + // ligature } } else { it.previous(); - break; - }// iterator remains unchanged + position--; + break; + }// iterator remains unchanged } - + // insert glue, unless it's the first element of the row // OR this element or the next is a Kern. if (it.previousIndex() != 0 && previousAtom != null && !previousAtom.isKern() && !atom.isKern()) { hBox.add(Glue.get(previousAtom.getRightType(), atom.getLeftType(), env)); - } + } // insert atom's box atom.setPreviousAtom(previousAtom); Box b = atom.createBox(env); + if (markAdded || (at instanceof CharAtom && Character.isDigit(((CharAtom) at).getCharacter()))) { + hBox.addBreakPosition(hBox.children.size()); + } hBox.add(b); - + // set last used fontId (for next atom) env.setLastFontId(b.getLastFontId()); - + // insert kern - if (Math.abs(kern) > TeXFormula.PREC) + if (Math.abs(kern) > TeXFormula.PREC) { hBox.add(new StrutBox(kern, 0, 0, 0)); - + } + // kerns do not interfere with the normal glue-rules without kerns - if (!atom.isKern()) + if (!atom.isKern()) { previousAtom = atom; + } } // reset previousAtom previousAtom = null; - - // return resulting horizontal box - return hBox; + + return hBox; } - + public void setPreviousAtom(Dummy prev) { previousAtom = prev; } - + public int getLeftType() { - if (elements.equals("")) + if (elements.size() == 0) { return TeXConstants.TYPE_ORDINARY; - else + } else { return (elements.get(0)).getLeftType(); + } } - + public int getRightType() { - if (elements.equals("")) + if (elements.size() == 0) { return TeXConstants.TYPE_ORDINARY; - else + } else { return (elements.get(elements.size() - 1)).getRightType(); + } } } diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/ScaleBox.java libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/ScaleBox.java --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/ScaleBox.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/ScaleBox.java 2011-11-22 17:18:16.000000000 +0000 @@ -41,12 +41,12 @@ public ScaleBox(Box b, double xscl, double yscl) { this.box = b; - this.xscl = xscl; - this.yscl = yscl; - width = b.width * (float) Math.abs(xscl); - height = yscl > 0 ? b.height * (float) yscl : -b.depth * (float) yscl; - depth = yscl > 0 ? b.depth * (float) yscl : -b.height * (float) yscl; - shift = b.shift * (float) yscl; + this.xscl = (Double.isNaN(xscl) || Double.isInfinite(xscl)) ? 0 : xscl; + this.yscl = (Double.isNaN(yscl) || Double.isInfinite(yscl)) ? 0 : yscl; + width = b.width * (float) Math.abs(this.xscl); + height = this.yscl > 0 ? b.height * (float) this.yscl : -b.depth * (float) this.yscl; + depth = this.yscl > 0 ? b.depth * (float) this.yscl : -b.height * (float) this.yscl; + shift = b.shift * (float) this.yscl; } public ScaleBox(Box b, float factor) { @@ -56,12 +56,14 @@ public void draw(Graphics2D g2, float x, float y) { drawDebug(g2, x, y); - float dec = xscl < 0 ? width : 0; - g2.translate(x + dec, y); - g2.scale(xscl, yscl); - box.draw(g2, 0, 0); - g2.scale(1 / xscl, 1 / yscl); - g2.translate(-x - dec, -y); + if (xscl != 0 && yscl != 0) { + float dec = xscl < 0 ? width : 0; + g2.translate(x + dec, y); + g2.scale(xscl, yscl); + box.draw(g2, 0, 0); + g2.scale(1 / xscl, 1 / yscl); + g2.translate(-x - dec, -y); + } } public int getLastFontId() { diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/SpaceAtom.java libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/SpaceAtom.java --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/SpaceAtom.java 2011-05-08 11:30:44.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/SpaceAtom.java 2011-12-14 16:00:38.000000000 +0000 @@ -32,6 +32,7 @@ package org.scilab.forge.jlatexmath; import java.util.HashMap; +import java.util.Map; /** * An atom representing whitespace. The dimension values can be set using different @@ -39,7 +40,7 @@ */ public class SpaceAtom extends Atom { - private static HashMap units = new HashMap(); + private static Map units = new HashMap(); static { units.put("em", TeXConstants.UNIT_EM); units.put("ex", TeXConstants.UNIT_EX); @@ -56,7 +57,7 @@ units.put("in", TeXConstants.UNIT_IN); units.put("sp", TeXConstants.UNIT_SP); units.put("dd", TeXConstants.UNIT_DD); - units.put("dd", TeXConstants.UNIT_CC); + units.put("cc", TeXConstants.UNIT_CC); } private static interface UnitConversion { // NOPMD @@ -215,12 +216,12 @@ public static int getUnit(String unit) { Integer u = (Integer) units.get(unit); - return u == null ? -1 : u.intValue(); + return u == null ? TeXConstants.UNIT_PIXEL : u.intValue(); } public static float[] getLength(String lgth) { if (lgth == null) { - return new float[]{0f, 0f}; + return new float[]{TeXConstants.UNIT_PIXEL, 0f}; } int i = 0; diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/TeXFormula.java libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/TeXFormula.java --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/TeXFormula.java 2011-05-08 17:33:24.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/TeXFormula.java 2011-11-22 17:18:16.000000000 +0000 @@ -81,7 +81,7 @@ */ public class TeXFormula { - public static final String VERSION = "0.9.6"; + public static final String VERSION = "0.9.7"; public static final int SERIF = 0; public static final int SANSSERIF = 1; @@ -126,10 +126,11 @@ public static String[] symbolFormulaMappings = new String[65536]; public static Map externalFontMap = new HashMap(); - public List middle = new LinkedList(); + public List middle = new LinkedList(); + protected Map jlmXMLMap; private TeXParser parser; - + static { // character-to-symbol and character-to-delimiter mappings TeXFormulaSettingsParser parser = new TeXFormulaSettingsParser(); @@ -219,8 +220,21 @@ * @param s the string to be parsed * @throws ParseException if the string could not be parsed correctly */ + public TeXFormula(String s, Map map) throws ParseException { + this.jlmXMLMap = map; + this.textStyle = textStyle; + parser = new TeXParser(s, this); + parser.parse(); + } + + /** + * Creates a new TeXFormula by parsing the given string (using a primitive TeX parser). + * + * @param s the string to be parsed + * @throws ParseException if the string could not be parsed correctly + */ public TeXFormula(String s) throws ParseException { - this(s, null); + this(s, (String) null); } public TeXFormula(String s, boolean firstpass) throws ParseException { @@ -262,8 +276,9 @@ * Creates an empty TeXFormula. * */ - public TeXFormula(boolean isPartial) { - parser = new TeXParser(isPartial, "", this, false); + protected TeXFormula(TeXParser tp) { + this.jlmXMLMap = tp.formula.jlmXMLMap; + parser = new TeXParser(tp.getIsPartial(), "", this, false); } /** @@ -272,12 +287,14 @@ * @param s the string to be parsed * @throws ParseException if the string could not be parsed correctly */ - public TeXFormula(boolean isPartial, String s) throws ParseException { - this(isPartial, s, null); + protected TeXFormula(TeXParser tp, String s) throws ParseException { + this(tp, s, null); } - public TeXFormula(boolean isPartial, String s, boolean firstpass) throws ParseException { + protected TeXFormula(TeXParser tp, String s, boolean firstpass) throws ParseException { this.textStyle = null; + this.jlmXMLMap = tp.formula.jlmXMLMap; + boolean isPartial = tp.getIsPartial(); parser = new TeXParser(isPartial, s, this, firstpass); if (isPartial) { try { @@ -292,8 +309,10 @@ * Creates a TeXFormula by parsing the given string in the given text style. * Used when a text style command was found in the parse string. */ - public TeXFormula(boolean isPartial, String s, String textStyle) throws ParseException { + protected TeXFormula(TeXParser tp, String s, String textStyle) throws ParseException { this.textStyle = textStyle; + this.jlmXMLMap = tp.formula.jlmXMLMap; + boolean isPartial = tp.getIsPartial(); parser = new TeXParser(isPartial, s, this); if (isPartial) { try { @@ -308,8 +327,10 @@ } } - public TeXFormula(boolean isPartial, String s, String textStyle, boolean firstpass, boolean space) throws ParseException { + protected TeXFormula(TeXParser tp, String s, String textStyle, boolean firstpass, boolean space) throws ParseException { this.textStyle = textStyle; + this.jlmXMLMap = tp.formula.jlmXMLMap; + boolean isPartial = tp.getIsPartial(); parser = new TeXParser(isPartial, s, this, firstpass, space); if (isPartial) { try { @@ -371,12 +392,13 @@ public TeXFormula add(Atom el) { if (el != null) { if (el instanceof MiddleAtom) - middle.add((MiddleAtom)el); - if (root == null) + middle.add((MiddleAtom) el); + if (root == null) { root = el; - else { - if (!(root instanceof RowAtom)) + } else { + if (!(root instanceof RowAtom)) { root = new RowAtom(root); + } ((RowAtom) root).add(el); } } @@ -602,6 +624,22 @@ TeXEnvironment te = new TeXEnvironment(style, createFont(size, type), widthUnit, textwidth); Box box = createBox(te); HorizontalBox hb = new HorizontalBox(box, te.getTextwidth(), align); + + TeXIcon ti = new TeXIcon(hb, size, true); + ti.isColored = te.isColored; + return ti; + } + + public TeXIcon createTeXIcon(int style, float size, int widthUnit, float textwidth, int align, int interlineUnit, float interline) { + return createTeXIcon(style, size, 0, widthUnit, textwidth, align, interlineUnit, interline); + } + + public TeXIcon createTeXIcon(int style, float size, int type, int widthUnit, float textwidth, int align, int interlineUnit, float interline) { + TeXEnvironment te = new TeXEnvironment(style, createFont(size, type), widthUnit, textwidth); + Box box = createBox(te); + float il = interline * SpaceAtom.getFactor(interlineUnit, te); + HorizontalBox hb = new HorizontalBox(BreakFormula.split(box, te.getTextwidth(), il), te.getTextwidth(), align); + TeXIcon ti = new TeXIcon(hb, size, true); ti.isColored = te.isColored; return ti; @@ -679,7 +717,7 @@ * @param size the size * @param transparency, if true the background is transparent * @return the generated image - */ static int toto=0; + */ public Image createBufferedImage(int style, float size, Color fg, Color bg) throws ParseException { TeXIcon icon = createTeXIcon(style, size); icon.setInsets(new Insets(2, 2, 2, 2)); diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/TeXFormulaSettings.xml libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/TeXFormulaSettings.xml --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/TeXFormulaSettings.xml 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/TeXFormulaSettings.xml 2011-11-22 17:18:16.000000000 +0000 @@ -793,7 +793,7 @@ - + diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/TeXIcon.java libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/TeXIcon.java --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/TeXIcon.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/TeXIcon.java 2011-11-22 17:18:16.000000000 +0000 @@ -1,35 +1,35 @@ /* TeXIcon.java * ========================================================================= * This file is originally part of the JMathTeX Library - http://jmathtex.sourceforge.net - * + * * Copyright (C) 2004-2007 Universiteit Gent * Copyright (C) 2009 DENIZET Calixte - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. - * + * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. - * + * * A copy of the GNU General Public License can be found in the file * LICENSE.txt provided with the source distribution of this program (see * the META-INF directory in the source jar). This license can also be * found on the GNU website at http://www.gnu.org/licenses/gpl.html. - * + * * If you did not receive a copy of the GNU General Public License along * with this program, contact the lead developer, or write to the Free * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. - * + * */ /* Modified by Calixte Denizet */ - + package org.scilab.forge.jlatexmath; import java.awt.Color; @@ -48,200 +48,208 @@ *

* This class cannot be instantiated directly. It can be constructed from a * TeXFormula using the {@link TeXFormula#createTeXIcon(int,float)} method. - * + * * @author Kurt Vermeulen */ public class TeXIcon implements Icon { - + + private static final Color defaultColor = new Color(0, 0, 0); + public static float defaultSize = -1; public static float magFactor = 0; private Box box; - + private final float size; - + private Insets insets = new Insets(0, 0, 0, 0); - private Color fg = new Color(0, 0, 0); + private Color fg = null; public boolean isColored = false; - + /** * Creates a new icon that will paint the given formula box in the given point size. - * - * @param b the formula box to be painted + * + * @param b the formula box to be painted * @param size the point size */ protected TeXIcon(Box b, float size) { - this(b, size, false); + this(b, size, false); } protected TeXIcon(Box b, float size, boolean trueValues) { - box = b; - - if (defaultSize != -1) { - size = defaultSize; - } - - if (magFactor != 0) { - this.size = size * Math.abs(magFactor); - } else { - this.size = size; - } - - /* I add this little value because it seems that tftopl calculates badly - the height and the depth of certains characters. - */ - if (!trueValues) { - insets.top += (int)(0.18f * size); - insets.bottom += (int)(0.18f * size); - } + box = b; + + if (defaultSize != -1) { + size = defaultSize; + } + + if (magFactor != 0) { + this.size = size * Math.abs(magFactor); + } else { + this.size = size; + } + + /* I add this little value because it seems that tftopl calculates badly + the height and the depth of certains characters. + */ + if (!trueValues) { + insets.top += (int)(0.18f * size); + insets.bottom += (int)(0.18f * size); + } } public void setForeground(Color fg) { - this.fg = fg != null ? fg : new Color(0, 0, 0); + this.fg = fg; } - + /** * Get the insets of the TeXIcon. - * - * @return the insets + * + * @return the insets */ public Insets getInsets() { - return insets; + return insets; } - + /** * Set the insets of the TeXIcon. - * + * * @param insets the insets * @param trueValues true to force the true values */ public void setInsets(Insets insets, boolean trueValues) { - this.insets = insets; - if (!trueValues) { - this.insets.top += (int)(0.18f * size); - this.insets.bottom += (int)(0.18f * size); - } + this.insets = insets; + if (!trueValues) { + this.insets.top += (int)(0.18f * size); + this.insets.bottom += (int)(0.18f * size); + } } /** * Set the insets of the TeXIcon. - * + * * @param insets the insets */ public void setInsets(Insets insets) { - setInsets(insets, false); + setInsets(insets, false); } - + /** * Change the width of the TeXIcon. The new width must be greater than the current * width, otherwise the icon will remain unchanged. The formula will be aligned to the - * left ({@linkplain TeXConstants#ALIGN_LEFT}), to the right - * ({@linkplain TeXConstants#ALIGN_RIGHT}) or will be centered + * left ({@linkplain TeXConstants#ALIGN_LEFT}), to the right + * ({@linkplain TeXConstants#ALIGN_RIGHT}) or will be centered * in the middle ({@linkplain TeXConstants#ALIGN_CENTER}). - * + * * @param width the new width of the TeXIcon * @param alignment a horizontal alignment constant: LEFT, RIGHT or CENTER */ public void setIconWidth(int width, int alignment) { - float diff = width - getIconWidth(); - if (diff > 0) - box = new HorizontalBox(box, box.getWidth() + diff, alignment); + float diff = width - getIconWidth(); + if (diff > 0) + box = new HorizontalBox(box, box.getWidth() + diff, alignment); } - + /** * Change the height of the TeXIcon. The new height must be greater than the current - * height, otherwise the icon will remain unchanged. The formula will be aligned on top - * (TeXConstants.TOP), at the bottom (TeXConstants.BOTTOM) or will be centered + * height, otherwise the icon will remain unchanged. The formula will be aligned on top + * (TeXConstants.TOP), at the bottom (TeXConstants.BOTTOM) or will be centered * in the middle (TeXConstants.CENTER). - * + * * @param height the new height of the TeXIcon * @param alignment a vertical alignment constant: TOP, BOTTOM or CENTER */ public void setIconHeight(int height, int alignment) { - float diff = height - getIconHeight(); - if (diff > 0) - box = new VerticalBox(box, diff, alignment); + float diff = height - getIconHeight(); + if (diff > 0) + box = new VerticalBox(box, diff, alignment); } - + /** * Get the total height of the TeXIcon. This also includes the insets. */ public int getIconHeight() { - return ((int) ((box.getHeight()) * size + 0.99 + insets.top)) + ((int) ((box.getDepth()) * size + 0.99 + insets.bottom)); + return ((int) ((box.getHeight()) * size + 0.99 + insets.top)) + ((int) ((box.getDepth()) * size + 0.99 + insets.bottom)); } /** * Get the total height of the TeXIcon. This also includes the insets. */ public int getIconDepth() { - return (int) (box.getDepth() * size + 0.99 + insets.bottom); + return (int) (box.getDepth() * size + 0.99 + insets.bottom); } - + /** * Get the total width of the TeXIcon. This also includes the insets. */ - + public int getIconWidth() { - return (int) (box.getWidth() * size + 0.99 + insets.left + insets.right); + return (int) (box.getWidth() * size + 0.99 + insets.left + insets.right); } public float getTrueIconHeight() { - return (box.getHeight() + box.getDepth()) * size; + return (box.getHeight() + box.getDepth()) * size; } /** * Get the total height of the TeXIcon. This also includes the insets. */ public float getTrueIconDepth() { - return box.getDepth() * size; + return box.getDepth() * size; } - + /** * Get the total width of the TeXIcon. This also includes the insets. */ - + public float getTrueIconWidth() { - return box.getWidth() * size; + return box.getWidth() * size; } - + public float getBaseLine() { - return (float)( (box.getHeight() * size + 0.99 + insets.top) / - ((box.getHeight() + box.getDepth()) * size + 0.99 + insets.top + insets.bottom)); + return (float)( (box.getHeight() * size + 0.99 + insets.top) / + ((box.getHeight() + box.getDepth()) * size + 0.99 + insets.top + insets.bottom)); } - + + public Box getBox() { + return box; + } + /** - * Paint the {@link TeXFormula} that created this icon. + * Paint the {@link TeXFormula} that created this icon. */ public void paintIcon(Component c, Graphics g, int x, int y) { - Graphics2D g2 = (Graphics2D) g; - // copy graphics settings - RenderingHints oldHints = g2.getRenderingHints(); - AffineTransform oldAt = g2.getTransform(); - Color oldColor = g2.getColor(); - - // new settings - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); - g2.setRenderingHint(RenderingHints.KEY_RENDERING, - RenderingHints.VALUE_RENDER_QUALITY); - g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, - RenderingHints.VALUE_TEXT_ANTIALIAS_ON); - - g2.scale(size, size); // the point size - if (fg != null) { - g2.setColor(fg); - } else { - g2.setColor(c != null ? c.getForeground() : fg); // foreground will be used as default painting color - } - - // draw formula box - box.draw(g2, (x + insets.left) / size, (y + insets.top) / size+ box.getHeight()); - - // restore graphics settings - g2.setRenderingHints(oldHints); - g2.setTransform(oldAt); - g2.setColor(oldColor); + Graphics2D g2 = (Graphics2D) g; + // copy graphics settings + RenderingHints oldHints = g2.getRenderingHints(); + AffineTransform oldAt = g2.getTransform(); + Color oldColor = g2.getColor(); + + // new settings + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + g2.setRenderingHint(RenderingHints.KEY_RENDERING, + RenderingHints.VALUE_RENDER_QUALITY); + g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, + RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + + g2.scale(size, size); // the point size + if (fg != null) { + g2.setColor(fg); + } else if (c != null) { + g2.setColor(c.getForeground()); // foreground will be used as default painting color + } else { + g2.setColor(defaultColor); + } + + // draw formula box + box.draw(g2, (x + insets.left) / size, (y + insets.top) / size+ box.getHeight()); + + // restore graphics settings + g2.setRenderingHints(oldHints); + g2.setTransform(oldAt); + g2.setColor(oldColor); } } diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/TeXParser.java libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/TeXParser.java --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/TeXParser.java 2011-05-08 11:52:42.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/TeXParser.java 2011-12-08 17:11:16.000000000 +0000 @@ -53,6 +53,7 @@ private boolean arrayMode; private boolean ignoreWhiteSpace = true; private boolean isPartial; + private boolean autoNumberBreaking; // the escape character private static final char ESCAPE = '\\'; @@ -63,6 +64,7 @@ private static final char L_BRACK = '['; private static final char R_BRACK = ']'; private static final char DOLLAR = '$'; + private static final char DQUOTE = '\"'; // Percent char for comments private static final char PERCENT = '%'; @@ -161,10 +163,10 @@ this.parseString = new StringBuffer(parseString); this.len = parseString.length(); this.pos = 0; - if (firstpass) + if (firstpass) { firstpass(); - } - else { + } + } else { this.parseString = null; this.pos = 0; this.len = 0; @@ -648,7 +650,7 @@ pos++; } - formula.add(new MathAtom(new TeXFormula(isPartial, getDollarGroup(DOLLAR), false).root, style)); + formula.add(new MathAtom(new TeXFormula(this, getDollarGroup(DOLLAR), false).root, style)); if (doubleDollar) { if (parseString.charAt(pos) == DOLLAR) { pos++; @@ -660,10 +662,11 @@ Atom at = processEscape(); formula.add(at); if (arrayMode && at instanceof HlineAtom) { - ((ArrayOfAtoms)formula).addRow(); + ((ArrayOfAtoms) formula).addRow(); } - if (insertion) + if (insertion) { insertion = false; + } break; case L_GROUP : Atom atom = getArgument(); @@ -676,8 +679,7 @@ group--; pos++; if (group == -1) - throw new ParseException("Found a closing '" + R_GROUP - + "' without an opening '" + L_GROUP + "'!"); + throw new ParseException("Found a closing '" + R_GROUP + "' without an opening '" + L_GROUP + "'!"); return; case SUPER_SCRIPT : case SUB_SCRIPT : @@ -705,6 +707,16 @@ } pos++; break; + case DQUOTE : + if (ignoreWhiteSpace) { + formula.add(new CumulativeScriptsAtom(getLastAtom(), null, SymbolAtom.get("prime"))); + formula.add(new CumulativeScriptsAtom(getLastAtom(), null, SymbolAtom.get("prime"))); + } else { + formula.add(convertCharacter(PRIME, true)); + formula.add(convertCharacter(PRIME, true)); + } + pos++; + break; default : formula.add(convertCharacter(ch, false)); pos++; @@ -953,8 +965,8 @@ } Atom at = convertCharacter(ch, true); - pos++; - return at; + pos++; + return at; } public String getOverArgument() throws ParseException { @@ -1015,6 +1027,23 @@ return str; } + public float[] getLength() throws ParseException { + if (pos == len) + return null; + + int ogroup = 1, spos; + char ch = '\0'; + + skipWhiteSpace(); + spos = pos; + while (pos < len && ch != ' ') { + ch = parseString.charAt(pos++); + } + skipWhiteSpace(); + + return SpaceAtom.getLength(parseString.substring(spos, pos - 1)); + } + /** Convert a character in the corresponding atom in using the file TeXFormulaSettings.xml for non-alphanumeric characters * @param c the character to be converted * @return the corresponding atom @@ -1039,10 +1068,10 @@ String symbolName = TeXFormula.symbolMappings[c]; if (symbolName == null && (TeXFormula.symbolFormulaMappings == null || TeXFormula.symbolFormulaMappings[c] == null)) { TeXFormula.FontInfos fontInfos = TeXFormula.externalFontMap.get(block); - if (fontInfos != null) { - if (oneChar) { - return new JavaFontRenderingAtom(Character.toString(c), fontInfos); - } + if (fontInfos != null) { + if (oneChar) { + return new JavaFontRenderingAtom(Character.toString(c), fontInfos); + } int start = pos++; int end = len - 1; while (pos < len) { @@ -1083,11 +1112,11 @@ } } else { // alphanumeric character - TeXFormula.FontInfos fontInfos = TeXFormula.externalFontMap.get(Character.UnicodeBlock.BASIC_LATIN); - if (fontInfos != null) { - if (oneChar) { - return new JavaFontRenderingAtom(Character.toString(c), fontInfos); - } + TeXFormula.FontInfos fontInfos = TeXFormula.externalFontMap.get(Character.UnicodeBlock.BASIC_LATIN); + if (fontInfos != null) { + if (oneChar) { + return new JavaFontRenderingAtom(Character.toString(c), fontInfos); + } int start = pos++; int end = len - 1; while (pos < len) { @@ -1222,12 +1251,15 @@ args[i] = "" + parseString.charAt(pos); pos++; } - else + else { args[i] = getCommandWithArgs(getCommand()); + } } } - skipWhiteSpace(); + if (ignoreWhiteSpace) { + skipWhiteSpace(); + } } return args; } diff -Nru libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/VerticalBox.java libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/VerticalBox.java --- libjlatexmath-java-0.9.6/src/org/scilab/forge/jlatexmath/VerticalBox.java 2011-05-06 11:52:26.000000000 +0000 +++ libjlatexmath-java-0.9.7/src/org/scilab/forge/jlatexmath/VerticalBox.java 2011-11-22 17:18:16.000000000 +0000 @@ -69,6 +69,13 @@ depth += b.height + b.depth; recalculateWidth(b); } + + public final void add(Box b, float interline) { + if (children.size() == 1) { + add(new StrutBox(0, interline, 0, 0)); + } + add(b); + } private void recalculateWidth(Box b) { leftMostPos = Math.min(leftMostPos, b.shift); diff -Nru libjlatexmath-java-0.9.6/version.xml libjlatexmath-java-0.9.7/version.xml --- libjlatexmath-java-0.9.6/version.xml 2011-05-08 13:51:20.000000000 +0000 +++ libjlatexmath-java-0.9.7/version.xml 2011-11-22 17:18:16.000000000 +0000 @@ -1,5 +1,5 @@ - +