⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 texobject.java

📁 著名的开源仿真软件yale
💻 JAVA
字号:
/* *  YALE - Yet Another Learning Environment *  Copyright (C) 2002, 2003 *      Simon Fischer, Ralf Klinkenberg, Ingo Mierswa,  *          Katharina Morik, Oliver Ritthoff *      Artificial Intelligence Unit *      Computer Science Department *      University of Dortmund *      44221 Dortmund,  Germany *  email: yale@ls8.cs.uni-dortmund.de *  web:   http://yale.cs.uni-dortmund.de/ * *  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; if not, write to the Free Software *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *  USA. */package edu.udo.cs.yale.tools;public class TexObject {        private String string;    private int width, height;    private static final int MARGIN = 1;    private static final int FONT_HEIGHT = 3;    public static final int OPERATOR_FORMAT = 1;    public static final int CLASS_FORMAT    = 2;    public static final int IO_FORMAT       = 3;    public static final String[] COLOUR = {"red", "yellow", "magenta"};    public TexObject() {	string = "";	width  = 0;	height = 0;    }    public void add(TexObject o, int x, int y) {	string += "\\put("+x+","+y+"){" + o.string + "}\n";	width  = Math.max(width, x+o.width);	height = Math.max(height, y+o.height);    }    public void addRectCentered(int x, int y, int w, int h, String str) {	string += "\\put("+x+","+y+"){\\framebox("+w+","+h+"){"+str+"}}\n";	width  = Math.max(width, x+w);	height = Math.max(height, y+h);    }    public void addRectUL(int x, int y, int w, int h, String str) {	addRectUL(x, y, w, h, str, -1);    }    public void addRectUL(int x, int y, int w, int h, String str, int color) {	if (color != -1)	    string += "{\\color{"+COLOUR[color]+"}\\put("+x+","+y+         "){\\rule{"+w*2+ "mm}{"+h*2+"mm}}}\n";	string += "\\put("+x+","+y+         "){\\framebox("+w+ ","+h+           "){}}\n";	string += "\\put("+x+","+(y+MARGIN)+"){\n\\makebox("+w+","+(h-2*MARGIN)+")[tl]{\n"+str+"\n}}\n";	width  = Math.max(width,  x+w);	height = Math.max(height, y+h);	    }    public void addVector(int x, int y, int w, String label) {	string += "\\put("+x+","+y+"){\\vector(1,0){"+w+"}}\n";	string += "\\put("+x+","+y+"){\\makebox("+w+","+FONT_HEIGHT+")[b]{"+label+"}}\n";	width  = Math.max(width,  x+w);	height = Math.max(height, y);	    }    public int getWidth() {	return width;    }    public int getHeight() {	return height;    }    public static String format(String s, int format) {	switch(format) {	case OPERATOR_FORMAT:	    return "{\\sf\\small "+s+"}";	case CLASS_FORMAT:	    return "{\\tt\\small "+s+"}";	case IO_FORMAT:	    return "{\\sf\\footnotesize "+s+"}";	default:	    return s;	}    }    public static String shortClassName(String lclass) {	String c = new String(lclass);	int p = -1;	while ((p = c.indexOf(".")) >= 0) 	    c = c.substring(p+1);	return c;    }    public String toString() {	return 	    "\\setlength{\\unitlength}{0.2cm}\n"+	    "\\begin{picture}("+width+","+height+")\n" +	    string +	    "\\end{picture}\n";    }        public static void main(String[] argv) {	TexObject to = new TexObject();	to.addRectUL(0,0,50,8,format("OperatorChain", OPERATOR_FORMAT));	TexObject to2 = new TexObject();	to2.addRectCentered(0,0,15,4,format("SVMLearner", CLASS_FORMAT) + " " + format("SVM", OPERATOR_FORMAT));	to.add(to2,1,1);	to.addVector(16,4,10,format("Example Set", IO_FORMAT));	to.addVector(16,2,10,format("Model", IO_FORMAT));	System.out.println(to);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -