您的位置:首页 > 其它

Cover It Up - For TV Lovers

2015-07-23 22:38 183 查看

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);
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: