当前位置: 首页>>代码示例>>Java>>正文


Java TeXConstants类代码示例

本文整理汇总了Java中org.scilab.forge.jlatexmath.TeXConstants的典型用法代码示例。如果您正苦于以下问题:Java TeXConstants类的具体用法?Java TeXConstants怎么用?Java TeXConstants使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TeXConstants类属于org.scilab.forge.jlatexmath包,在下文中一共展示了TeXConstants类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getStringDimension

import org.scilab.forge.jlatexmath.TeXConstants; //导入依赖的package包/类
/**
 * Get string dimension
 *
 * @param str String
 * @param g Graphics2D
 * @return String dimension
 */
public static Dimension getStringDimension(String str, Graphics2D g) {
    if (isLaTeX(str)) {
        float size = g.getFont().getSize2D();
        // create a formula
        TeXFormula formula = new TeXFormula(str);

        // render the formla to an icon of the same size as the formula.
        TeXIcon icon = formula.createTeXIcon(TeXConstants.STYLE_TEXT, size);

        // insert a border 
        //icon.setInsets(new Insets(5, 5, 5, 5));
        //return new Dimension(icon.getIconWidth(), icon.getIconHeight());
        int width = (int) icon.getTrueIconWidth() + 10;
        //int height = (int)icon.getTrueIconHeight();
        int height = icon.getIconHeight();
        return new Dimension(width, height);
    } else {
        FontMetrics metrics = g.getFontMetrics();
        //return new Dimension(metrics.stringWidth(str), metrics.getHeight());
        return new Dimension(metrics.stringWidth(str), metrics.getAscent());
    }
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:30,代码来源:Draw.java

示例2: drawLaTeX

import org.scilab.forge.jlatexmath.TeXConstants; //导入依赖的package包/类
/**
 * Draw LaTeX string
 *
 * @param g Graphics2D
 * @param str String
 * @param size Size
 * @param x X
 * @param y Y
 * @param useExternalFont If use external font
 */
public static void drawLaTeX(Graphics2D g, String str, float size, float x, float y, boolean useExternalFont) {
    if (useExternalFont) {
        //Set font
        TeXFormula.registerExternalFont(Character.UnicodeBlock.BASIC_LATIN, g.getFont().getName());
    } else {
        TeXFormula.registerExternalFont(Character.UnicodeBlock.BASIC_LATIN, null, null);
    }

    // create a formula
    TeXFormula formula = new TeXFormula(str);

    // render the formla to an icon of the same size as the formula.
    TeXIcon icon = formula.createTeXIcon(TeXConstants.STYLE_TEXT, size);

    // insert a border 
    icon.setInsets(new Insets(5, 5, 5, 5));
    icon.setForeground(g.getColor());
    y = y - (icon.getIconHeight() * 2.0f / 3.f);
    icon.paintIcon(null, g, (int) x, (int) y);
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:31,代码来源:Draw.java

示例3: convertToImage

import org.scilab.forge.jlatexmath.TeXConstants; //导入依赖的package包/类
/**
 * The convertToImage method is used to convert a LaTeX string to an PNG image file.
 * 
 * @param imageFile
 * @param latexString
 * @throws Exception
 */
public static void convertToImage(File imageFile, String latexString) throws Exception
{
    TeXFormula formula = new TeXFormula(latexString);
    
    TeXIcon icon = formula.new TeXIconBuilder().setStyle(TeXConstants.STYLE_DISPLAY).setSize(20).build();
    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);
    g2.fillRect(0,0,icon.getIconWidth(),icon.getIconHeight());
    
    JLabel jl = new JLabel();
    jl.setForeground(new Color(0, 0, 0));
    icon.paintIcon(jl, g2, 0, 0);
    
    ImageIO.write(image, "png", imageFile.getAbsoluteFile());
}
 
开发者ID:bclemenzi,项目名称:latex-converter,代码行数:27,代码来源:LaTeXConverter.java

示例4: sym

import org.scilab.forge.jlatexmath.TeXConstants; //导入依赖的package包/类
public static String sym(String symCommand) throws Exception {
        StringBufferWriter buf = new StringBufferWriter();
        IExpr result = GlobalValues.symUtil.evaluate(symCommand);
        OutputFormFactory.get().convert(buf, result);
        String output = buf.toString();

        output = symCommand + " = " + output;

        int FONT_SIZE_TEX = GlobalValues.FONT_SIZE_TEX;

        if (GlobalValues.displayLatexOnEval) {
// display the LaTex formula graphically
            final StringBufferWriter bufTex = new StringBufferWriter();
            GlobalValues.texUtil.toTeX(symCommand + "=" + result, bufTex);
            String forLatexPrettyOut = bufTex.toString();

            org.scilab.forge.jlatexmath.TeXFormula formula = new org.scilab.forge.jlatexmath.TeXFormula(forLatexPrettyOut);
            org.scilab.forge.jlatexmath.TeXIcon ticon = formula.createTeXIcon(TeXConstants.STYLE_DISPLAY, FONT_SIZE_TEX, TeXConstants.UNIT_PIXEL, 80, TeXConstants.ALIGN_LEFT);

            GlobalValues.uiTabbedPane.setIconAt(0, ticon);

        }
        return output;
    }
 
开发者ID:scalalab,项目名称:scalalab,代码行数:25,代码来源:BasicCommands.java

示例5: latexRender

import org.scilab.forge.jlatexmath.TeXConstants; //导入依赖的package包/类
public static void latexRender(String latex) {
    TeXFormula tf = new TeXFormula(latex);
    TeXIcon icontf = tf.createTeXIcon(TeXConstants.STYLE_DISPLAY, 20);
    icontf.setInsets(new Insets(5, 5, 5, 5));

    OutputTextPane otp = new OutputTextPane();
    otp.addIcon(icontf, 0, true);
    JPanel jp = new JPanel();
    jp.add(otp);

    JFrame tstF = new JFrame("test");
    tstF.add(jp);
    tstF.setSize(200, 200);
    tstF.setVisible(true);


}
 
开发者ID:scalalab,项目名称:scalalab,代码行数:18,代码来源:plot.java

示例6: LatexImage

import org.scilab.forge.jlatexmath.TeXConstants; //导入依赖的package包/类
public LatexImage(String _latexStr, int x, int y) {
    plotAbsolute = true;
    xcoord = x;
    ycoord = y;
    latexStr = _latexStr;

    TeXFormula formula = new TeXFormula(true, latexStr);
    TeXIcon icon = formula.createTeXIcon(TeXConstants.STYLE_DISPLAY, 20);
    icon.setInsets(new Insets(5, 5, 5, 5));

    img = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = img.createGraphics();
    g2.setColor(Color.white);
    g2.fillRect(0, 0, icon.getIconWidth(), icon.getIconHeight());
    JLabel jl = new JLabel();
    jl.setForeground(new Color(0, 0, 0));
    icon.paintIcon(jl, g2, 0, 0);

    alpha = (float) 0.5;

}
 
开发者ID:scalalab,项目名称:scalalab,代码行数:22,代码来源:LatexImage.java

示例7: generate_image_from_icon

import org.scilab.forge.jlatexmath.TeXConstants; //导入依赖的package包/类
@Test
public void generate_image_from_icon() throws IOException {
    String formula = "" +
            "\\Re{z} =\\frac{n\\pi \\dfrac{\\theta +\\psi}{2}}{\n" +
            "            \\left(\\dfrac{\\theta +\\psi}{2}\\right)^2 + \\left( \\dfrac{1}{2}\n" +
            "            \\log \\left\\vert\\dfrac{B}{A}\\right\\vert\\right)^2}.";

    TeXFormula teXFormula = new TeXFormula(formula);
    TeXIcon teXIcon = teXFormula.createTeXIcon(TeXConstants.STYLE_DISPLAY, 14f);

    BufferedImage image = new BufferedImage(teXIcon.getIconWidth(), teXIcon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = (Graphics2D)image.getGraphics();
    teXIcon.paintIcon(null, g2, 0, 0);
    g2.dispose();

    File output = new File(settings.workingDir(), "TeXFormulaTest__generate_image_from_icon.png");
    ImageIO.write(image, "png", output);
    System.out.println("TeXFormulaTest.generate_image_from_icon::" + output.getAbsolutePath());
}
 
开发者ID:Arnauld,项目名称:gutenberg,代码行数:20,代码来源:TeXFormulaTest.java

示例8: getLatexImage

import org.scilab.forge.jlatexmath.TeXConstants; //导入依赖的package包/类
public static BufferedImage getLatexImage(String latex) {

		TeXFormula formula = new TeXFormula(latex);
		TeXIcon icon = formula.createTeXIcon(TeXConstants.STYLE_DISPLAY, 48);
		icon.setInsets(new Insets(5, 5, 5, 5));
		
		BufferedImage image = new BufferedImage(icon.getIconWidth()+75, icon.getIconHeight()+75, BufferedImage.TYPE_INT_ARGB);
		Graphics2D g2 = image.createGraphics();
		g2.setColor(Color.white);
		g2.fillRect(0,0,icon.getIconWidth()+75,icon.getIconHeight()+75);
		JLabel jl = new JLabel();
		jl.setForeground(new Color(0, 0, 0));
		icon.paintIcon(jl, g2, 37, 37);
		
		return image;
	}
 
开发者ID:tbluche,项目名称:MERStructure,代码行数:17,代码来源:LatexParser.java

示例9: latexCodeToImageIcon

import org.scilab.forge.jlatexmath.TeXConstants; //导入依赖的package包/类
/**
*
* @param codeLaTEX
* @return une image qui représente ce qu'affiche LaTEX à la place du code codeLaTEX
*/
   static Icon latexCodeToImageIcon(String codeLaTEX)
   {
        TeXFormula formula = new TeXFormula(codeLaTEX);
        TeXIcon ti = formula.createTeXIcon(TeXConstants.STYLE_DISPLAY, 20);

        return ti;

   }
 
开发者ID:touist,项目名称:touist,代码行数:14,代码来源:LaTEX.java

示例10: plot

import org.scilab.forge.jlatexmath.TeXConstants; //导入依赖的package包/类
/**
 * see Text for formatted text output
 */
public void plot(AbstractDrawer draw) {
    if (!visible) return;

    TeXFormula formula = new TeXFormula(label);

    TeXIcon icon = formula.createTeXIcon(TeXConstants.STYLE_DISPLAY, size);
    icon.setTeXIconColor(plotColor);
    //icon.setInsets(new Insets(5, 5, 5, 5));

    Graphics2D g2 = draw.getGraphics();
    g2.setColor(plotColor);

    JLabel jl = new JLabel();

    jl.setForeground(plotColor);  // GlobalValues.defaultFormulaColor);
    if (useLogical == false)   // do not use logical coordinates
        icon.paintIcon(jl, g2, coordx, coordy);
    else  // use logical coordinates to place the formula
    {
        double[] logicalCoords = {logicalx, logicaly};
        int[] screenCoords = draw.project(logicalCoords[0], logicalCoords[1]);
        icon.paintIcon(jl, g2, screenCoords[0], screenCoords[1]);


    }
}
 
开发者ID:scalalab,项目名称:scalalab,代码行数:30,代码来源:texLabel.java

示例11: createImage

import org.scilab.forge.jlatexmath.TeXConstants; //导入依赖的package包/类
/**
 * This method creates the image from the equation given.
 * @param equation - The equation to parse
 * @return
 */
public static BufferedImage createImage(String equation) {
    TeXFormula fomule = new TeXFormula(equation);
    TeXIcon ti = fomule.createTeXIcon(
            TeXConstants.STYLE_DISPLAY, 40);
    BufferedImage b = new BufferedImage(ti.getIconWidth(), ti
            .getIconHeight(), BufferedImage.TYPE_4BYTE_ABGR);
    ti.paintIcon(new JLabel(), b.getGraphics(), 0, 0);
    return b;
}
 
开发者ID:crro,项目名称:GoogleGlassServerHeroku,代码行数:15,代码来源:Main.java

示例12: paint

import org.scilab.forge.jlatexmath.TeXConstants; //导入依赖的package包/类
public void paint( Graphics g )
	{
		if( reparseSrcOnRepaint )
		{
			this.setLaTeXSrc( this.texSrc, false );
			reparseSrcOnRepaint = false;
		}
		super.paint( g );
		if( this.isOpaque() )
		{
			g.setColor( this.getBackground() );
			g.fillRect(0, 0, this.getWidth(), this.getHeight() );			
		}
		
		// scale font size according to ratio of actual size vs. preferred size
		float xScale = this.getPreferredSize() != null ? this.getWidth() / ( float ) this.getPreferredSize().width : 1.0f; 
		float yScale = this.getPreferredSize() != null ? this.getHeight() / ( float ) this.getPreferredSize().height : 1.0f;
		float scale = ( xScale < yScale ? xScale : yScale );
//		System.out.println( scale );
		TeXIcon texIcon = texFormula.createTeXIcon( TeXConstants.STYLE_TEXT, 0.88f * 30f * scale, TeXFormula.SANSSERIF, TeXConstants.UNIT_PIXEL, 1920f, TeXConstants.ALIGN_CENTER );
		
		texIcon.setInsets( this.getInsets() );
		
		int x, y;
		switch( halign )
		{
			case LEFT: x = 0; break;
			case RIGHT: x = this.getWidth() - texIcon.getIconWidth(); break;
			case CENTER:
			default: x = ( this.getWidth() - texIcon.getIconWidth() ) / 2; break;
		}
		switch( valign )
		{
			case TOP: y = 0; break;
			case BOTTOM: y = this.getHeight() - texIcon.getIconHeight(); break;
			case CENTER_BASELINE: y = ( this.getHeight() - texIcon.getIconHeight() + texIcon.getIconDepth()  ) / 2; break;
			case CENTER: 
			default: y = ( this.getHeight() - texIcon.getIconHeight() ) / 2; break;
		}
		
		texIcon.paintIcon( this, g, x, y );
	}
 
开发者ID:IMAGINARY,项目名称:FormulaMorph,代码行数:43,代码来源:LaTeXLabel.java

示例13: updateFormula

import org.scilab.forge.jlatexmath.TeXConstants; //导入依赖的package包/类
public void updateFormula(String sFormula, int size) {
	TeXFormula formula = new TeXFormula(sFormula);
	TeXIcon icon = formula.new TeXIconBuilder().setStyle(TeXConstants.STYLE_DISPLAY)
			.setSize(size)
			.build();
	this.setIcon(icon);
	setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
}
 
开发者ID:THoffbauer,项目名称:Scales,代码行数:9,代码来源:FormulaLabel.java

示例14: emit

import org.scilab.forge.jlatexmath.TeXConstants; //导入依赖的package包/类
@Override
public void emit(SourceCode sourceCode, ITextContext context) {
    String lang = sourceCode.lang();
    String code = sourceCode.content();

    try {
        String trimmed = Strings.unindentBlock(code);

        log.debug("Initializing text grid");
        TeXFormula formula = new TeXFormula(trimmed);
        TeXIcon teXIcon = formula.createTeXIcon(TeXConstants.STYLE_DISPLAY, 14f);
        teXIcon.setInsets(new Insets(1, 1, 1, 1));
        teXIcon.setForeground(foreground);

        PdfWriter pdfWriter = context.getPdfWriter();
        PdfContentByte cb = pdfWriter.getDirectContent();
        float width = (float) teXIcon.getIconWidth();
        float height = (float) teXIcon.getIconHeight();

        PdfTemplate template = cb.createTemplate(width, height);
        Graphics2D g2 = new PdfGraphics2D(template, width, height, new JLaTeXmathFontMapper());

        log.debug("Rendering formula");
        teXIcon.paintIcon(null, g2, 0, 0);
        g2.dispose();

        log.debug("Rendering diagram done");
        ImgTemplate imgTemplate = new ImgTemplate(template);
        scaleToFit(imgTemplate, context.getDocumentArtBox());

        context.append(imgTemplate);

    } catch (Exception e) {
        throw new WrappedRuntimeException(e);
    }

}
 
开发者ID:Arnauld,项目名称:gutenberg,代码行数:38,代码来源:SourceCodeLaTeXExtension.java

示例15: generate_image

import org.scilab.forge.jlatexmath.TeXConstants; //导入依赖的package包/类
@Test
public void generate_image() throws IOException {
    String formula = "" +
            "\\Re{z} =\\frac{n\\pi \\dfrac{\\theta +\\psi}{2}}{\n" +
            "            \\left(\\dfrac{\\theta +\\psi}{2}\\right)^2 + \\left( \\dfrac{1}{2}\n" +
            "            \\log \\left\\vert\\dfrac{B}{A}\\right\\vert\\right)^2}.";

    TeXFormula.setDPITarget(600);

    BufferedImage image = (BufferedImage)TeXFormula.createBufferedImage(formula, TeXConstants.STYLE_DISPLAY, 14f, Color.BLUE, Color.WHITE);
    File output = new File(settings.workingDir(), "TeXFormulaTest__generate_image.png");
    ImageIO.write(image, "png", output);
    System.out.println("TeXFormulaTest.generate_image::" + output.getAbsolutePath());
}
 
开发者ID:Arnauld,项目名称:gutenberg,代码行数:15,代码来源:TeXFormulaTest.java


注:本文中的org.scilab.forge.jlatexmath.TeXConstants类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。