package com.crocro.wrp.wrpPc;
import com.crocro.wrp.app.AppLoop;
import com.crocro.wrp.mng.MngLayout;
import com.crocro.wrp.utl.UtlCmnPc;
import com.crocro.wrp.utl.UtlDw;
import com.crocro.wrp.utl.UtlDw.StringPrm;
import com.crocro.wrp.utl.UtlTool;
import com.crocro.wrp.wrp.WrpDw;
import com.crocro.wrp.wrp.WrpDw.StrFntOpt;
import com.crocro.wrp.wrp.WrpDw.StrFrmOpt;
import com.crocro.wrp.wrp.WrpFile;
import java.awt.AlphaComposite;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Insets;
import java.awt.MediaTracker;
import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.awt.image.MemoryImageSource;
import java.awt.image.PixelGrabber;
import java.io.InputStream;
import java.util.ArrayList;
import javax.imageio.ImageIO;
public class WrpDwPc extends WrpDw {
private AppLoop mAL = null;
private static final String PTH_IMG = "res/img/";
public ArrayList<Image> mBufArrLst = new ArrayList();
public ArrayList<Graphics2D> mGrpArrLst = new ArrayList();
private static ArrayList<Color> mColArrLst = new ArrayList();
private Graphics2D mG = null;
private Graphics2D mGNow = null;
private Component mPrnt = null;
private Insets mInsts = null;
private WrpFile mWF = null;
private double mRttRad = 0.0D;
private double mRttX = 0.0D;
private double mRttY = 0.0D;
private boolean mUseCntr = false;
private static final AffineTransform DEF_AT = new AffineTransform();
private static final BasicStroke[] STRKS = { new BasicStroke(0.0F),
new BasicStroke(1.0F), new BasicStroke(2.0F),
new BasicStroke(3.0F), new BasicStroke(4.0F),
new BasicStroke(5.0F), new BasicStroke(6.0F),
new BasicStroke(7.0F), new BasicStroke(8.0F) };
private Font mFntDflt = null;
private Font mFntSml = null;
private Font mFntXSml = null;
private static double mAscntRate = 1.0D;
private static double mDscntRate = 1.0D;
public WrpDwPc(Component cmpnnt, Insets insts) {
this.mPrnt = cmpnnt;
this.mInsts = insts;
if (mColArrLst.size() == 0) {
for (int i = 0; i < COL_USER; i++) {
int[] c = COL_ARR[i];
mColArrLst.add(i, new Color(c[0], c[1], c[2]));
}
}
int tstW = 60;
int tstH = 120;
int tstSz = 30;
BufferedImage img = new BufferedImage(tstW, tstH, 1);
Graphics2D g2d = (Graphics2D) img.getGraphics();
Font fnt = new Font("Monospaced", 1, tstSz);
g2d.setFont(fnt);
FontMetrics fm = g2d.getFontMetrics(fnt);
int ascnt = fm.getAscent();
int dscnt = fm.getDescent();
g2d.setColor(new Color(0, 0, 0));
g2d.fillRect(0, 0, tstW, tstH);
g2d.setColor(new Color(255, 255, 255));
g2d.drawString("Bg", 0, ascnt);
int frstFntY = -1;
int lstFntY = -1;
for (int y = 0; y < tstH; y++) {
for (int x = 0; x < tstW; x++) {
int c = img.getRGB(x, y) & 0xFFFFFF;
if (c != 0) {
if (frstFntY == -1)
frstFntY = y;
lstFntY = y;
}
}
}
mAscntRate = (ascnt - frstFntY) * 1.0D / ascnt;
mDscntRate = (lstFntY - ascnt) * 1.0D / dscnt;
g2d.dispose();
g2d = null;
img = null;
}
public void setAppLoop(AppLoop al) {
this.mAL = al;
this.mWF = this.mAL.mWF;
}
public void initBufSz(int w, int h) {
mkBuf(0, w, h);
}
public WrpDw getNew() {
WrpDw wd = new WrpDwPc(this.mPrnt, this.mInsts);
wd.setAppLoop(this.mAL);
return wd;
}
public void setGrphcs(Graphics g) {
this.mG = ((Graphics2D) g);
tgtBuf(0);
}
public void mkBuf(int id, int w, int h) {
if (id < 0)
return;
if (id >= this.mBufArrLst.size()) {
for (int i = this.mBufArrLst.size(); i <= id; i++)
this.mBufArrLst.add(i, null);
}
BufferedImage img = new BufferedImage(w, h, 2);
this.mBufArrLst.set(id, img);
Graphics2D g2d = (Graphics2D) ((Image) this.mBufArrLst.get(id))
.getGraphics();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
if (id >= this.mGrpArrLst.size()) {
for (int i = this.mGrpArrLst.size(); i <= id; i++)
this.mGrpArrLst.add(i, null);
}
this.mGrpArrLst.set(id, g2d);
}
public void mkBuf(int id, String fNm) {
if ((fNm == null) || (fNm.length() == 0))
return;
if (id < 0)
return;
Image img = ldImg(fNm);
if (img == null) {
img = ldMskImg(fNm);
}
if (img == null) {
img = new BufferedImage(1, 1, 2);
}
if (id >= this.mBufArrLst.size()) {
for (int i = this.mBufArrLst.size(); i <= id; i++)
this.mBufArrLst.add(i, null);
}
this.mBufArrLst.set(id, img);
if (id >= this.mGrpArrLst.size()) {
for (int i = this.mGrpArrLst.size(); i <= id; i++)
this.mGrpArrLst.add(i, null);
}
this.mGrpArrLst.set(id,
(Graphics2D) ((Image) this.mBufArrLst.get(id)).getGraphics());
}
private Image ldImg(String fNm) {
Image img = null;
try {
String pth = "res/img/" + fNm;
InputStream is = null;
try {
is = this.mWF.getRIS(pth);
img = ImageIO.read(is);
} catch (Exception ex) {
if (is != null)
try {
is.close();
is = null;
} catch (Exception localException2) {
}
} finally {
if (is != null)
try {
is.close();
is = null;
} catch (Exception localException3) {
}
}
MediaTracker tracker = new MediaTracker(this.mPrnt);
tracker.addImage(img, 0);
tracker.waitForAll();
} catch (Exception e) {
UtlCmnPc.prntExcp(e, "ldImg img : " + fNm);
}
return img;
}
private Image ldMskImg(String fNm) {
Image img = null;
if (fNm.endsWith(".png")) {
String fNmBs = UtlTool.replOne(fNm, ".png", "");
Image imgBs = ldImg(fNmBs + ".gif");
if (imgBs == null)
return img;
int w = imgBs.getWidth(null);
int h = imgBs.getHeight(null);
int[] pxlsBs = new int[w * h];
PixelGrabber pgBs = new PixelGrabber(imgBs, 0, 0, w, h, pxlsBs, 0,
w);
try {
pgBs.grabPixels();
} catch (Exception ex) {
}
if ((pgBs.getStatus() & 0x80) != 0)
return img;
imgBs.flush();
imgBs = null;
Image imgMsk = ldImg(fNmBs + "_msk.gif");
if (imgMsk == null)
return img;
if ((w == imgMsk.getWidth(null)) && (h == imgMsk.getHeight(null))) {
int[] pxlsMsk = new int[w * h];
PixelGrabber pgMsk = new PixelGrabber(imgMsk, 0, 0, w, h,
pxlsMsk, 0, w);
try {
pgMsk.grabPixels();
} catch (Exception ex) {
}
if ((pgMsk.getStatus() & 0x80) != 0)
return img;
imgMsk.flush();
imgMsk = null;
int sz = w * h;
for (int i = 0; i < sz; i++) {
pxlsBs[i] = (pxlsBs[i] & 0xFFFFFF | (pxlsMsk[i] & 0xFF) << 24);
}
Image imgMem = this.mPrnt.createImage(new MemoryImageSource(w,
h, pxlsBs, 0, w));
img = new BufferedImage(w, h, 2);
Graphics g = img.getGraphics();
g.drawImage(imgMem, 0, 0, null);
g.dispose();
imgMem.flush();
imgMem = null;
}
}
return img;
}
public void tgtBuf(int id) {
if (id == -1)
this.mGNow = this.mG;
else
try {
this.mGNow = ((Graphics2D) this.mGrpArrLst.get(id));
if (this.mGNow == null)
this.mGNow = this.mG;
} catch (Exception e) {
this.mGNow = this.mG;
}
}
public void delBuf(int id) {
if (id >= this.mBufArrLst.size())
return;
this.mBufArrLst.set(id, null);
if (this.mGrpArrLst.get(id) != null)
((Graphics2D) this.mGrpArrLst.get(id)).dispose();
this.mGrpArrLst.set(id, null);
}
public void flshBuf(int id) {
if (id < 0)
return;
for (int i = id; i < this.mBufArrLst.size(); i++)
delBuf(i);
}
public void prcBuf(int id, int prcTyp) {
if ((id < 0) || (id >= this.mBufArrLst.size()))
return;
没有合适的资源?快使用搜索试试~ 我知道了~
Java小游戏之SRPGWar
共376个文件
class:245个
java:91个
png:15个
需积分: 0 0 下载量 170 浏览量
2024-03-20
13:02:39
上传
评论 2
收藏 3.82MB RAR 举报
温馨提示
Java小游戏之SRPGWar
资源推荐
资源详情
资源评论
收起资源包目录
Java小游戏之SRPGWar (376个子文件)
WrpDwPc.class 22KB
ScnGm.class 16KB
GmToolScr.class 15KB
GmToolMap.class 12KB
UtlTool.class 12KB
DrwScrpt.class 12KB
GmToolSkl.class 10KB
LghtBox.class 10KB
GmDtUnt.class 10KB
MnRcrd.class 10KB
AppLoop.class 10KB
GmUnt.class 9KB
GmEfWpn.class 9KB
ScnTtlGm.class 9KB
F.class 9KB
Frm.class 9KB
UtlDw.class 8KB
ScnBfrGm.class 8KB
MnUntInf.class 7KB
MngDlg.class 7KB
ScnSelStg.class 7KB
Scn.class 7KB
WrpFilePc.class 7KB
MnSelUnt.class 7KB
MnOpt.class 6KB
V.class 6KB
GmTmr.class 6KB
DwTbl.class 6KB
MnDfclt.class 6KB
GmMapSelUnt.class 6KB
UtlJson.class 6KB
GmDtMap.class 6KB
MngOpt.class 6KB
GmMapAll.class 6KB
WrpSndPc$SndVrtl.class 6KB
GmRng.class 5KB
WrpSndPc.class 5KB
GmUntDst.class 5KB
Clckbl.class 5KB
MngCnvs.class 5KB
WrpDw.class 5KB
WrpNetPc.class 4KB
GmDt.class 4KB
GmEfDth.class 4KB
UtlDwEf.class 4KB
GmLog.class 4KB
StrBtn.class 4KB
MnDfclt$5.class 4KB
WrpEnvPc.class 4KB
GmImgWpn.class 4KB
MnSndVol.class 4KB
DlgMnSldBar.class 3KB
V.class 3KB
AnmTtl.class 3KB
GmDtUntF.class 3KB
MngSnd.class 3KB
AppLoopSimWar.class 3KB
MngLayout.class 3KB
UtlSort.class 3KB
ScnStgStrt.class 3KB
MnVwMes.class 3KB
GmMap.class 3KB
UtlCmnPc.class 3KB
GmToolScr$1.class 3KB
ScnTtl.class 3KB
ScnTtlGm$4.class 3KB
DlgMnItm.class 3KB
DlgMnItmImg.class 2KB
LghtBoxScrpt.class 2KB
MnRcrd$3$1.class 2KB
UtlMsk.class 2KB
WrpSndPc$1.class 2KB
Tab.class 2KB
MngScn.class 2KB
MnRcrd$1.class 2KB
ScnStgClr.class 2KB
DlgTtl.class 2KB
MnUntInf$2.class 2KB
MnDfclt$2.class 2KB
WrpEnvPc$1.class 2KB
ScnTtlGm$2$1.class 2KB
ScnTtlGm$InfBtn.class 2KB
GmToolScr$4.class 2KB
Btn.class 2KB
Frm$2.class 2KB
MnUntInf$3$1.class 2KB
Drg.class 2KB
ScnWinGm.class 2KB
WrpEnvPc$2.class 2KB
UtlMsk$MskOutputStream.class 2KB
ScnGm$2.class 2KB
ScnSelStg$1$1.class 2KB
MnSelUnt$2.class 2KB
MnSndVol$3.class 2KB
ScnSelStg$2$1.class 2KB
MnVwMes$2.class 2KB
MnDfclt$4.class 2KB
MnOpt$2.class 2KB
MnRcrd$3$1$2.class 2KB
GmToolScr$7.class 1KB
共 376 条
- 1
- 2
- 3
- 4
资源评论
清风絮柳
- 粉丝: 1543
- 资源: 25
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功