📄 jmgraphics.java
字号:
package jm.framework.gui.module;
import java.awt.BasicStroke;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.geom.Line2D;
public abstract class JMGraphics extends Graphics
{
public static final String CLASS_NAME = "JMGraphics" ;
public final static int REL_LINE1 = 1;
public final static int REL_LINE2 = 2;
public final static int REL_LINE3 = 3;
public final static int REL_LINE4 = 4;
//private Color BkColor ;
//private Font BkFont;
private Graphics pgraphics;
public JMGraphics() {
super();
}
public JMGraphics(Graphics agraphics) {
this();
this.pgraphics = agraphics;
}
/**
* drawRelLine
* 慄偺庬椶丄慄偺懢偝傪巜掕偟偰丄2揰娫傪寢傇捈慄傪昤夋偟傑偡丅
* @param aiType 慄庬傪巜掕偟傑偡丅慄庬偼埲壓偺僼傿乕儖僪掕悢傛傝巜掕偟傑偡丅
* 僼傿乕儖僪掕悢 慄庬僀儊乕僕
* @param aiThick 慄偺懢偝傪巜掕偟傑偡丅0埲忋傪巜掕偟傑偡丅
* @param aoP1 捈慄偺昤夋傪奐巒偡傞揰偺嵗昗傪昞偡Point僆僽僕僃僋僩傪巜掕偟傑偡丅
* @param aoP2 捈慄偺昤夋傪廔椆偡傞揰偺嵗昗傪昞偡Point僆僽僕僃僋僩傪巜掕偟傑偡丅
*/
public void drawRelLine(int aiType,int aiThick,Point aoP1,Point aoP2)
throws Exception
{
if ( aiThick < 0 )
{
throw new Exception("0埲忋傪巜掕偟傑偡");
}
//昞帵偡傞懢偝偺寁嶼
float pflineW = (float)( 2 * ( aiThick / 2 ) + 1 );
Graphics2D dw_Line = (Graphics2D)pgraphics;
//REL_LINE1
if ( aiType == REL_LINE1 )
{
float[] DW_REL_LINE2 = {5f,0f};
BasicStroke dashed = new BasicStroke(pflineW,
BasicStroke.CAP_BUTT,
BasicStroke.JOIN_MITER,
1.0f,
DW_REL_LINE2,
1.0f);
dw_Line.setStroke(dashed);
dw_Line.draw(new Line2D.Double(
aoP1.getX() , aoP1.getY(),
aoP2.getX() , aoP2.getY()
));
}
//REL_LINE2
if ( aiType == REL_LINE2 )
{
float[] DW_REL_LINE2 = {5f,5f};
BasicStroke dashed = new BasicStroke(pflineW,
BasicStroke.CAP_BUTT,
BasicStroke.JOIN_MITER,
1.0f,
DW_REL_LINE2,
1.0f);
dw_Line.setStroke(dashed);
dw_Line.draw(new Line2D.Double(
aoP1.getX() , aoP1.getY(),
aoP2.getX() , aoP2.getY()
));
}
//REL_LINE3
if ( aiType == REL_LINE3 )
{
float[] DW_REL_LINE3 = {10f,5f,5f,5f};
BasicStroke dashed = new BasicStroke(pflineW,
BasicStroke.CAP_BUTT,
BasicStroke.JOIN_MITER,
1.0f,
DW_REL_LINE3,
1.0f);
dw_Line.setStroke(dashed);
dw_Line.draw(new Line2D.Double(
aoP1.getX() , aoP1.getY(),
aoP2.getX() , aoP2.getY()
));
}
//REL_LINE4
if ( aiType == REL_LINE4 )
{
float[] DW_REL_LINE4 = {10f,3f,3f,3f,3f,3f};
BasicStroke dashed = new BasicStroke(pflineW,
BasicStroke.CAP_BUTT,
BasicStroke.JOIN_MITER,
1.0f,
DW_REL_LINE4,
1.0f);
dw_Line.setStroke(dashed);
dw_Line.draw(new Line2D.Double(
aoP1.getX() , aoP1.getY(),
aoP2.getX() , aoP2.getY()
));
}
}
/*
public Graphics create() {
JMGraphics prJMGraphics = new JMGraphics();
prJMGraphics.pgraphics = pgraphics.create();
return prJMGraphics;
}
public Graphics create(int x, int y, int width, int height) {
JMGraphics prJMGraphics;
prJMGraphics = new JMGraphics();
prJMGraphics.pgraphics = pgraphics.create(x, y, width, height);
return prJMGraphics;
}
public void translate(int x, int y) {}
public Color getColor() { return BkColor; }
public void setColor(Color c) { BkColor = c; }
public void setPaintMode() {}
public void setXORMode(Color c1) {}
public Font getFont() { return BkFont; }
public void setFont(Font font) { BkFont = font; }
public FontMetrics getFontMetrics(Font f) { return null; }
public Rectangle getClipBounds() { return null; }
public void clipRect(int x, int y, int width, int height) {}
public void setClip(int x, int y, int width, int height) {}
public Shape getClip() { return null; }
public void setClip(Shape clip) {}
public void copyArea(int x, int y, int width, int height,
int dx, int dy) {}
public void drawLine(int x1, int y1, int x2, int y2) {}
public void fillRect(int x, int y, int width, int height) {}
public void clearRect(int x, int y, int width, int height) {}
public void drawRoundRect(int x, int y, int width, int height,
int arcWidth, int arcHeight) {}
public void fillRoundRect(int x, int y, int width, int height,
int arcWidth, int arcHeight) {}
public void drawOval(int x, int y, int width, int height) {}
public void fillOval(int x, int y, int width, int height) {}
public void drawArc(int x, int y, int width, int height,
int startAngle, int arcAngle) {}
public void fillArc(int x, int y, int width, int height,
int startAngle, int arcAngle) {}
public void drawPolyline(int xPoints[], int yPoints[],
int nPoints) {}
public void drawPolygon(int xPoints[], int yPoints[],
int nPoints) {}
public void fillPolygon(int xPoints[], int yPoints[],
int nPoints) {}
public void drawString(String str, int x, int y) {}
public void drawString(AttributedCharacterIterator iterator,
int x, int y) {}
public boolean drawImage(Image img, int x, int y,
ImageObserver observer) { return true; }
public boolean drawImage(Image img, int x, int y,
int width, int height,
ImageObserver observer) { return true; }
public boolean drawImage(Image img, int x, int y,
Color bgcolor,
ImageObserver observer) { return true; }
public boolean drawImage(Image img, int x, int y,
int width, int height,
Color bgcolor,
ImageObserver observer) { return true; }
public boolean drawImage(Image img,
int dx1, int dy1, int dx2, int dy2,
int sx1, int sy1, int sx2, int sy2,
ImageObserver observer) { return true; }
public boolean drawImage(Image img,
int dx1, int dy1, int dx2, int dy2,
int sx1, int sy1, int sx2, int sy2,
Color bgcolor,
ImageObserver observer) { return true; }
public void dispose() {}
*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -