Android Open Source - TileView Path Manager






From Project

Back to project page TileView.

License

The source code is released under:

MIT License

If you think the Android project TileView listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.qozix.tileview.paths;
//from   w w  w.j  a  v  a 2  s. com
import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Point;

import com.qozix.layouts.StaticLayout;
import com.qozix.tileview.detail.DetailManager;

public class PathManager extends StaticLayout {

    private static final int DEFAULT_STROKE_COLOR = 0x883399FF;
    private static final int DEFAULT_STROKE_WIDTH = 8;

    private boolean shouldDraw = true;

    private Paint defaultPaint = new Paint();
    {
        defaultPaint.setStyle(Paint.Style.STROKE);
        defaultPaint.setColor(DEFAULT_STROKE_COLOR);
        defaultPaint.setStrokeWidth(DEFAULT_STROKE_WIDTH);
        defaultPaint.setAntiAlias(true);
    }

    private DetailManager detailManager;

    private Path drawingPath = new Path();
    private Matrix matrix = new Matrix();

    private ArrayList<DrawablePath> paths = new ArrayList<DrawablePath>();

    public PathManager(Context context, DetailManager dm) {
        super(context);
        setWillNotDraw(false);
        detailManager = dm;
    }

    public Paint getPaint() {
        return defaultPaint;
    }

    public Path getPathFromPoints(List<Point> points) {
        Path path = new Path();
        Point start = points.get(0);
        path.moveTo((float) start.x, (float) start.y);
        int l = points.size();
        for (int i = 1; i < l; i++) {
            Point point = points.get(i);
            path.lineTo((float) point.x, (float) point.y);
        }
        return path;
    }

    public DrawablePath addPath(List<Point> points) {
        return addPath(points, defaultPaint);
    }

    public DrawablePath addPath(List<Point> points, Paint paint) {
        Path path = new Path();
        Point start = points.get(0);
        path.moveTo((float) start.x, (float) start.y);
        int l = points.size();
        for (int i = 1; i < l; i++) {
            Point point = points.get(i);
            path.lineTo((float) point.x, (float) point.y);
        }
        return addPath(path, paint);
    }

    public DrawablePath addPath(Path path, Paint paint) {
        DrawablePath drawablePath = new DrawablePath();
        drawablePath.path = path;
        drawablePath.paint = paint;
        return addPath(drawablePath);
    }

    public DrawablePath addPath(Path path) {
        return addPath(path, defaultPaint);
    }

    public DrawablePath addPath(DrawablePath drawablePath) {
        paths.add(drawablePath);
        invalidate();
        return drawablePath;
    }

    public void removePath(DrawablePath path) {
        paths.remove(path);
        invalidate();
    }

    public void clear() {
        paths.clear();
        invalidate();
    }

    public void setShouldDraw(boolean should) {
        shouldDraw = should;
        invalidate();
    }

    @Override
    public void onDraw(Canvas canvas) {
        if (shouldDraw) {
            float scale = (float) detailManager.getScale();
            matrix.setScale(scale, scale);
            for (DrawablePath drawablePath : paths) {
                drawingPath.set(drawablePath.path);
                drawingPath.transform(matrix);
                // defer drawing to the path object
                drawablePath.draw(canvas, drawingPath);
            }
        }
        super.onDraw(canvas);
    }

}




Java Source Code List

com.qozix.animation.AnimationListener.java
com.qozix.animation.Animator.java
com.qozix.animation.TweenHandler.java
com.qozix.animation.TweenListener.java
com.qozix.animation.Tween.java
com.qozix.animation.easing.EasingEquation.java
com.qozix.animation.easing.Linear.java
com.qozix.animation.easing.Strong.java
com.qozix.layouts.AnchorLayout.java
com.qozix.layouts.FixedLayout.java
com.qozix.layouts.ScalingLayout.java
com.qozix.layouts.StaticLayout.java
com.qozix.layouts.TranslationLayout.java
com.qozix.layouts.ZoomPanLayout.java
com.qozix.os.AsyncTask.java
com.qozix.tileview.TileView.java
com.qozix.tileview.detail.DetailLevelEventListener.java
com.qozix.tileview.detail.DetailLevelPatternParserDefault.java
com.qozix.tileview.detail.DetailLevelPatternParser.java
com.qozix.tileview.detail.DetailLevelSet.java
com.qozix.tileview.detail.DetailLevelSetupListener.java
com.qozix.tileview.detail.DetailLevel.java
com.qozix.tileview.detail.DetailManager.java
com.qozix.tileview.geom.PositionManager.java
com.qozix.tileview.graphics.BitmapDecoderAssets.java
com.qozix.tileview.graphics.BitmapDecoderHttp.java
com.qozix.tileview.graphics.BitmapDecoder.java
com.qozix.tileview.hotspots.HotSpotEventListener.java
com.qozix.tileview.hotspots.HotSpotManager.java
com.qozix.tileview.hotspots.HotSpot.java
com.qozix.tileview.markers.CalloutManager.java
com.qozix.tileview.markers.MarkerEventListener.java
com.qozix.tileview.markers.MarkerManager.java
com.qozix.tileview.paths.DrawablePath.java
com.qozix.tileview.paths.PathHelper.java
com.qozix.tileview.paths.PathManager.java
com.qozix.tileview.samples.SampleManager.java
com.qozix.tileview.tiles.TileCache.java
com.qozix.tileview.tiles.TileManager.java
com.qozix.tileview.tiles.TileRenderHandler.java
com.qozix.tileview.tiles.TileRenderListener.java
com.qozix.tileview.tiles.TileRenderTask.java
com.qozix.tileview.tiles.TileTransitionListener.java
com.qozix.tileview.tiles.Tile.java
com.qozix.tileview.tiles.selector.TileSetSelectorByRange.java
com.qozix.tileview.tiles.selector.TileSetSelectorClosest.java
com.qozix.tileview.tiles.selector.TileSetSelectorMinimalUpScale.java
com.qozix.tileview.tiles.selector.TileSetSelector.java
com.qozix.utils.ViewCurator.java
com.qozix.widgets.Scroller.java