该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
mk文件
Main-Class: MainTest
Version: 0.1
Public-Data: Dec. 8,2015
Author: Fulton Shaw
Copyright: GPL
readme文件
API
==
public interface Console {
public void setConsoleCursorPosition(int x,int y);
public void setConsoleCursorOffset(int offx,int offy);
public Pair getConsoleCursorPosition();
public String getConsoleType();
public void resizeConsoleWindowSize(int size_x,int size_y);
public Pair getConsoleWindowSize();
public void hideConsoleCursor();
public void showConsoleCursor();
public void clearConsoleWindows();
}
以及
public class ConsoleWIndows implements Console;
文档结构
==
根目录
META-INF
MANIFEST.MF 清单文件
makefest.mk 自配置文件,版本信息,作者,授权等
fulton java包,package
util 次级包
Console.class Console接口
ConsoleWindows.class Console接口在Windows环境下的实现
Pair.class Pair对象
Util.class 使用工具包,封装了sleep,System.out.println等函数
src 源码文件,包括cpp和java
cpp cpp源文件,用于生成ConsoleWindows.dll动态库文件
ConsoleWindows.cpp
ConsoleWindows.h
fulton 对应的源代码包
util
Console.java 对应的源代码
ConsoleWindows.java
Pair.java
Util.java
ConsoleWindows.dll Windows环境下的本地c函数,用于调用设置光标位置
MainTest.class 主测试函数入口
readme.txt 帮助文档
源代码分析
==
接口:fulton.util.Console
作用:为windows和linux环境的光标移动提供统一的函数接口
package fulton.util;
import fulton.util.Pair;
/**
* Created by Fulton's PC on 2015/12/7.
*/
public interface Console {
public void setConsoleCursorPosition(int x,int y);
public void setConsoleCursorOffset(int offx,int offy);
public Pair getConsoleCursorPosition();
public String getConsoleType();
public void resizeConsoleWindowSize(int size_x,int size_y);
public Pair getConsoleWindowSize();
public void hideConsoleCursor();
public void showConsoleCursor();
public void clearConsoleWindows();
}
实现类:ConsoleWindows
作用:Console接口在Windows下的实现
package fulton.util;
import fulton.util.Console;
/**
* Created by Fulton's PC on 2015/12/7.
*/
public class ConsoleWindows implements Console {
static{
//载入动态库ConsoleWindows.dll
System.loadLibrary("ConsoleWindows");
}
public ConsoleWindows()
{
initUse();
}
protected void finalize()
{
finishUse();
}
//调用初始化
public native void initUse();
//调用结束
public native void finishUse();
@Override
public native void setConsoleCursorPosition(int x, int y) ;
@Override
public native void setConsoleCursorOffset(int offx, int offy) ;
@Override
public native Pair getConsoleCursorPosition();
@Override
public String getConsoleType() {
return "Windows";
}
@Override
public native void resizeConsoleWindowSize(int size_x, int size_y);
@Override
public native Pair getConsoleWindowSize() ;
@Override
public native void hideConsoleCursor();
@Override
public native void showConsoleCursor() ;
@Override
public native void clearConsoleWindows();
}
拓展分析
==
文件:cpp/ConsoleWindows.h
来源:由javah程序依据ConsoleWindows中的native声明生成
实现:cpp/ConsoleWindows.app
#pragma once
/* DO NOT EDIT THIS FILE - it is machine generated */
#include
/* Header for class fulton_util_ConsoleWindows */
#ifndef _Included_fulton_util_ConsoleWindows
#define _Included_fulton_util_ConsoleWindows
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: fulton_util_ConsoleWindows
* Method: initUse
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_fulton_util_ConsoleWindows_initUse
(JNIEnv *, jobject);
/*
* Class: fulton_util_ConsoleWindows
* Method: finishUse
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_fulton_util_ConsoleWindows_finishUse
(JNIEnv *, jobject);
/*
* Class: fulton_util_ConsoleWindows
* Method: setConsoleCursorPosition
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_fulton_util_ConsoleWindows_setConsoleCursorPosition
(JNIEnv *, jobject, jint, jint);
/*
* Class: fulton_util_ConsoleWindows
* Method: setConsoleCursorOffset
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_fulton_util_ConsoleWindows_setConsoleCursorOffset
(JNIEnv *, jobject, jint, jint);
/*
* Class: fulton_util_ConsoleWindows
* Method: getConsoleCursorPosition
* Signature: ()Lfulton/util/Pair;
*/
JNIEXPORT jobject JNICALL Java_fulton_util_ConsoleWindows_getConsoleCursorPosition
(JNIEnv *, jobject);
/*
* Class: fulton_util_ConsoleWindows
* Method: resizeConsoleWindowSize
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_fulton_util_ConsoleWindows_resizeConsoleWindowSize
(JNIEnv *, jobject, jint, jint);
/*
* Class: fulton_util_ConsoleWindows
* Method: getConsoleWindowSize
* Signature: ()Lfulton/util/Pair;
*/
JNIEXPORT jobject JNICALL Java_fulton_util_ConsoleWindows_getConsoleWindowSize
(JNIEnv *, jobject);
/*
* Class: fulton_util_ConsoleWindows
* Method: hideConsoleCursor
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_fulton_util_ConsoleWindows_hideConsoleCursor
(JNIEnv *, jobject);
/*
* Class: fulton_util_ConsoleWindows
* Method: showConsoleCursor
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_fulton_util_ConsoleWindows_showConsoleCursor
(JNIEnv *, jobject);
/*
* Class: fulton_util_ConsoleWindows
* Method: clearConsoleWindows
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_fulton_util_ConsoleWindows_clearConsoleWindows
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif