Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException when using EMFGraphics2D without writeHeader #14

Open
laeubi opened this issue Jun 30, 2013 · 0 comments
Open

NullPointerException when using EMFGraphics2D without writeHeader #14

laeubi opened this issue Jun 30, 2013 · 0 comments

Comments

@laeubi
Copy link

laeubi commented Jun 30, 2013

EMFGraphics2D g2 = new EMFGraphics2D(new FileOutputStream(new File("/tmp/test.emf")), new Dimension(800, 600));
BasicStroke basicStroke = new BasicStroke(2f);
g2.setStroke(basicStroke);
g2.setColor(Color.RED);
g2.draw(new Line2D.Double(0, 0, 800, 600));
g2.dispose();

The culprit is that the os field of the class is null.

It works when invoking writeHeader() first.
Imo there are two options:

  • Call writeHeader() if the stream is first fetched
  • Throw a meaningfull exception

The same applies imo for the disposal... if the inital Graphics2D is disposed, writeTrailer and at least flush should be called on the stream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant