Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7837229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:32:16+00:00 2026-06-02T14:32:16+00:00

I am using a large open source library and need to generate personal subclasses

  • 0

I am using a large open source library and need to generate personal subclasses of a few of the classes. What are the best strategies? I would like to keep the original library unaltered and be easily able to reconfigure when it is updated. It is unlikely that my code is worth contributing to the project (though I am happy to write in a way that permits this).

The problem is a general one but I will illustrate it with my example. I am using Apache PDFBox which has a routine to write to java.awt.Graphics2D. I have replaced this by the Apache Batik toolkit which provides a subclass of Graphics2D (org.apache.batik.svggen.SVGGraphics2D) so I can capture the SVG representation. I create an instance

public static org.apache.batik.svggen.SVGGraphics2D createSVG() {
    org.w3c.dom.DOMImplementation domImpl =
    org.apache.batik.dom.GenericDOMImplementation.getDOMImplementation();
        org.w3c.dom.Document document = 
            domImpl.createDocument("http://www.w3.org/2000/svg", "svg", null);
        return new org.apache.batik.svggen.SVGGraphics2D(document);
    }

The place where PDFBox uses the graphics is org.apache.pdfbox.PDFReader which I have edited to allow for the new graphics:

    protected void showPage(int pageNumber)
{
    try 
    {
        PageDrawer drawer = new PageDrawer();
        PageWrapper wrapper = new PageWrapper( this );
        PDPage page = (PDPage)pages.get(pageNumber);
        wrapper.displayPage( page );
        PDRectangle cropBox = page.findCropBox();
        Dimension drawDimension = cropBox.createDimension();
        svg = PDFPagePanel.createSVG();          // MY EDIT!!!!!!!!!
        drawer.drawPage( svg, page, drawDimension );
        writeSVG(pageNumber);
    }
    catch (IOException exception)
    {
        exception.printStackTrace();
    }
}

I have got it to work (that’s not the problem). My concern is that I have had to hack/edit and recompile a number of the distributed PDFBox classes simply to generate and use the subclass. I end up with classes such as PMRPDFReader in the same packages as the library. It’s very messy – I can’t immediately remember where I made the edits, etc.

I feel I ought ought to be able to use the library as-is and simply add/link my subclasses. I use maven so maybe there is a way of excluding the original classes.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T14:32:18+00:00Added an answer on June 2, 2026 at 2:32 pm

    Here’s how I would do this:

    • Create a separate project that contains your source code changes. Check it into source code/revision control (SVN, Git, whatever you’re using). This project will only contain your changes.
    • Make sure it’s a Maven project. Use the same version number as the original open source project, but add an appendix to the version. If you’re using version 1.2, create your project to have version 1.2-Peter-1 or something similar. This way, you’ll always know which version it’s based on you’re also able to provide multiple versions/revisions of your changes. It will also not conflict with the official versions. Use the same group/artifact IDs as the official ones.
    • Use the original project as a dependency in your own.

    For deployment, you then have two options:

    • Deploy both your JAR (which just has your changes) and the original one, but make sure that your one is first in the classpath.
    • Use the Maven Shade plugin to create one jar that mixes the original classes and your own ones: http://maven.apache.org/plugins/maven-shade-plugin/examples/includes-excludes.html
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a certain large and well-maintained open-source C++ library and came across a
I'm using a large open-source control and I can't seem to find the code
I'm using a large (thousands of source files) public project with minor (a dozen
I am using a large JS library to perform certain drawing operations in canvas.
Anyone know of any open source libraries for particle based large scale smooth particle
I have the source for a large (>250 files) library that makes heavy use
I'm developing an open source C# application. For awhile now, I've been using a
We are developing an open source and free large scale database driven web application.
Is there a standardized way (i.e., code pattern, or, even better, open source library)
im using an open source program called Festival that generates text to speech, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.