pen.js
来自「JSVM核心类库,收集了JAVA进行JSVM开发必用技术进行归纳,在实际项目应用」· JavaScript 代码 · 共 99 行
JS
99 行
// Description: js.graphics.Pen 类;画笔(封装VML)
// Author: Changhua.Wan
// Version: 2004.02.02.09
_package("js.graphics");
_import("js.lang.Object");
_import("js.graphics.Point");
function js.graphics.Pen() {
this.color = "#000000";
this.lineWidth = 1;
this.lineStyle = null; //枚举型 {"Single","ThinThin","ThinThick","ThickBetweenThin"}
this.dashStyle = null; //枚举型 {"Solid","ShortDash","ShortDot","ShortDashDot","ShortDashDotDot","Dot","Dash","LongDash","DashDot","LongDashDot","LongDashDotDot"}
this.endArrow = null; //枚举型 {Block","Classic","Diamond","Oval","Open"}
this.startArrow = null;
this.fontSize = 9;
}
var _p = js.graphics.Pen._extends("js.lang.Object");
_p.createLine = function() {
var line = document.createElement('v:line');
line.strokeweight = this.lineWidth + "px";
line.strokecolor = this.color;
var stroke = document.createElement('v:stroke');
if (this.lineStyle != null) stroke.linestyle = this.lineStyle;
if (this.dashStyle != null) stroke.dashstyle = this.dashStyle;
if (this.startArrow != null) stroke.startarrow = this.startArrow;
if (this.endArrow != null) stroke.endarrow = this.endArrow;
line.appendChild(stroke);
return line;
};
_p.createPolyLine = function() {
var line = document.createElement('v:polyline');
line.strokeweight = this.lineWidth + "px";
line.strokecolor = this.color;
var stroke = document.createElement('v:stroke');
if (this.lineStyle != null) stroke.linestyle = this.lineStyle;
if (this.dashStyle != null) stroke.dashstyle = this.dashStyle;
if (this.startArrow != null) stroke.startarrow = this.startArrow;
if (this.endArrow != null) stroke.endarrow = this.endArrow;
line.appendChild(stroke);
return line;
};
_p.createRect = function(_w, _h) {
var rect = document.createElement('v:rect');
rect.strokecolor = this.color;
rect.style.width = _w;
rect.style.height = _h;
return rect;
};
_p.createRoundRect = function(_w, _h) {
var rect = document.createElement('v:roundrect');
rect.strokecolor = this.color;
rect.strokeweight = this.lineWidth + "px";
rect.style.width = _w;
rect.style.height = _h;
return rect;
};
_p.createOval = function(_w, _h) {
var oval = document.createElement('v:oval');
oval.style.width = _w;
oval.style.height = _h;
oval.strokecolor = this.color;
oval.strokeweight = this.lineWidth + "px";
return oval;
};
_p.createCurve = function(_points) {
var curve = document.createElement('v:curve');
curve.from = _points[0].toString();
curve.to = _points[_points.length - 1].toString();
for (var i = 1; i < _points.length - 1; i++)
curve.setAttribute("control" + i, _points[i].toString());
curve.strokecolor = this.color;
curve.strokeweight = this.lineWidth + "px";
return curve;
};
_p.createArc = function(_width, _height, _startangle, _endangle) {
var arc = document.createElement('v:arc');
arc.style.width = _width;
arc.style.height = _height;
arc.startangle = _startangle;
arc.endangle = _endangle;
arc.strokecolor = this.color;
arc.strokeweight = this.lineWidth + "px";
return arc;
};
_p.createShape = function(_width, _height, _path) {
var shape = document.createElement('v:shape');
shape.style.width = _width;
shape.style.height = _height;
shape.strokeweight = this.lineWidth + "px";
shape.strokecolor = this.color;
shape.path = _path;
return shape;
};
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?