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

📄 graphicscmd.java

📁 Hecl编程语言是一个高层次的脚本语言的Java实现。其用意是要小
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		d.drawLine(v0,HeclUtils.getPoint(v1,argv,startat));		v0.setLocation(v1.getX(),v1.getY());	    }	    return null;	}		if(subcmd.equals("polygon")) {	    if(startat+3 > argv.length)		throw HeclException.createWrongNumArgsException(		    argv, startat, "p0 p1 p2 [...]");	    Point2D[] p = getPoints(argv,startat);	    d.drawPolygon(p.length,p,false);	    return null;	}		if(subcmd.equals("fpolygon")) {	    if(startat+3 > argv.length)		throw HeclException.createWrongNumArgsException(		    argv, startat, "p0 p1 p2 [...]");	    Point2D[] p = getPoints(argv,startat);	    d.drawPolygon(p.length,p,true);	    return null;	}	if(subcmd.equals("rect")) {	    // point dimension	    if(startat+2 != argv.length)		throw HeclException.createWrongNumArgsException(		    argv, startat, "point dimension");	    d.drawRect(HeclUtils.thing2Point(argv,startat),		       HeclUtils.thing2Dimension(argv,startat+1),		       false);	    return null;	}	if(subcmd.equals("string")) {	    if(startat+2 > argv.length)		throw HeclException.createWrongNumArgsException(		    argv, startat, "point text [anchor]");	    int anchor = startat+2 < argv.length ?		WidgetInfo.toCanvasAnchor(argv[startat+2]) : Graphics.BOTTOM|Graphics.LEFT;	    	    d.drawString(argv[startat+1].toString(),			 HeclUtils.thing2Point(argv,startat), anchor);	    return null;	}	if(subcmd.equals("htext")) {	    if(startat+2 > argv.length)		throw HeclException.createWrongNumArgsException(		    argv, startat, "point text [anchor]");	    int anchor = startat+2 < argv.length ?		WidgetInfo.toCanvasAnchor(argv[startat+2]) : Graphics.BOTTOM|Graphics.LEFT;	    	    d.drawVString(argv[startat+1].toString(),			  HeclUtils.thing2Point(argv,startat));	    return null;	}	if(subcmd.equals("rrect")) {	    /* p dim arcw arch */	    if(startat+4 != argv.length)		throw HeclException.createWrongNumArgsException(		    argv, startat, "point dimension arcw arch");	    d.drawRoundRect(HeclUtils.thing2Point(argv,startat),			    HeclUtils.thing2Dimension(argv,startat+1),			    IntThing.get(argv[startat+2]),			    IntThing.get(argv[startat+3]));	    return null;	}	if(subcmd.equals("farc")) {	    /* x, y, w, h, arcw, argh */	    if(startat+4 != argv.length)		throw HeclException.createWrongNumArgsException(		    argv, startat, "point dimension arcw arch");	    d.drawArc(HeclUtils.thing2Point(argv,startat),		      HeclUtils.thing2Dimension(argv,startat+1),		      IntThing.get(argv[startat+2]),		      IntThing.get(argv[startat+3]),		      true);	    return null;	}	if(subcmd.equals("frect")) {	    // point dim	    if(startat+2 != argv.length)		throw HeclException.createWrongNumArgsException(		    argv, startat, "point dimension");	    d.drawRect(HeclUtils.thing2Point(argv,startat),		       HeclUtils.thing2Dimension(argv,startat+1),		       true);	    return null;	}	if(subcmd.equals("frrect")) {	    // point dim 	    if(startat+4 != argv.length)		throw HeclException.createWrongNumArgsException(		    argv, startat, "point dimension arcw arch");	    d.fillRoundRect(HeclUtils.thing2Point(argv,startat),			    HeclUtils.thing2Dimension(argv,startat+1),			    IntThing.get(argv[startat+2]),			    IntThing.get(argv[startat+3]));	    return null;	}	// Get commands...	if(subcmd.startsWith("get")) {	    /* no arguments */	    if(startat != argv.length)		throw HeclException.createWrongNumArgsException(		    argv, startat, "");//#ifdef notdef	    if(subcmd.equals("getblue")) {		//ip.setResult(d.getBlueComponent());		return null;	    }	    if(subcmd.equals("getgreen")) {		//ip.setResult(d.getGreenComponent());		return null;	    }	    if(subcmd.equals("getred")) {		//ip.setResult(d.getRedComponent());		return null;	    }//#endif	    if(subcmd.equals("getfont"))		return FontMap.fontThing(d.getFont());	    if(subcmd.equals("getgrayscale"))		return IntThing.create(d.getGrayScale());	    if(subcmd.equals("getlinetype"))		IntThing.create((int)d.getLineType());	    if(subcmd.equals("getcolor"))		return WidgetInfo.fromColor(d.getColor());	    if(subcmd.equals("getbackground"))		return WidgetInfo.fromColor(d.getBackground());	}//#ifdef notdef		if(subcmd.equals("displaycolor")) {	    n += 1;	    if(startat+1 != argv.length)		throw HeclException.createWrongNumArgsException(		    argv, startat, "<colorspec>");	    Color c = new Color(WidgetInfo.toColor(argv[startat]));	    return WidgetInfo.fromColor(d.getDisplayColor(c));	}//#endif	// Set commands	if(subcmd.equals("background")) {	    /* colorspec */	    if(startat+1 != argv.length)		throw HeclException.createWrongNumArgsException(		    argv, startat, "<colorspec>");	    d.setBackground(new Color(WidgetInfo.toColor(argv[startat])));	    return null;	}	if(subcmd.equals("color")) {	    /* colorspec */	    if(startat+1 != argv.length)		throw HeclException.createWrongNumArgsException(		    argv, startat, "<colorspec>");	    d.setColor(new Color(WidgetInfo.toColor(argv[startat])));	    return null;	}	if(subcmd.equals("font")) {	    /* font */	    if(startat+1 != argv.length)		throw HeclException.createWrongNumArgsException(		    argv, startat, "<font>");	    d.setFont(FontMap.get(argv[startat]));	    return null;	}	if(subcmd.equals("grayscale")) {	    /* colorspec */	    if(startat+1 != argv.length)		throw HeclException.createWrongNumArgsException(		    argv, startat, "<greyspec>");	    d.setGrayScale(IntThing.get(argv[startat]));	    return null;	}	if(subcmd.equals("linetype")) {	    /* linetype */	    if(startat+1 != argv.length)		throw HeclException.createWrongNumArgsException(		    argv, startat, "<linetype>");	    d.setLineStipple((short)HeclUtils.thing2int(argv[startat],false,0));	    return null;	}	// Misc commands	if(subcmd.equals("clip")) {	    // {x, y} {w, h}	    if(startat+2 != argv.length)		throw HeclException.createWrongNumArgsException(		    argv, startat, "point dimension");	    Point2D p = HeclUtils.thing2Point(argv,startat);	    Dimension dim = HeclUtils.thing2Dimension(argv,startat+1);	    d.setClip((int)Math.floor(.5+p.getX()),(int)Math.floor(.5+p.getY()),		      dim.width,dim.height);	    return null;	}	if(subcmd.equals("cliprect")) {	    /* {x, y} {w, h} */	    if(startat+2 != argv.length)		throw HeclException.createWrongNumArgsException(		    argv, startat, "x y w h");	    Point2D p = HeclUtils.thing2Point(argv,startat);	    Dimension dim = HeclUtils.thing2Dimension(argv,startat+1);	    d.clipRect((int)Math.floor(.5+p.getX()),(int)Math.floor(.5+p.getY()),		       dim.width,dim.height);	    return null;	}//#ifdef notdef	if(subcmd.equals("translate")) {	    // point	    if(startat+1 != argv.length)		throw HeclException.createWrongNumArgsException(		    argv, startat, "point");	    d.translate(HeclUtils.thing2Point(argv,startat));	    return null;	}//#endif	return super.handlecmd(ip,d,subcmd,argv,startat);    }    private Point2D[] getPoints(Thing[] argv,int startat)	throws HeclException {	int n = (argv.length - startat);	Point2D[] points = new Point2D[n];	for(int i=0; startat<argv.length; ++startat, ++i) {	    points[i] = HeclUtils.thing2Point(argv,startat);	    //System.out.println("point["+i+"]="+points[i].getX()+", "+points[i].getY());	}	return points;    }        protected boolean needflush = true;//#ifdef notdef    private int mytx = 0;    private int myty = 0;//#endif    private Drawable drawable;    private static GraphicsCmd cmd = new GraphicsCmd();}class Context {    protected Context(Drawable d) {	cliprect = new Rectangle();	Graphics g = d.getGraphics();		fcol = d.getColor();	bcol = d.getBackground();	gray = d.getGrayScale();	font = d.getFont();	linestipple = d.getLineStipple();	linewidth = d.getLineWidth();	d.getClipBounds(cliprect);//#ifdef notdef	mytx = d.getTranslateX();	myty = d.getTranslateY();//#endif    }            protected void restore(Drawable d) {	Graphics g = d.getGraphics();		d.setColor(fcol);	d.setBackground(bcol);	d.setGrayScale(gray);	d.setLineStipple(linestipple);	d.setLineWidth(linewidth);	d.setClip(cliprect);	d.setFont(font);//#ifdef notdef	d.translate(mytx,myty);//#endif    }        private Color fcol;    private Color bcol;    private int gray;    private Font font;    private short linestipple;    private int linewidth;    private Rectangle cliprect;//#ifdef notdef    private double mytx;    private double myty;//#endif}// Variables:// mode:java// coding:utf-8// End:

⌨️ 快捷键说明

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