Index: lams_central/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -r078ffcc5cce6214e179857ace04486fa04a7e3a2 -r662e144da0df02dfacd0f157c29bc12012cab224 --- lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 078ffcc5cce6214e179857ace04486fa04a7e3a2) +++ lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 662e144da0df02dfacd0f157c29bc12012cab224) @@ -652,5 +652,14 @@ authoring.fla.liveedit.readonly.remove.child.error =The activity can not be removed. It has read-only child activities. authoring.fla.liveedit.readonly.remove.transition.error =The transition can not be removed. It is read-only. +ckeditor.math.greek =Greek +ckeditor.math.uppercase =uppercase +ckeditor.math.misc =misc +ckeditor.math.binary =binary +ckeditor.math.large =large +ckeditor.math.relations =relations +ckeditor.math.negatedrelations =negated
relations +ckeditor.math.arrows =arrows +ckeditor.math.combining =combining #======= End labels: Exported 438 labels for en AU ===== Index: lams_central/src/java/org/lamsfoundation/lams/web/JlatexmathServlet.java =================================================================== diff -u -r3b2ee7c25ecf993b0ec1b05d5b2333165db03ccf -r662e144da0df02dfacd0f157c29bc12012cab224 --- lams_central/src/java/org/lamsfoundation/lams/web/JlatexmathServlet.java (.../JlatexmathServlet.java) (revision 3b2ee7c25ecf993b0ec1b05d5b2333165db03ccf) +++ lams_central/src/java/org/lamsfoundation/lams/web/JlatexmathServlet.java (.../JlatexmathServlet.java) (revision 662e144da0df02dfacd0f157c29bc12012cab224) @@ -18,9 +18,9 @@ * * http://www.gnu.org/licenses/gpl.txt * **************************************************************** - */ - -/* $Id$ */ + */ + +/* $Id$ */ package org.lamsfoundation.lams.web; import java.awt.AlphaComposite; @@ -37,7 +37,9 @@ import javax.swing.JLabel; import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; import org.lamsfoundation.lams.util.WebUtil; +import org.scilab.forge.jlatexmath.ParseException; import org.scilab.forge.jlatexmath.TeXConstants; import org.scilab.forge.jlatexmath.TeXFormula; import org.scilab.forge.jlatexmath.TeXIcon; @@ -49,46 +51,65 @@ * @web:servlet-mapping url-pattern="/servlet/jlatexmath" */ public class JlatexmathServlet extends HttpServlet { - + + private static Logger log = Logger.getLogger(JlatexmathServlet.class); + @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - + String formulaParam = request.getParameter("formula"); if (StringUtils.isBlank(formulaParam)) { return; } - + Integer fontSize = WebUtil.readIntParam(request, "fontSize", true); if (fontSize == null) { fontSize = 20; } - - TeXFormula formula = new TeXFormula(formulaParam); - TeXIcon icon = formula.new TeXIconBuilder().setStyle(TeXConstants.STYLE_DISPLAY) - .setSize(fontSize) - .setWidth(TeXConstants.UNIT_PIXEL, 256f, TeXConstants.ALIGN_CENTER) - .setIsMaxWidth(true).setInterLineSpacing(TeXConstants.UNIT_PIXEL, 20f) - .build(); - -// TeXFormula fomule = new TeXFormula(formula); -// TeXIcon ti = fomule.createTeXIcon(TeXConstants.STYLE_DISPLAY, 40); - BufferedImage b = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); -// Color transparent = new Color(0, true); -// ((Graphics2D)b.getGraphics()).setBackground(transparent); -// b.getGraphics().clearRect(0, 0, icon.getIconWidth(), icon.getIconHeight()); - - ((Graphics2D)b.getGraphics()).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5F)); + + TeXFormula formula = null; + try { + formula = new TeXFormula(formulaParam); + } catch (ParseException e) { + // don't throw a full-blown exception whenever an user makes a mistake in the formula + if (JlatexmathServlet.log.isTraceEnabled()) { + JlatexmathServlet.log.trace(e.getMessage()); + } + return; + } + + TeXIcon icon = formula.new TeXIconBuilder().setStyle(TeXConstants.STYLE_DISPLAY).setSize(fontSize) + .setWidth(TeXConstants.UNIT_PIXEL, 256f, TeXConstants.ALIGN_CENTER).setIsMaxWidth(true) + .setInterLineSpacing(TeXConstants.UNIT_PIXEL, 20f).build(); + + BufferedImage b = null; + // TeXFormula fomule = new TeXFormula(formula); + // TeXIcon ti = fomule.createTeXIcon(TeXConstants.STYLE_DISPLAY, 40); + try { + b = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); + } catch (IllegalArgumentException e) { + // don't throw a full-blown exception whenever an user makes a mistake in the formula + if (JlatexmathServlet.log.isTraceEnabled()) { + JlatexmathServlet.log.trace(e.getMessage()); + } + return; + } + // Color transparent = new Color(0, true); + // ((Graphics2D)b.getGraphics()).setBackground(transparent); + // b.getGraphics().clearRect(0, 0, icon.getIconWidth(), icon.getIconHeight()); + + ((Graphics2D) b.getGraphics()).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5F)); icon.paintIcon(new JLabel(), b.getGraphics(), 0, 0); - + response.setContentType("image/png"); OutputStream out = response.getOutputStream(); ImageIO.write(b, "png", out); out.close(); } @Override - protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, - IOException { + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { doGet(request, response); } } Index: lams_central/web/ckeditor/plugins/jlatexmath/buttons.css =================================================================== diff -u --- lams_central/web/ckeditor/plugins/jlatexmath/buttons.css (revision 0) +++ lams_central/web/ckeditor/plugins/jlatexmath/buttons.css (revision 662e144da0df02dfacd0f157c29bc12012cab224) @@ -0,0 +1,44 @@ +#formulaButtonsTable { + border-spacing: 0; + border-collapse: collapse; + margin-bottom: 10px; +} + +#formulaButtonsTable td { + padding: 6px 0 3px 0; + border-bottom: 1px solid gray; +} + +#formulaButtonsTable th { + font-size: 14px; + font-weight: normal; + padding-right: 15px; + border-bottom: 1px solid gray; +} + +#formulaButtonsTable tbody tr:last-child td, #formulaButtonsTable tbody tr:last-child th { + border-bottom: none; +} + +#formulaButtonsTable button { + width: 30px; + height: 25px; + margin: 0 0 4px 0; + background: none; + background-color: #EEEEEE; + color: black; + font-size : 14px; + font-weight: normal; +} + +#formulaButtonsTable button:hover { + background-color: #DDDDDD; +} + +#formulaButtonsTable button span { + padding: 2px 3px 3px 3px !important; +} + +#formulaButtonsTable button.formulaButtonShifted span { + padding-top: 0px !important; +} \ No newline at end of file Index: lams_central/web/ckeditor/plugins/jlatexmath/buttons.js =================================================================== diff -u --- lams_central/web/ckeditor/plugins/jlatexmath/buttons.js (revision 0) +++ lams_central/web/ckeditor/plugins/jlatexmath/buttons.js (revision 662e144da0df02dfacd0f157c29bc12012cab224) @@ -0,0 +1,16 @@ +function insertFormula(text) { + var textarea = $('#latex-formula').focus(), + cursorPos = textarea.prop('selectionStart'), + v = textarea.val(), + textBefore = v.substring(0, cursorPos), + textAfter = v.substring(cursorPos, v.length); + textarea.val(textBefore + text + textAfter); + cursorPos = cursorPos + text.length; + textarea.prop('selectionEnd', cursorPos); + textarea.prop('selectionStart', cursorPos); + formulaTextareaChanged(); +} + +$(document).ready(function(){ + $('#formulaButtonsTable button').button(); +}); \ No newline at end of file Index: lams_central/web/ckeditor/plugins/jlatexmath/buttons.jsp =================================================================== diff -u --- lams_central/web/ckeditor/plugins/jlatexmath/buttons.jsp (revision 0) +++ lams_central/web/ckeditor/plugins/jlatexmath/buttons.jsp (revision 662e144da0df02dfacd0f157c29bc12012cab224) @@ -0,0 +1,254 @@ +<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
\ No newline at end of file Index: lams_central/web/ckeditor/plugins/jlatexmath/jlatexmath.jsp =================================================================== diff -u -r3b2ee7c25ecf993b0ec1b05d5b2333165db03ccf -r662e144da0df02dfacd0f157c29bc12012cab224 --- lams_central/web/ckeditor/plugins/jlatexmath/jlatexmath.jsp (.../jlatexmath.jsp) (revision 3b2ee7c25ecf993b0ec1b05d5b2333165db03ccf) +++ lams_central/web/ckeditor/plugins/jlatexmath/jlatexmath.jsp (.../jlatexmath.jsp) (revision 662e144da0df02dfacd0f157c29bc12012cab224) @@ -14,6 +14,13 @@ + + + + + + +