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


Java SVG类代码示例

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


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

示例1: setSvg

import com.caverock.androidsvg.SVG; //导入依赖的package包/类
private void setSvg(String svgData)
{
    svg = null;
    try
    {
        svg = SVG.getFromString(svgData);
        originalWidth = (int) svg.getDocumentWidth();
        originalHeight = (int) svg.getDocumentHeight();
        svg.setDocumentWidth("100%");
        svg.setDocumentHeight("100%");
        svg.setDocumentViewBox(0, 0, originalWidth, originalHeight);
    }
    catch (SVGParseException e)
    {
        // nothing to do
    }
    if (svg != null)
    {
        this.svgData = svgData;
    }
    imageType = this.svg == null ? ImageType.NONE : ImageType.SVG;
}
 
开发者ID:mkulesh,项目名称:microMathematics,代码行数:23,代码来源:CustomImageView.java

示例2: doInBackground

import com.caverock.androidsvg.SVG; //导入依赖的package包/类
private Bitmap doInBackground(Integer... paramVarArgs)
{
  try
  {
    SVG localSVG = SVG.getFromResource(this.mContext, paramVarArgs[0].intValue());
    Bitmap localBitmap = Bitmap.createBitmap(this.mWidth, this.mHeight, Bitmap.Config.ARGB_8888);
    localSVG.renderToCanvas(new Canvas(localBitmap));
    return localBitmap;
  }
  catch (SVGParseException localSVGParseException)
  {
    Object[] arrayOfObject = new Object[2];
    arrayOfObject[0] = paramVarArgs[0];
    arrayOfObject[1] = localSVGParseException.getMessage();
    FinskyLog.e("Error loading SVG resource 0x%x: %s", arrayOfObject);
  }
  return null;
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:19,代码来源:LoadSVGTask.java

示例3: VectorDrawable

import com.caverock.androidsvg.SVG; //导入依赖的package包/类
public VectorDrawable(Resources res, int resId) {
    if (resId == 0)
        return;
    try {
        SVG svg = cache.get(resId);
        if (svg == null) {
            svg = SVG.getFromResource(res, resId);
            cache.put(resId, svg);
        }
        float density = res.getDisplayMetrics().density;

        float width = svg.getDocumentViewBox().width();
        float height = svg.getDocumentViewBox().height();

        int intWidth = (int) (width * density);
        int intHeight = (int) (height * density);
        state = new VectorState(svg, intWidth, intHeight);
        setBounds(0, 0, state.intWidth, state.intHeight);
    } catch (SVGParseException e) {

    }
}
 
开发者ID:ZieIony,项目名称:Carbon,代码行数:23,代码来源:VectorDrawable.java

示例4: attachView

import com.caverock.androidsvg.SVG; //导入依赖的package包/类
@Override
public void attachView(ImageZoomMvpView mvpView) {

    super.attachView(mvpView);

    requestBuilder = Glide.with(getMvpView().getAppContext())
            .using(Glide.buildStreamModelLoader(Uri.class,
                    getMvpView().getAppContext()), InputStream.class)
            .from(Uri.class)
            .as(SVG.class)
            .transcode(new SvgDrawableTranscoder(), PictureDrawable.class)
            .sourceEncoder(new StreamEncoder())
            .cacheDecoder(new FileToStreamDecoder<SVG>(new SvgDecoder()))
            .decoder(new SvgDecoder())
            .placeholder(R.drawable.placeholder)
            .error(R.drawable.placeholder)
            .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
            .animate(android.R.anim.fade_in);

}
 
开发者ID:apache,项目名称:incubator-taverna-mobile,代码行数:21,代码来源:ImageZoomPresenter.java

示例5: ContentBlock3ViewHolder

import com.caverock.androidsvg.SVG; //导入依赖的package包/类
public ContentBlock3ViewHolder(View itemView, Context context,
                               OnContentBlock3ViewHolderInteractionListener listener) {
  super(itemView);
  mContext = context;
  mTitleTextView = (TextView) itemView.findViewById(R.id.titleTextView);
  mCopyrightTextView = (TextView) itemView.findViewById(R.id.copyrightTextView);
  mImageView = (ImageView) itemView.findViewById(R.id.imageImageView);
  mImageProgressBar = (ProgressBar) itemView.findViewById(R.id.imageProgressBar);
  mListener = listener;

  mFileManager = FileManager.getInstance(context);

  SvgDrawableTranscoder svgDrawableTranscoder =  new SvgDrawableTranscoder();
  svgDrawableTranscoder.setmDeviceWidth(mContext.getResources().getDisplayMetrics().widthPixels);

  requestBuilder = Glide.with(mContext)
      .using(Glide.buildStreamModelLoader(Uri.class, mContext), InputStream.class)
      .from(Uri.class)
      .as(SVG.class)
      .transcode(svgDrawableTranscoder, PictureDrawable.class)
      .sourceEncoder(new StreamEncoder())
      .cacheDecoder(new FileToStreamDecoder<>(new SvgDecoder()))
      .decoder(new SvgDecoder())
      .listener(new SvgSoftwareLayerSetter<Uri>());
}
 
开发者ID:xamoom,项目名称:xamoom-android-sdk,代码行数:26,代码来源:ContentBlock3ViewHolder.java

示例6: getBitmapFromSvgInputstream

import com.caverock.androidsvg.SVG; //导入依赖的package包/类
private Bitmap getBitmapFromSvgInputstream(InputStream is) {
    Bitmap bitmap = null;
    try {
        SVG svg = SVG.getFromInputStream(is);
        double width = 16;
        double height = 16;
        if (svg.getDocumentViewBox() != null) {
            width = svg.getDocumentViewBox().width();
            height = svg.getDocumentViewBox().height();
        } else {
            Log.d(TAG, "DocumentViewBox is null. assuming width and heigh of 16px.");
        }

        bitmap = Bitmap.createBitmap((int) Math.ceil(width), (int) Math.ceil(height), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);//drawARGB(0,0,0,0);//drawRGB(255, 255, 255);
        svg.renderToCanvas(canvas);
    } catch (SVGParseException e) {
        e.printStackTrace();
    }
    return bitmap;
}
 
开发者ID:openhab,项目名称:openhab-android,代码行数:23,代码来源:MyWebImage.java

示例7: loadSvgIcon

import com.caverock.androidsvg.SVG; //导入依赖的package包/类
private void loadSvgIcon(String imageName, ImageView imageView)
{
    SVG cachedSvg = svgCache.get(imageName);
    if (cachedSvg != null)
    {
        imageView.setImageDrawable(new PictureDrawable(cachedSvg.renderToPicture()));
    }
    else
    {
        if (currentlyRetrieving.contains(imageView))
            return;
        currentlyRetrieving.add(imageView);

        imageView.setImageDrawable(null);
        Needle.onBackgroundThread().withThreadPoolSize(10).execute(new IconRetrievalTask(imageName, imageView));
    }
}
 
开发者ID:matejdro,项目名称:PebbleNotificationCenter-Android,代码行数:18,代码来源:IconPickerItem.java

示例8: thenDoUiRelatedWork

import com.caverock.androidsvg.SVG; //导入依赖的package包/类
@Override
protected void thenDoUiRelatedWork(SVG svg)
{
    if (svg != null)
    {
        try
        {
            imageView.setImageDrawable(new PictureDrawable(svg.renderToPicture()));
            svgCache.put(imageName, svg);

        }
        catch (NullPointerException e)
        {
            //renderToPicture() sometimes throws NPE.

            Timber.e("SVG Error", e);
            e.printStackTrace();
        }
    }

    currentlyRetrieving.remove(imageView);
}
 
开发者ID:matejdro,项目名称:PebbleNotificationCenter-Android,代码行数:23,代码来源:IconPickerItem.java

示例9: decode

import com.caverock.androidsvg.SVG; //导入依赖的package包/类
public Resource<SVG> decode(InputStream source, int width, int height, Options options)
    throws IOException {
  try {
    SVG svg = SVG.getFromInputStream(source);
    return new SimpleResource<SVG>(svg);
  } catch (SVGParseException ex) {
    throw new IOException("Cannot load SVG from stream", ex);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:SvgDecoder.java

示例10: transcode

import com.caverock.androidsvg.SVG; //导入依赖的package包/类
@Override
public Resource<PictureDrawable> transcode(Resource<SVG> toTranscode) {
  SVG svg = toTranscode.get();
  Picture picture = svg.renderToPicture();
  PictureDrawable drawable = new PictureDrawable(picture);
  return new SimpleResource<PictureDrawable>(drawable);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:SvgDrawableTranscoder.java

示例11: decode

import com.caverock.androidsvg.SVG; //导入依赖的package包/类
public Resource<SVG> decode(InputStream source, int width, int height, Options options)
    throws IOException {
  try {
    SVG svg = SVG.getFromInputStream(source);
    return new SimpleResource<>(svg);
  } catch (SVGParseException ex) {
    throw new IOException("Cannot load SVG from stream", ex);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:SvgDecoder.java

示例12: transcode

import com.caverock.androidsvg.SVG; //导入依赖的package包/类
@Override
public Resource<PictureDrawable> transcode(Resource<SVG> toTranscode, Options options) {
  SVG svg = toTranscode.get();
  Picture picture = svg.renderToPicture();
  PictureDrawable drawable = new PictureDrawable(picture);
  return new SimpleResource<>(drawable);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:SvgDrawableTranscoder.java

示例13: decode

import com.caverock.androidsvg.SVG; //导入依赖的package包/类
@Override
public CloseableImage decode(
    EncodedImage encodedImage,
    int length,
    QualityInfo qualityInfo,
    ImageDecodeOptions options) {
  try {
    SVG svg = SVG.getFromInputStream(encodedImage.getInputStream());
    return new CloseableSvgImage(svg);
  } catch (SVGParseException e) {
    e.printStackTrace();
  }
  return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:SvgDecoderExample.java

示例14: onSaveInstanceState

import com.caverock.androidsvg.SVG; //导入依赖的package包/类
/**
 * Parcelable interface: procedure writes the formula state
 */
@Override
@SuppressLint("MissingSuperCall")
public Parcelable onSaveInstanceState()
{
    Bundle bundle = new Bundle();
    bundle.putString(STATE_IMAGE_TYPE, imageType.toString());
    switch (imageType)
    {
    case NONE:
        // nothing to do
        break;
    case BITMAP:
        if (bitmap != null)
        {
            bundle.putParcelable(STATE_IMAGE_BITMAP, bitmap);
        }
        break;
    case SVG:
        if (svgData != null)
        {
            bundle.putString(STATE_IMAGE_SVG, svgData);
        }
        break;
    }
    return bundle;
}
 
开发者ID:mkulesh,项目名称:microMathematics,代码行数:30,代码来源:CustomImageView.java

示例15: onRestoreInstanceState

import com.caverock.androidsvg.SVG; //导入依赖的package包/类
/**
 * Parcelable interface: procedure reads the formula state
 */
@Override
@SuppressLint("MissingSuperCall")
public void onRestoreInstanceState(Parcelable state)
{
    if (state == null)
    {
        return;
    }
    if (state instanceof Bundle)
    {
        Bundle bundle = (Bundle) state;
        final ImageType type = ImageType.valueOf(bundle.getString(STATE_IMAGE_TYPE));
        switch (type)
        {
        case NONE:
            // nothing to do
            break;
        case BITMAP:
            setBitmap((Bitmap) bundle.getParcelable(STATE_IMAGE_BITMAP));
            break;
        case SVG:
            setSvg(bundle.getString(STATE_IMAGE_SVG));
            break;
        }
    }
}
 
开发者ID:mkulesh,项目名称:microMathematics,代码行数:30,代码来源:CustomImageView.java


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