Results 1 to 4 of 4
  1. #1
    Agent Mulder is offline Member
    Join Date
    Jul 2013
    Posts
    4
    Rep Power
    0

    Default java.awt.geom.Dimension2D.Float. Where is the implementation?

    Hello fellow Java Programmers,

    Classes like java.awt.geom.Point2D.Float and java.awt.geom.Rectangle2D.Float can be instantiated without problems, because they are implemented. But java.awt.geom.Dimension2D is only available as an abstract class. Concrete implementations for both the Float and the Double flavors seem to be missing.

    Why?

    Am I supposed to inherit java.awt.geom.Dimension2D myself? I use instances of java.awt.geom.Point2D.Float now, because it also encapsulates two floats, but conceputally it doesn't feel right.

    -X- Agent Mulder

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,728
    Blog Entries
    7
    Rep Power
    21

    Default Re: java.awt.geom.Dimension2D.Float. Where is the implementation?

    Indeed, the only extension of that class (in the public API) is the Dimension class; it has int public members but their getters return the corresponding double values If you want to, yu can always extend that abstract super class yourself (but do you really need to?)

    kind regards,

    Js
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Agent Mulder is offline Member
    Join Date
    Jul 2013
    Posts
    4
    Rep Power
    0

    Default Re: java.awt.geom.Dimension2D.Float. Where is the implementation?

    Unfortunately, I really do need Dimension2D.Float, because it holds values that I need later on. Rounding them to ints already is not an option.

    Extending the abstract base class java.awt.geom.Dimension2D is an option, but it is a mayor dent in an otherwise smooth design. I stick to java.awt.Point2D.Float to hold the two floats (width and height) that I need, but it is kind of ugly to use point.setLocation(width, height) where I mean to say dimension.setSize(width, height).

    Still it strikes me as odd that almost all java.awt.geom-classes do have concrete implementations for both Float and Double, with Dimension2D as the one exception. Is there a reason for this?

    -X- Agent Mulder
    Last edited by Agent Mulder; 07-28-2013 at 07:50 PM. Reason: added signature

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,728
    Blog Entries
    7
    Rep Power
    21

    Default Re: java.awt.geom.Dimension2D.Float. Where is the implementation?

    It is a bit inconsequent, I agree; but can't you define a simple class Dimension2DDouble extends Dimension2D or similar. It shouldn't be much work; you can even define your entire class Hierarchy so that you can have your static nested class MyDimension2D.Double ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. java.awt.geom, Making Objects Invisible?
    By Jakeob in forum New To Java
    Replies: 6
    Last Post: 10-12-2012, 04:21 AM
  2. XT XFLAT implementation in java
    By eljuventino in forum XML
    Replies: 0
    Last Post: 02-08-2011, 06:34 PM
  3. Java, MySQL and Data Type Float
    By digidigdj in forum AWT / Swing
    Replies: 0
    Last Post: 03-11-2010, 08:42 PM
  4. double and float value in java
    By arvindmer in forum New To Java
    Replies: 6
    Last Post: 05-28-2009, 05:51 PM
  5. [SOLVED] float in java and in mysql
    By Ch4os in forum NetBeans
    Replies: 1
    Last Post: 12-08-2008, 11:22 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •