当前位置: 首页>>代码示例>>Java>>正文


Java SVG类代码示例

本文整理汇总了Java中com.larvalabs.svgandroid.SVG的典型用法代码示例。如果您正苦于以下问题:Java SVG类的具体用法?Java SVG怎么用?Java SVG使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SVG类属于com.larvalabs.svgandroid包,在下文中一共展示了SVG类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: SVGTileProvider

import com.larvalabs.svgandroid.SVG; //导入依赖的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
    );
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:25,代码来源:SVGTileProvider.java

示例2: getBitmapSvg

import com.larvalabs.svgandroid.SVG; //导入依赖的package包/类
private Bitmap getBitmapSvg(Params params, String fileName, int densityIndex) {
    try {
        FileInputStream inputStream = new FileInputStream(mContext.getFilesDir() + MainActivity.ICONS_PATH + fileName);
        SVG svg = SVGParser.getSVGFromInputStream(inputStream);

        // Icon size relative to current processed density
        int fSize = ICONS_SIZE[densityIndex];

        Bitmap bitmap = Bitmap.createBitmap(fSize, fSize, Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        canvas.drawPicture(svg.getPicture(), new Rect(0, 0, fSize, fSize));

        Bitmap finalBitmap = createTintedBitmap(bitmap, params.desiredColor);
        bitmap.recycle();
        return finalBitmap;
    } catch (IOException | SVGParseException e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:MajeurAndroid,项目名称:Android-Material-Icons,代码行数:21,代码来源:AsyncExporter.java

示例3: SVGTileProvider

import com.larvalabs.svgandroid.SVG; //导入依赖的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
    );
}
 
开发者ID:google,项目名称:iosched,代码行数:22,代码来源:SVGTileProvider.java

示例4: setButtonData

import com.larvalabs.svgandroid.SVG; //导入依赖的package包/类
private final void setButtonData(ImageButton button, int bWidth, int bHeight,
                                 int svgResId, SVG touched) {
    SVG svg = SVGParser.getSVGFromResource(getResources(), svgResId);
    button.setBackgroundDrawable(new SVGPictureDrawable(svg));

    StateListDrawable sld = new StateListDrawable();
    sld.addState(new int[]{android.R.attr.state_pressed}, new SVGPictureDrawable(touched));
    button.setImageDrawable(sld);

    LayoutParams lp = button.getLayoutParams();
    lp.height = bHeight;
    lp.width = bWidth;
    button.setLayoutParams(lp);
    button.setPadding(0,0,0,0);
    button.setScaleType(ScaleType.FIT_XY);
}
 
开发者ID:spdd,项目名称:chessonline,代码行数:17,代码来源:DroidFish.java

示例5: onCreate

import com.larvalabs.svgandroid.SVG; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_svg_android_sample);

    mMatrix = new Matrix();
    mImageView = (ImageView) findViewById(R.id.image);
    checkLayer(mImageView);

    SVG svg = SVGParser.getSVGFromResource(getResources(), R.raw.cute_fox);
    mImageView.setImageDrawable(svg.createPictureDrawable());
    mImageView.setImageMatrix(mMatrix);

    final ScaleGestureDetector detector = new ScaleGestureDetector(this,
            this);
    mImageView.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return detector.onTouchEvent(event);
        }
    });
}
 
开发者ID:android-opensource-library-56,项目名称:android-opensource-library-56,代码行数:24,代码来源:SvgAndroidSampleActivity.java

示例6: getDrawable

import com.larvalabs.svgandroid.SVG; //导入依赖的package包/类
public static Drawable getDrawable(String name, String svgSource) {
    if (cache.get(name) != null) {
        return cache.get(name);
    } else {
        SVG svg = SVGParser.getSVGFromString(svgSource);
        Drawable d = svg.createPictureDrawable();
        cache.put(name, d);
        return d;
    }
}
 
开发者ID:lampmantech,项目名称:tryton_android,代码行数:11,代码来源:SVGFactory.java

示例7: onCreate

import com.larvalabs.svgandroid.SVG; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);
	ImageView imageView = (ImageView) findViewById(R.id.imageView);
	imageView.setBackgroundColor(Color.WHITE);
	// Parse the SVG file, using svg-android
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
		Log.d("MainActivity", "disabling hw acceleration");
		imageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
	}
	SVG svg = SVGParser.getSVGFromResource(getResources(), R.raw.x);
	imageView.setImageDrawable(svg.createPictureDrawable());
}
 
开发者ID:knilch0r,项目名称:and-whereami,代码行数:16,代码来源:MainActivity.java

示例8: doInBackground

import com.larvalabs.svgandroid.SVG; //导入依赖的package包/类
@Override
protected SVG doInBackground(String... params) {
    try {
        FileInputStream inputStream = new FileInputStream(params[0]);
        SVG svg = SVGParser.getSVGFromInputStream(inputStream, Color.BLACK, Color.DKGRAY);
        inputStream.close();

        return svg;
    } catch (IOException | SVGParseException e) {
        Log.e("SVG", params[0]);
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:MajeurAndroid,项目名称:Android-Material-Icons,代码行数:15,代码来源:SVGView.java

示例9: getDrawableForSvg

import com.larvalabs.svgandroid.SVG; //导入依赖的package包/类
public static Drawable getDrawableForSvg(Context context, String fileName) {
    try {
        FileInputStream inputStream = new FileInputStream(context.getFilesDir() + MainActivity.ICONS_PATH + fileName);
        SVG svg = SVGParser.getSVGFromInputStream(inputStream, Color.BLACK, Color.DKGRAY);

        return svg.createPictureDrawable();
    } catch (IOException | SVGParseException e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:MajeurAndroid,项目名称:Android-Material-Icons,代码行数:12,代码来源:Utils.java

示例10: getBackgroundObject

import com.larvalabs.svgandroid.SVG; //导入依赖的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();
    }
}
 
开发者ID:RomanGolovanov,项目名称:ametro,代码行数:16,代码来源:ZipArchiveMapProvider.java

示例11: scaleSVG

import com.larvalabs.svgandroid.SVG; //导入依赖的package包/类
private static Bitmap scaleSVG(final SVG svg, int width, int height, final ScaleCoeffs a) {

    final int origWidth = svg.getPicture().getWidth();
    final int origHeight = svg.getPicture().getHeight();

    if (width <= 0 && height <= 0) {
      return svg.resizePictureAsBitmap(origWidth, origHeight);
    }
    else {
      float resizeWidthCoeff = 1.0f;
      float resizeHeightCoeff = 1.0f;

      if (width > 0) {
        resizeWidthCoeff = (float) width / (float) origWidth;
      }

      if (height > 0) {
        resizeHeightCoeff = (float) height / (float) origHeight;
        if (width < 0) {
          resizeWidthCoeff = resizeHeightCoeff;
        }
      }
      else {
        resizeHeightCoeff = resizeWidthCoeff;
      }

      width = Math.round(origWidth * resizeWidthCoeff);
      height = Math.round(origHeight * resizeHeightCoeff);

      if (a != null) {
        a.setCoeffX(resizeWidthCoeff);
        a.setCoeffY(resizeHeightCoeff);
      }

      return svg.resizePictureAsBitmap(width, height);
    }
  }
 
开发者ID:raydac,项目名称:AndroidPirateDice,代码行数:38,代码来源:InteractiveIndicator.java

示例12: SVGTileProvider

import com.larvalabs.svgandroid.SVG; //导入依赖的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
    );
}
 
开发者ID:secondsun,项目名称:devnexus-android,代码行数:28,代码来源:SVGTileProvider.java

示例13: SVGPictureDrawable

import com.larvalabs.svgandroid.SVG; //导入依赖的package包/类
public SVGPictureDrawable(SVG svg) {
    super(svg.getPicture());
    RectF bounds = svg.getBounds();
    RectF limits = svg.getLimits();
    if (bounds != null) {
        iWidth = (int)bounds.width();
        iHeight = (int)bounds.height();
    } else if (limits != null) {
        iWidth = (int)limits.width();
        iHeight = (int)limits.height();
    } else {
        iWidth = -1;
        iHeight = -1;
    }
}
 
开发者ID:spdd,项目名称:chessonline,代码行数:16,代码来源:SVGPictureDrawable.java

示例14: updateButtons

import com.larvalabs.svgandroid.SVG; //导入依赖的package包/类
private final void updateButtons() {
    boolean largeButtons = settings.getBoolean("largeButtons", false);
    Resources r = getResources();
    int bWidth  = (int)Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 36, r.getDisplayMetrics()));
    int bHeight = (int)Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 32, r.getDisplayMetrics()));
    if (largeButtons) {
        if (custom1ButtonActions.isEnabled() &&
            custom2ButtonActions.isEnabled() &&
            custom3ButtonActions.isEnabled()) {
            Configuration config = getResources().getConfiguration();
            if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
                bWidth  = bWidth  * 6 / 5;
                bHeight = bHeight * 6 / 5;
            } else {
                bWidth  = bWidth  * 5 / 4;
                bHeight = bHeight * 5 / 4;
            }
        } else {
            bWidth  = bWidth  * 3 / 2;
            bHeight = bHeight * 3 / 2;
        }
    }
    SVG svg = SVGParser.getSVGFromResource(getResources(), R.raw.touch);
    setButtonData(custom1Button, bWidth, bHeight, custom1ButtonActions.getIcon(), svg);
    setButtonData(custom2Button, bWidth, bHeight, custom2ButtonActions.getIcon(), svg);
    setButtonData(custom3Button, bWidth, bHeight, custom3ButtonActions.getIcon(), svg);
    setButtonData(modeButton, bWidth, bHeight, R.raw.mode, svg);
    setButtonData(undoButton, bWidth, bHeight, R.raw.left, svg);
    setButtonData(redoButton, bWidth, bHeight, R.raw.right, svg);
}
 
开发者ID:spdd,项目名称:chessonline,代码行数:31,代码来源:DroidFish.java

示例15: setClef

import com.larvalabs.svgandroid.SVG; //导入依赖的package包/类
public void setClef(Clef clef) {
    _clef = clef;
    SVG svg = SVGParser.getSVGFromResource(getResources(), clef._svgResource);
    _clefPic = svg.getPicture();
    int scaledWidth = _clefPic.getWidth() * _clef._height / _clefPic.getHeight();
    _clefRect = new Rect(_clefLeft, _clef._top,
                         _clefLeft + scaledWidth, _clef._top + _clef._height);
}
 
开发者ID:ydirson,项目名称:NotesTrainer,代码行数:9,代码来源:ScoreView.java


注:本文中的com.larvalabs.svgandroid.SVG类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。