-
Notifications
You must be signed in to change notification settings - Fork 7
/
TestInsertSVG.java
executable file
·104 lines (89 loc) · 3.71 KB
/
TestInsertSVG.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Copyright (c) 2012-2015, https://github.com/rhcad/vgandroid-demo, BSD license
package vgtest.testview.shape;
import rhcad.touchvg.IViewHelper;
import rhcad.touchvg.ViewFactory;
import vgtest.app.R;
import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
//! 测试插入SVG图形的视图类
public class TestInsertSVG extends LinearLayout {
private IViewHelper mHelper = ViewFactory.createHelper();
private static final String PATH = "mnt/sdcard/TouchVG/";
private static final String VGFILE = PATH + "testsvg.vg";
public TestInsertSVG(Context context) {
super(context);
this.setOrientation(LinearLayout.VERTICAL);
createButtons(context);
final FrameLayout layout = new FrameLayout(context);
addView(mHelper.createGraphView(context, layout), new LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
mHelper.setImagePath(PATH);
}
private void createButtons(Context context) {
final LinearLayout layout = new LinearLayout(context);
final LayoutParams param = new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
layout.setOrientation(LinearLayout.HORIZONTAL);
this.addView(layout, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
final Button tigerBtn = new Button(context);
tigerBtn.setText("tiger");
layout.addView(tigerBtn, param);
tigerBtn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mHelper.insertSVGFromResource(R.raw.tiger, 100, 100);
}
});
final Button mapBtn = new Button(context);
mapBtn.setText("map file");
layout.addView(mapBtn, param);
mapBtn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mHelper.insertImageFromFile(PATH + "map.svg");
}
});
final Button fontsBtn = new Button(context);
fontsBtn.setText("fonts");
layout.addView(fontsBtn, param);
fontsBtn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mHelper.insertSVGFromResource(R.raw.fonts);
}
});
final Button picBtn = new Button(context);
picBtn.setText("bitmap");
layout.addView(picBtn, param);
picBtn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mHelper.insertBitmapFromResource(R.drawable.vg_lock, 200, 100);
}
});
final Button splinesBtn = new Button(context);
splinesBtn.setText("Splines");
layout.addView(splinesBtn, param);
splinesBtn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mHelper.setCommand("splines");
}
});
final Button saveBtn = new Button(context);
saveBtn.setText("Save");
layout.addView(saveBtn, param);
saveBtn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mHelper.exportPNG(VGFILE);
mHelper.saveToFile(VGFILE);
}
});
final Button loadBtn = new Button(context);
loadBtn.setText("Load");
layout.addView(loadBtn, param);
loadBtn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mHelper.loadFromFile(VGFILE);
}
});
}
}