Mercurial > MadButterfly
view Android/java/org/madbutterfly/redraw_man.java @ 1395:a768d74e5f49
Fix the svg:use. For a svg:use, it is a group which include the content it reference. It means that we can not tween it to its origin object directly. Instead, we need to ungroup it and then use the result matrix to generate the tweened transformation matrix. Therefore, we need to concate its matrix to the referenced object.
Ad center object when the bbox-x is not available.
author | wycc |
---|---|
date | Sat, 02 Apr 2011 05:36:36 +0800 |
parents | 2d7df44e6299 |
children |
line wrap: on
line source
package org.madbutterfly; import android.graphics.Canvas; import android.view.SurfaceHolder; import java.util.ArrayList; public class redraw_man { Canvas _cr, _backend; int _rdman_addr; // address of redraw_man_t coord root; ArrayList paints; MBView _view; public redraw_man(Canvas cr, Canvas backend, MBView view) { int addr; _view = view; _cr = cr; _backend = backend; _rdman_addr = _jni.redraw_man_new(cr, backend); addr = _jni.rdman_get_root(_rdman_addr); root = new coord(this, addr); paints = new ArrayList(); } static void _invalid_subtree(coord subtree) { int i, sz; coord child; shape member; subtree.invalid(); sz = subtree.members.size(); for(i = 0; i < sz; i ++) { member = (shape)subtree.members.get(i); member.invalid(); } sz = subtree.children.size(); for(i = 0; i < sz; i++) { child = (coord)subtree.children.get(i); _invalid_subtree(child); } } protected void finalize() { int i, sz; paint pnt; _invalid_subtree(root); /* invalid paints */ sz = paints.size(); for(i = 0; i < sz; i++) { pnt = (paint)paints.get(i); pnt.invalid(); } _jni.redraw_man_free(_rdman_addr); } public coord get_root() { return root; } public coord coord_new(coord parent) { int addr; coord child; addr = _jni.rdman_coord_new(_rdman_addr, parent.addr); child = new coord(this, addr); parent.children.add(child); return child; } public void coord_free(coord obj) { obj.finalize(); obj.invalid(); } public shape shape_path_new(String pathdata) { int addr; shape new_shape; addr = _jni.rdman_shape_path_new(_rdman_addr, pathdata); new_shape = new shape(this, addr); return new_shape; } public paint paint_color_new(float r, float g, float b, float a) { int addr; paint pnt; addr = _jni.rdman_paint_color_new(_rdman_addr, r, g, b, a); pnt = new paint(this, addr); return pnt; } public void redraw() { _jni.rdman_redraw_all(_rdman_addr); _view.redraw(); } }