Git Product home page Git Product logo

vectorgraphics2d's Introduction

image

image

VectorGraphics2D

VectorGraphics2D provides implementations of Java's Graphics2D interface and exports the graphics in various vector file formats. Currently, there is support for the following vector file formats:

  • Encapsulated PostScript® (EPS)
  • Scalable Vector Graphics (SVG)
  • Portable Document Format (PDF)

Additional formats can be easily added.

Features

  • Support for EPS, PDF, and SVG formats
  • Rendering of all geometric shapes provided by the java.awt.Graphics2D interface
  • Shapes and text can be made transparent (except in EPS)
  • Arbitrary clipping paths can be defined
  • Output of bitmap images
  • Easily extensible
  • Small footprint (JAR is below 100 kilobytes)

Currently, most operations are supported, i.e. VectorGraphics2D is able to handle clipping gradients, or compression. Some features are still missing, like text encodings, embedded fonts, or metadata support. Although its early stage VectorGraphics2D is already used successfully in several projects to export vector graphics.

Requirements

VectorGraphics2D requires at least Java 8 and Gradle 5 or higher to build.

Installation

Without build management system

You can just add VectorGraphics2D-0.13.jar to the classpath of your project.

Using VectorGraphics2D with Maven

<dependency>
    <groupId>de.erichseifert.vectorgraphics2d</groupId>
    <artifactId>VectorGraphics2D</artifactId>
    <version>0.13</version>
</dependency>

Using VectorGraphics2D with Gradle

dependencies {
    compile group: 'de.erichseifert.vectorgraphics2d', name: 'VectorGraphics2D', version: '0.13'
}

Using VectorGraphics2D with sbt

libraryDependencies += "de.erichseifert.vectorgraphics2d" % "VectorGraphics2D" % "0.13"

Usage

A VectorGraphics2D object can be used as a replacement for a Graphics2D object. All calls to the VectorGraphics2D instance will be recorded and can later be retrieved as a CommandSequence:

Graphics2D vg2d = new VectorGraphics2D();
vg2d.draw(new Rectangle2D.Double(0.0, 0.0, 20.0, 20.0));
CommandSequence commands = ((VectorGraphics2D) vg2d).getCommands();

This command sequence can then be exported to a EPS, PDF or SVG document using a processor for the desired file type, i.e. EPSProcessor for EPS, PDFProcessor for PDF and SVGProcessor for SVG. Additionally, format specific output options can be passed to the processor when it is created. For example, a compression option can be passed for PDF:

PDFProcessor pdfProcessor = new PDFProcessor(true);

Another method to get a processor is Processors.get(String):

Processor pdfProcessor = Processors.get("pdf");

Finally, a document can be generated from the commands and written to an output stream:

Document doc = pdfProcessor.getDocument(commands, PageSize.A4);
doc.writeTo(new FileOutputStream("rect.pdf"));

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.