本文整理汇总了Java中com.larvalabs.svgandroid.SVGBuilder类的典型用法代码示例。如果您正苦于以下问题:Java SVGBuilder类的具体用法?Java SVGBuilder怎么用?Java SVGBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SVGBuilder类属于com.larvalabs.svgandroid包,在下文中一共展示了SVGBuilder类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createBitmap
import com.larvalabs.svgandroid.SVGBuilder; //导入依赖的package包/类
public static Bitmap createBitmap(InputStream in, int w, int h, boolean closeStream) {
if (in == null) {
return null;
}
com.larvalabs.svgandroid.SVG svg;
svg = new SVGBuilder().readFromInputStream(in).build();
Bitmap bitmap = Bitmap.createBitmap(w, h, Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
Picture pic = svg.getPicture();
// svg.renderToCanvas(canvas/*, new RectF(0f, 0f, (float)w, (float)h)*/);
// svg.renderToCanvas(canvas, new RectF(0f, 0f, (float)w, (float)h));
canvas.drawPicture(pic, new Rect(0, 0, w, h));
if (closeStream) {
try {
in.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return bitmap;
}
示例2: SVGTileProvider
import com.larvalabs.svgandroid.SVGBuilder; //导入依赖的package包/类
public SVGTileProvider(File file, float dpi) throws IOException {
mScale = Math.round(dpi + .3f); // Make it look nice on N7 (1.3 dpi)
mDimension = BASE_TILE_SIZE * mScale;
mPool = new TileGeneratorPool(POOL_MAX_SIZE);
SVG svg = new SVGBuilder().readFromInputStream(new FileInputStream(file)).build();
mSvgPicture = svg.getPicture();
RectF limits = svg.getLimits();
mBaseMatrix = new Matrix();
mBaseMatrix.setPolyToPoly(
new float[]{
0, 0,
limits.width(), 0,
limits.width(), limits.height()
}, 0,
new float[]{
40.95635986328125f, 98.94217824936158f,
40.95730018615723f, 98.94123077396628f,
40.95791244506836f, 98.94186019897214f
}, 0, 3
);
}
示例3: SVGTileProvider
import com.larvalabs.svgandroid.SVGBuilder; //导入依赖的package包/类
public SVGTileProvider(File file, float dpi) throws IOException {
mScale = Math.round(dpi + .3f); // Make it look nice on N7 (1.3 dpi)
mDimension = BASE_TILE_SIZE * mScale;
mPool = new TileGeneratorPool(POOL_MAX_SIZE);
SVG svg = new SVGBuilder().readFromInputStream(new FileInputStream(file)).build();
mSvgPicture = svg.getPicture();
RectF limits = svg.getLimits();
// These values map the SVG file to world coordinates.
// See: http://stackoverflow.com/questions/21167584/google-io-2013-app-mystery-values
mBaseMatrix = new Matrix();
mBaseMatrix.setPolyToPoly(
new float[]{
0, 0, // North-West
limits.width(), 0, // North-East
limits.width(), limits.height() // South-East
}, 0, BuildConfig.MAP_FLOORPLAN_MAPPING, 0, 3
);
}
示例4: getBackgroundObject
import com.larvalabs.svgandroid.SVGBuilder; //导入依赖的package包/类
public Object getBackgroundObject(String name) throws IOException {
InputStream stream = getInputStream(name);
try {
if (name.endsWith(".svg")) {
SVG svg = new SVGBuilder().readFromString(FileUtils.readAllText(stream)).build();
return svg.getPicture();
} else if (name.endsWith(".png")) {
return BitmapFactory.decodeStream(stream);
}else {
throw new IOException("Unsupported type of image file " + name);
}
} finally {
stream.close();
}
}
示例5: buildImages
import com.larvalabs.svgandroid.SVGBuilder; //导入依赖的package包/类
private void buildImages() {
int background = isPressed ? darkenColor(getBackgroundColor()) : getBackgroundColor();
int foreground = isPressed ? darkenColor(getForegroundColor()) : getForegroundColor();
paint = new Paint();
paint.setTextAlign(Paint.Align.LEFT);
paint.setTextSize(getResources().getDisplayMetrics().scaledDensity *
18 * getResources().getConfiguration().fontScale);
paint.setColor(foreground);
backgroundPaint = new Paint();
backgroundPaint.setColor(background);
if (!isInEditMode()) {
logo = new SVGBuilder()
.readFromResource(getResources(), R.raw.hoomi_icon_only)
.setColorSwap(Color.WHITE, foreground)
.build();
hoomiName = new SVGBuilder()
.readFromResource(getResources(), R.raw.hoomi_text_only)
.setColorSwap(Color.WHITE, foreground)
.build();
hoomiNameLimits = hoomiName.getLimits();
} else {
Rect hoomiNameLimitsTemp = new Rect();
paint.getTextBounds("Hoomi", 0, 0, hoomiNameLimitsTemp);
hoomiNameLimits = new RectF(hoomiNameLimitsTemp);
}
imagesBuilt = true;
}
示例6: SVGTileProvider
import com.larvalabs.svgandroid.SVGBuilder; //导入依赖的package包/类
public SVGTileProvider(File file, float dpi) throws IOException {
mScale = Math.round(dpi + .3f); // Make it look nice on N7 (1.3 dpi)
mDimension = BASE_TILE_SIZE * mScale;
mPool = new TileGeneratorPool(POOL_MAX_SIZE);
SVG svg = new SVGBuilder().readFromInputStream(new FileInputStream(file)).build();
mSvgPicture = svg.getPicture();
RectF limits = svg.getLimits();
mBaseMatrix = new Matrix();
mBaseMatrix.setPolyToPoly(
new float[]{
0, 0,
limits.width(), 0,
limits.width(), limits.height(),
0, limits.height()
}, 0,
new float[]{
lon2x(-84.3965270742774),lat2y(33.76028996243774),
lon2x(-84.3958156183362),lat2y(33.760276861729395),
lon2x(-84.39581125974655),lat2y( 33.7582431615339),
lon2x(-84.39653344452381),lat2y( 33.7582526388671)
}, 0, 4
);
}