Skip to content

Instantly share code, notes, and snippets.

@christianwimmer
Last active October 20, 2018 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christianwimmer/470e350d719f212349492c1d6bf22af4 to your computer and use it in GitHub Desktop.
Save christianwimmer/470e350d719f212349492c1d6bf22af4 to your computer and use it in GitHub Desktop.
class Graphics2DPlotter {
final SVGGraphics2D g2d = new SVGGraphics2D(...);
byte[] plotAsSVG(String function, double xmin, double xmax) {
... /* Use g2d instance for rendering. */
}
}
class PlotterSingletonFeature implements Feature {
@Override
public void afterRegistration(AfterRegistrationAccess access) {
/* This code runs during image generation. */
ImageSingletons.add(Graphics2DPlotter.class, new Graphics2DPlotter());
}
}
/* At run time, look up the singleton object that was created during image generation. */
ImageSingletons.lookup(Graphics2DPlotter.class).plotAsSVG(function, xmin, xmax);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment