Cover It Up - For TV Lovers

Wanna See Some TV Serials - Use It

Wanna See Some TV Serials
-->> Then Use It For Better Experience

It will help you cover the Chinese subtitles by black block.
And you can easily move it upwards, or edit the alpha, or resize it.

import java.awt.Color;
import java.awt.Rectangle;
import java.io.InputStream;

import javax.swing.JFrame;
import javax.swing.JPanel;

import com.sun.awt.AWTUtilities;

public class Vampire {
	private SurfaceFrame frame;
	private InputStream in = null;
		private int iScale = 4;//at px;
		private int iScaleB = 4;//at px;
		private float fScale = 0.02f;//at px;

	public static void main(String[] s) {
		Vampire context = new Vampire();
		context.alert("Input '?' for help!");
		if(s.length > 0){
			context.fHelp();
		}
		context.fMain();
	}

	private void fMain() {
		frame = new SurfaceFrame();
		frame.fInit();

		fListen();
	}

	private void fListen() {
		try {
			in = System.in;

			int get = -1;
			while ((get = in.read()) != -1) {
				if ('a' <= get && get <= 'z') {
					get -= 32;
				} else if ('A' <= get && get <= 'Z') {

				} else if (get == '<' || get == '>') {

				} else if (get=='?') {

				} else
					continue;

				fExcel(get);
			}
		} catch (Exception e) {
			alert("Error when reading char: " + e.toString());
		} finally {
			if (in != null) {
				try {
					in.close();
				} catch (Exception e) {
					alert("Error when closing System.in: " + e.toString());
				}
			}
		}
	}

	private void fExcel(int get) throws Exception {
		switch (get) {
		case '?':
			fHelp();
			break;
		case 'Q':
		case 'q':
			in.close();
			alert("Listening has shut up");
			return;
		case 'W':
			frame.fUp();
			break;
		case 'S':
			frame.fDown();
			break;
		case 'A':
			frame.fLeft();
			break;
		case 'D':
			frame.fRight();
			break;
		case 'I':
			frame.fHeighten();
			break;
		case 'K':
			frame.fShorten();
			break;
		case 'J':
			frame.fWiden();
			break;
		case 'L':
			frame.fNarrow();
			break;
		case '<':
			frame.fIn();
			break;
		case '>':
			frame.fOut();
			break;
		default:
			alert("Unknown Order!");
			break;
		}
	}
	private void fHelp(){
			alert("Wanna Up, Down, Left, Right, please use -->> W S A D;");
			alert("Wanna Highten, Shorten, Widen, Narrow, please use -->> I K J L;");
			alert("Wanna Shadow, Brighten, please use -->> < >;");
			alert("Wanna See The Parameter, please input -->> E");
			alert("Tip: All letters will be ignored cases;");
			alert("");
	}

	@SuppressWarnings("serial")
	private class SurfaceFrame extends JFrame {

		private JFrame frame;
		private Rectangle rect;
		private float fAlpha = 0.95f;
		
		public SurfaceFrame() {

		}

		public void fInit() {
			rect = new Rectangle(130, 666, 1000, 52);

			frame = new JFrame();
			frame.setLayout(null);
			frame.setBounds(rect);// Vampire
			frame.setUndecorated(true);

			JPanel panel = new JPanel();
			panel.setBounds(0, 0, 1390, 1000);
			panel.setBackground(Color.black);
			frame.add(panel);

			AWTUtilities.setWindowOpacity(frame, fAlpha);
			frame.setAlwaysOnTop(true);
			frame.setVisible(true);
		}

		public void fUp() {
			rect.y -= iScale;
			frame.setBounds(rect);
		}

		public void fDown() {
			rect.y += iScale;
			frame.setBounds(rect);
		}

		public void fLeft() {
			rect.x -= iScale;
			frame.setBounds(rect);
		}

		public void fRight() {
			rect.x += iScale;
			frame.setBounds(rect);
		}

		public void fWiden() {
			rect.width += 2 * iScaleB;
			rect.x -= iScaleB;
			frame.setBounds(rect);
		}

		public void fNarrow() {
			rect.width -= 2 * iScaleB;
			rect.x += iScaleB;
			frame.setBounds(rect);
		}

		public void fHeighten() {
			rect.height += iScaleB;
			frame.setBounds(rect);
		}

		public void fShorten() {
			rect.height -= iScaleB;
			frame.setBounds(rect);
		}

		public void fIn() {
			fAlpha -= fScale;
			fAlpha = fAlpha < 0 ? 0f : fAlpha;
			AWTUtilities.setWindowOpacity(frame, fAlpha);
		}

		public void fOut() {
			fAlpha += fScale;
			fAlpha = fAlpha > 1 ? 1f : fAlpha;
			AWTUtilities.setWindowOpacity(frame, fAlpha);
		}
	}

	public static void alert(String s) {
		System.out.println(s);
	}

}




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值