Code Monkey home page Code Monkey logo

mapyrus's People

Contributors

simoc avatar simon04 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

simon04

mapyrus's Issues

NullPointerException using EPS command in PDF output file

I ran the following Mapyrus commands:

newpage "pdf", "test3.pdf", 210, 297
move 50, 50
eps "test3.eps", 20

Mapyrus stopped with a Java exception:

Cannot invoke "java.awt.Graphics2D.getColor()" because "this.m_graphics2D" is null
java.lang.NullPointerException: Cannot invoke "java.awt.Graphics2D.getColor()" because "this.m_graphics2D" is null
	at org.mapyrus.OutputFormat.drawBoundingBoxes(OutputFormat.java:3926)
	at org.mapyrus.OutputFormat.drawEPS(OutputFormat.java:4053)
	at org.mapyrus.Context.drawEPS(Context.java:2142)
	at org.mapyrus.ContextStack.drawEPS(ContextStack.java:687)
	at org.mapyrus.Interpreter.execute(Interpreter.java:1936)
	at org.mapyrus.Interpreter.executeStatement(Interpreter.java:3552)
	at org.mapyrus.Interpreter.interpret(Interpreter.java:3185)
	at org.mapyrus.Mapyrus.processFile(Mapyrus.java:215)
	at org.mapyrus.Mapyrus.main(Mapyrus.java:719)

The documentation for the EPS command states that a grey box should be drawn on the page.

I am using the git master branch.

Avoid unnecessary casts in source code

Mapyrus was developed before Java generics were available. As a result, there are still many unnecessary casts in the source code. For example,

ArrayList<Integer> pageNumbers = m_PDFIncludedPages.get(i);
for (int j = 0; j < pageNumbers.size(); j++)
{
	Integer pageNumber = (Integer)pageNumbers.get(j);

Remove these casts so the source code is easier to read.

Use try-with-resource when reading/writing files

Use Java 8 try-with-resource when reading or writing files, to simplify logic and cleanup.

Eclipse identifies about 40 places where try-with-resource should be used and reports warnings like Resource 'reader' should be managed by try-with-resource TFWFile.java:47.

Use explicit boxing/unboxing of numeric types

Use boxing and unboxing functions in Java source code to avoid The expression of type Integer is unboxed into int and The expression of type int is boxed into Integer type warnings.

This avoids any possible problems with auto-boxing/unboxing.

Fix compiler warnings with openjdk-11

Fix warnings when compiling Mapyrus with openjdk-11.

There are three categories of warnings:

  1. Resource leak: 'inStream' is never closed.
  2. The constructor Character(char) is deprecated since version 9 and also for objects of class Integer and Double.
  3. Missing enum values from case statements.

Remove declarations of exceptions that are never thrown

Eclipse reports that the following Java exceptions are declared, but never thrown:

Description	Resource	Path	Location	Type
The declared exception IOException is not actually thrown by the method readCFF(RandomAccessFile, OpenTypeFont.TableRecord) from type OpenTypeFont	OpenTypeFont.java	/mapyrus/src/main/java/org/mapyrus/font	line 509	Java Problem
The declared exception IOException is not actually thrown by the method writePostScriptHeader(double, double, int, boolean, ArrayList<PostScriptFont>, Color) from type OutputFormat	OutputFormat.java	/mapyrus/src/main/java/org/mapyrus	line 338	Java Problem
The declared exception IOException is not actually thrown by the method writeUnicodePDFString(PrintWriter, OpenTypeFont, String) from type OutputFormat	OutputFormat.java	/mapyrus/src/main/java/org/mapyrus	line 4689	Java Problem
The declared exception MapyrusException is not actually thrown by the method init(InputStream, String, int) from type XBMImage	XBMImage.java	/mapyrus/src/main/java/org/mapyrus/image	line 67	Java Problem
The declared exception MapyrusException is not actually thrown by the method isPageMaskAllZero(double, double, double, double) from type Context	Context.java	/mapyrus/src/main/java/org/mapyrus	line 1591	Java Problem
The declared exception MapyrusException is not actually thrown by the method reproject(Projection, Projection, Point2D.Double) from type Reproject	Reproject.java	/mapyrus/src/main/java/org/mapyrus/function	line 187	Java Problem
The declared exception MapyrusException is not actually thrown by the method writePostScriptHeader(double, double, int, boolean, ArrayList<PostScriptFont>, Color) from type OutputFormat	OutputFormat.java	/mapyrus/src/main/java/org/mapyrus	line 338	Java Problem

Remove these exceptions.

Add @Override annotations

Add @OverRide annotations to methods that are overridden, as this helps check that methods really do override a parent method.

Eclipse identifies about 100 methods where this annotation should be added.

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.