# JustWeTools
**Repository Path**: andych008/JustWeTools
## Basic Information
- **Project Name**: JustWeTools
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 1
- **Created**: 2021-12-22
- **Last Updated**: 2024-11-25
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# JustWeTools
**本项目是基于开源项目JustWeTools进行ohos化的移植和开发的,可以通过项目标签以及github地址( https://github.com/lfkdsk/JustWeTools )追踪到原项目版本**
## 项目介绍
- 项目名称:JustWeTools
- 所属系列:ohos的第三方组件适配移植
- 功能:JustWeTools是一个方便使用的工具集,集合了众多工具类和自定义组件。
- 项目移植状态:完成
- 调用差异:无
- 项目作者和维护人:hihope
- 联系方式:hihope@hoperun.com
- 原项目Doc地址:https://github.com/lfkdsk/JustWeTools
- 原项目基线版本:v1.0, sha1:76784019a41e200ce3f4493d10a1eb949d2692a7
- 编程语言:Java
- 外部库依赖:无
## 安装教程
##### 方法一:
1. 下载har包justwetools.har。
2. 启动 DevEco Studio,将下载的har/jar包,导入工程目录“entry->libs”下。
3. 在moudle级别下的build.gradle文件中添加依赖,在dependences标签中增加对libs目录下har/jar包的引用。
```
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
}
```
4. 在导入的har包上点击右键,选择“Add as Library”对包进行引用,选择需要引用的模块,并点击“OK”即引用成功。
##### 方法二:
1. 在工程的build.gradle的allprojects中,添加HAR所在的Maven仓地址:
```
repositories {
maven {
url 'http://106.15.92.248:8081/repository/Releases/'
}
}
```
2. 在应用模块的build.gradle的dependencies闭包中,添加如下代码:
```
dependencies {
implementation 'com.lfk.ohos:justwetools:1.0.1'
}
```
## 使用说明
### Component自定义组件:
#### PaintView画图工具:
* 可直接使用设定按钮来实现已拥有的方法,且拓展性强
* 基础功能:更换颜色、更换橡皮、以及更换橡皮和笔的粗细、清屏、倒入图片
* 特殊功能:保存画笔轨迹帧动画、帧动画导入导出、ReDo和UnDo
* 重构版本:提供笔刷类型基类DrawBase,可继承此类制作笔刷
##### 效果展示
- PaintView

- PaintNew

##### 使用基础功能只需要:
###### 1.1 添加xml:
```xml
```
##### 1.2 在ability里找到:
``` java
paintView = (PaintView) findComponentById(ResourceTable.Id_paint);
```
##### 若想使用帧动画相关功能:
需要新建数据集,设定纪录paintview,并且设定onPathListener()
``` java
pathNode = (PathNode) getAbilityPackage();
paintView.setIsRecordPath(true,pathNode);
paintView.setOnPathListener(new OnPathListener() {
@Override
public void AddNodeToPath(float x, float y, int event, boolean IsPaint) {
PathNode.Node tempnode = pathNode.new Node();
tempnode.x = x;
tempnode.y = y;
if (IsPaint) {
tempnode.PenColor = UserInfo.PaintColor;
tempnode.PenWidth = UserInfo.PaintWidth;
} else {
tempnode.EraserWidth = UserInfo.EraserWidth;
}
tempnode.IsPaint = IsPaint;
Log.e(tempnode.PenColor + ":" + tempnode.PenWidth + ":" + tempnode.EraserWidth, tempnode.IsPaint + "");
tempnode.TouchEvent = event;
tempnode.time = System.currentTimeMillis();
pathNode.AddNode(tempnode);
}
});
```
***
##### CodeView代码查看/修改工具:
* 基于WebView制作的代码编辑器
* 实现代码高亮,暗色主题
* 代码及时修改
##### 效果展示

##### 使用基础功能只需要:
###### 2.1 添加xml:
``` xml
```
###### 2.2 在Ability中获取路径:
``` java
codeView = (CodeView)findComponentById(ResourceTable.Id_mcodeview);
File dir = null;
Uri fileUri = getIntent().getUri();
if (fileUri != null) {
dir = new File(fileUri.getDecodedPath());
}
if (dir != null) {
codeView.setDirSource(dir);
((Text)findComponentById(ResourceTable.Id_sub_title)).setText(dir.getName());
}
else
terminateAbility();
```
如果是手动复制代码的话,需要复制rawfile文件夹下的js文件。
###### 2.3 编辑修改:
``` java
public void onActionCode(Component component) {
if (!codeView.isEditable()) {
((Button)component).setText("完成");
codeView.setContentEditable(true);
} else {
((Button)component).setText("编辑");
codeView.setContentEditable(false);
}
}
```
***
#### ReadView小说阅读:
* 基于Canvas制作的小说阅读
* 可更换字体、字号、字颜色
* 拓展性强
##### 效果展示

###### 使用基础功能只需要:
``` java
ReadView readView = new ReadView(this,dir.getPath());
setUIContent(readView);
```
###### 如果需要打开文件时调用请修改config。json和:
``` java
File dir = null;
Uri fileUri = getIntent().getData();
if (fileUri != null) {
dir = new File(fileUri.getPath());
}
readView = null;
if (dir != null) {
readView = new ReadView(this,dir.getPath());
}
else
finish();
setUIContent(readView);
```
***
#### MarkDownView支持MarkDown语法的渲染器:
* 基于WebView的MarkDown渲染器
* 支持标准化的MarkDown语法
* 调用接口和CodeView保持一致使用简便
##### 效果展示

###### 使用基础功能:
``` xml
```
并添加:
``` java
MarkDownView markDownView = (MarkDownView)findComponentById(ResourceTable.Id_markdownview);
if(getIntent().getStringParam("str") != null){
markDownView.setStringSource(getIntent().getStringParam("str"));
}
```
###### 如果需要打开文件时调用请修改config.json和:
``` java
File dir = null;
Uri fileUri = getIntent().getData();
if (fileUri != null) {
dir = new File(fileUri.getPath());
}
if (dir != null) {
markDownView.setDirSource(dir);
}
```
***
#### VerTextView竖行排版的TextView:
* 支持竖行排版
* 添加了下划线功能,开启简便,下划线粗细、颜色、间距均可自定义
* 接口调用方式与TextView相似,使用简便
##### 效果展示

###### 使用基础功能:
``` xml
```
并添加:
``` java
VerTextView verTextView = (VerTextView)findComponentById(ResourceTable.Id_vertextview);
verTextView.setText(getString(ResourceTable.String_poem));
```
###### 一些设定:
``` java
verTextView.setFontSize(100); // 设定字体尺寸
verTextView.setIsOpenUnderLine(true); // 设定开启下划线
verTextView.setUnderLineColor(Color.RED); // 设定下划线颜色
verTextView.setUnderLineWidth(3); // 设定下划线宽度
verTextView.setUnderLineSpacing(10); // 设定下划线到字的间距
verTextView.setTextStartAlign(VerTextView.RIGHT); // 从右侧或左侧开始排版
verTextView.setTextColor(color); // 设定字体颜色
...
```
***
#### Clock 绘制时钟:自定义View绘制的时钟
##### 效果展示

``` xml
```
##### 一些设定:
``` java
void setColor(int color);
void setNeedleColor(int needleColor);
void setTextColor(int textColor);
void setCircleColor(int circleColor);
void setUnthehourLineColor(int unthehourLineColor);
void setThehourLineColor(int thehourLineColor);
void setHourSize(int hourSize);
...
```
## 版本迭代
- v1.0.1
## 版权和许可信息
Copyright 2015 [刘丰恺](http://www.cnblogs.com/lfk-dsk/)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.