This discussion is archived
3 Replies Latest reply: Dec 3, 2012 7:52 AM by gimbal2 RSS

JFrame Graphics SVG Or Absolute ?

KonTiki Newbie
Currently Being Moderated
I'm doing a Java graphical display of an application's output so that the eventual user can use this as a sort of working drawing for fabricating a customised part.

The first snag is that since lines can only be defined between 2 points (x1, y1) & (x2, y2) and since we have to enter integers for all co-ordinates (their being pixels), there is going to be a finite error in the line positions.

My plan was to convert this JFrame output to an SVG or EPS file and then let the craftsman print this out at true scale as his working drawing.
But I am afraid that enlarging an erroneous drawing will lead to still greater errors in the finished component.

I am in a position to draw these lines using a starting point and an angle, yet I see no method to do this.
In fact, the arc drawing methods also specify integer angle parameters.

Can anyone give me any guidance on this ?
Or do I just have to draw these as best I can, label them and add a table of precise angles for these lines ?
  • 1. Re: JFrame Graphics SVG Or Absolute ?
    gimbal2 Guru
    Currently Being Moderated
    Coordinates don't have to be integers. They have to be integers at the moment you draw them, but not necessarily does that have to be the case when you store them in memory.

    Computer graphics generally work on a model which defines the coordinates using floating point numbers and eventually that model is rasterized to the screen, calculating the proper 2D integer coordinates. Perhaps you too should be using basic 2D vector math and models when defining and transforming your data (for example scaling it) and only come time to draw the stuff (using Graphics2D methods) you translate whatever model you're using to proper 2D coordinates.
  • 2. Re: JFrame Graphics SVG Or Absolute ?
    KonTiki Newbie
    Currently Being Moderated
    Thanks for quick response.

    So, you suggest that I hold the true double data for later conversion into SVG/EPS files ?

    And that I cast this double precision data to distinct integer variables for GUI display purposes only ?

    (When I say that graphics plotting parameters have to be integers, I meant that Java graphics methods only recognize integer parameters.)

    Edited by: KonTiki on 03-Dec-2012 07:48
  • 3. Re: JFrame Graphics SVG Or Absolute ?
    gimbal2 Guru
    Currently Being Moderated
    KonTiki wrote:
    So, you suggest that I hold the true double data for later conversion into SVG/EPS files ?
    Whatever you want to do with it. The 'double data' is the information which is the actual truth!
    >
    And that I cast this double precision data to distinct integer variables for GUI display purposes only ?
    Exactly. The difference between data (float/double coordinates) and the presentation of data (2D integer coordinates mapped to the screen). Its a concept you'll see often in software development. That what you see does not have to be what is really going on under the hood.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points