AffineTransform - Is there a way to glean units of measurement for pixels?

Assuming I get a pointer to a java.awt.geom.AffineTransform from:
java.awt.geom.AffineTransform CurTransform = ((java.awt.Graphics2D)this.getMainFrame().getGraphics()).getDeviceConfiguration().getDefaultTransform();
Assuming I've gotten the right AffineTransform... How do I get, or can I get, the scaling factor between horizontal pixels and vertical pixels for the current screen (or whatever device). In other words I want to place components... buttons, textboxes, etc. in a dialog box so that they are "square". i.e. 10 units in x look on the screen equal to 10 units in y.
Once I know what the "square pixel scale factor" is I can then worry about making the units relative to whatever font size.
This question is usually posed as "How do I get dialog units?". I haven't done that because of the "legacy problems" associated with what most people think dialog units come from. It is true that way back when dialog units were derived from a textmetrics ONLY, but unless I'm mistaken, Charles Petzold, was describing something that could only be gotten that way at that time (circa 1990).... The width of the fixed system font by the height of the fixed system font ended up being as close to a unit that was 8 units high looked like 8 units wide in the screen. The object of the exercise is to most importantly get units of measurement that translate to pixels and look "square" on the screen. Secondarily, but not unimportant, is to be a unit that has some relevance to the current font size. It's been a long time dialog units in windows maybe a 2:1 ratio. I made my own cDialogUnits so long ago I can't remember what the "standard windows" dialog unit is. In windows I can very easily get the screen dpi x and y, I think it's a devicecontext but Java's "devicecontext" only gives one dimension of the dpi?
Also this query is mute if I was "painting" on a device. The units are for pixels NOT points and are (mostly) for placing controls on the screen. I am aware of and have used the various addPreferredGap and setAutoCreateContainerGaps available in a GroupLayout... Great gizmos but, still dialog units would be very handy for setting the prefered width of a textbox/label with too much text. (Note: dialog units are NOT for calculating the height of text... )
I did search the sun forums for an answer first... It might be here I just didn't find it. It seems to be a question either avoided like the plague or considered a dumb question in Java.

This might be OK?
BE AWARE!! This is NOT a painting gizmo. It is used in conjunction with the Layout gizmos. It drives me crazy that the Layout gizmos have "default" gaps and spacers of some kind and yet ALL the tutorials immediately and unabashedly trash any "device independence" by mixing in pixel measurements... Not to mention I don't like the size of the gaps and spacing provided with the Layout gizmos anyway.
Does anyone know if this will fail? I am aware of the caveats provided... "Information about the device is only as good as has been provided." However if there is bad information in the device info I doubt using these units will do anything much different that the end user experiences with the errant device anyway.
AGAIN... This is NOT a painting gizmo. It's a helper when Laying out controls usually in conjunction with a Layout and only for spaces and gaps.
public class DialogUnits
    private double m_x;
    private double m_y;
    public DialogUnits( java.awt.Graphics2D g2 )
        java.awt.GraphicsConfiguration gc = g2.getDeviceConfiguration();
        java.awt.geom.AffineTransform at = gc.getDefaultTransform();
        at.concatenate( gc.getNormalizingTransform() );
        double fs = g2.getFont().getSize2D();
        m_x = at.getScaleX() * fs;
        m_y = at.getScaleY() * fs;
    public int CalcX( double units )
        return (int)Math.round( ( units * m_x ) / 8.0 );
    public int CalcY( double units )
        return (int)Math.round( ( units * m_y ) / 8.0 );
    public int ContainerGapX()
        return this.CalcX( 8.0 );
    public int ContainerGapY()
        return this.CalcY( 8.0 );
    public int FontSize2dX( int crude_columns )
        return (int)Math.round( crude_columns * m_x );
    public int FontSize2dY( int crude_rows )
        return (int)Math.round( crude_line_height * m_y );
    public int X( int units )
        return this.CalcX( units );
    public int Y( int units )
        return this.CalcY( units );
    } // end of class DialogUnits

Similar Messages

  • Is there a way to update an external dictionary for services without migrating the services

    Is there a way to update an external dictionary for services without migrating the services
    Is there a way to update a common external dictionary used by many services without migrating each and every service that uses the dictionary.  I have updated the table in the database and the external dictionary in our Development Environment. The external dictionary is used by many services. When I migrate the changed service to TEST/STAGE/PROD environments (NOTE: the table has been updated in the TEST/STAGE/PROD Databases), only the changed service is having the external dictionary updated. All other services that use the same external dictionary are NOT updated. I have the following questions
    Is it possible to migrate dictionaries so that all the services which are using that dictionary are updated?
    If the first one is not possible, Is there any other way to update the external dictionary without migrating all the services that use dictionary?

    dont think so but I could be wrong
    as it were I didn't like the build in audio so I connected some external logictech 2.1 speakers  but there
    are times when I use headset so I bought this one
    or any minijack splitter will work too so I have 2 things connected to the headset port works just fine
    http://www.belkin.com/IWCatProductPage.process?Product_Id=404634

  • Is there a way to connect an external speaker (for another room) through the headphone port

    Is there a way to connect an external speaker (for another room) through the headphone port  & still hear sound through the internal speakers?  System Preferences/Sound/Output or Sound Effects allows you to use one or the other  --  headphones or internal speakers.  I would like to have the option of hearing music through the internal speakers in one room, & through an external speaker in another room at the same time.  I also do not want to frequently disconnect/reconnect the external speaker from/to the headphone port as I know over time the connection could become loose.  (10.7.4  Lion)

    dont think so but I could be wrong
    as it were I didn't like the build in audio so I connected some external logictech 2.1 speakers  but there
    are times when I use headset so I bought this one
    or any minijack splitter will work too so I have 2 things connected to the headset port works just fine
    http://www.belkin.com/IWCatProductPage.process?Product_Id=404634

  • My family shares one apple id. Is there any way to make an apple id for each member of my family and have it all connected to the same credit card and have the same previous downloads open to download by signing in to each members personal apple id?

    My family shares one apple id. Is there any way to make an apple id for each member of my family and have it all connected to the same credit card and have the same previous downloads open to download by signing in to each members personal apple id?

    Hi cindy,
    If you all have individual Apple IDs, then you would be able to dowload music from a shared iTunes library on a computer, but you would not be able to sign on each individual ID on an iOS device in order to download music purchased under the original Apple ID without a 90-day waiting period between sign-ons.
    Here's what I mean:
    If you were to sign on a new Apple ID on, say, an iPhone, and then were to purchase and download some music from iTunes, then you would have to wait 90 days before you could sign on the old Apple ID to that iPhone in order to download previously purchased material (and vice versa).
    However, if all of the music purchased by that origjnal Apple ID is in an iTunes library on a shared computer, then you can hook up the device and selectively sync any music in that library to the device. You can also sign on any of the Apple IDs to that shared iTunes library and purchase music to be added to the library.
    You would need to authorize the computer for each of the new Apple IDs.
    Each of the Apple IDs would also be able to download that music purchased either by syncing to the iTunes library on the computer or by downloading it OTA on the device.
    So, each Apple ID can download music, movies, etc. purchased with that Apple ID OTA to the device. Also each Apple ID can sync any music, movies, etc. that are in the iTunes library on the computer regardless of who purchased them.
    The only other thing you would need to remember is that if an App needed to be updated, then the original Apple ID that was used to purchase that App would come up, and the password that goes with that Apple ID would be required to do the update.
    Hope that helps,
    GB

  • Is there a way to create a coorporate account for Itunes?

    Is there a way to create a coorporate account for Itunes?

    Yes, but it's a series of 3 corporate accounts: VPP manager, VPP Facilitator,  end user
    See this documentation I just posted today to this forum
    https://discussions.apple.com/message/19437873#19437873

  • Is there a way to create a fade only for the first loop?

    I have a loop (Modern Guitar Rock 04), which I've extended out so it repeats four times. I select the Fade Tool and X-Fade for drag. I then drag just in front of the loop and onto it, which creates a fade. However, this also creates fades at the beginning of the repeating loops. Is there a way to create a fade only for the first loop?

    The loop function always repeats the same region so of course the fade is also copied. So option+drag the original region to make a (non clone) copy, fade the first region and loop the second one (which you just copied).

  • Can anyone help or answer this question for me. Is there a way to have a private album for pictures sent to my phone? Don't exactly want kids ( niece and nephew ) to play on my phone and see private pictures of my girlfriend

    Can anyone help or answer this question for me. Is there a way to have a private album for pictures sent to my phone? Don't exactly want kids ( niece and nephew ) to play on my phone and see private pictures of my girlfriend

    What about this?
    https://itunes.apple.com/ru/app/best-secret-folder/id488030828?l=en&mt=8

  • Is there a way to create a "common desktop" for all RD/TS 2012 users? (Office 2010 icons on the dekstop, for example.)

    Hello!  Just like the title, is there a way to create a "common desktop" for all RD/TS 2012 users?
    I know how to do this using regular W7 workstations and 2008 Servers, but the "Default" folder under the USERS directory is gone and I'm not sure how to get the icons there in Windows 8, let alone Server 2012 Remote Desktop.
    I've installed Office 2010 on the 2012 server, but every end user that logs in has to manually type in "Word," "Excel." "PowerPoint." etc from the metro interface, then right-click each icon to add the shortcut to the desktop.
    Given the... uh.. unfamiliarity of our endusers around the computer, this really isn't the best option.  What I'd like is them to log on and have all the Office icons ready and availible for them.
    Any ideas?
    Matthew J. Fazio

    Hi,
    You can edit the local GPP and create a desktop shortcut for all users.
    Reference:
    Customize the default local user profile in windows Server 2012
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/3f178a0e-128e-4f4f-870a-90c8bbf1afeb/customize-the-default-local-user-profile-in-windows-server-2012?forum=winserver8gen
    Also, you can use CopyProfile to customize the Default User Profile.
    Customize the Default User Profile by Using CopyProfile
    http://technet.microsoft.com/en-us/library/hh825135.aspx
    Best Regards.
    Jeremy Wu
    TechNet Community Support

  • Can someonoe please assist me in my Adobe Photoshop CS6 Extended.  I keep getting a 'Couldn't Complete Your Request because Dynamic Link is not Available?" Is there a way of getting a software patch for this problem?  I thought you didn't need extra softw

    Can someonee please assist me in my Adobe Photoshop CS6 Extended.  I keep getting a 'Couldn't Complete Your Request because Dynamic Link is not Available?" Is there a way of getting a software patch for this problem?  I thought you didn't need extra software.  My software other than that problem works fine.

    Couldn't complete what request?   Way more information please.
    What operating system?

  • Is there any way to create admin role only for one resource.

    Hi all,
    I am trying to create an admin role with 'update user' capability. But I want to restrict the user(with the admin role) to be able to update a user's attribute only for one resource, The user(with the admin role) should not be able to update the attributes of the other resources which a user have.
    Is there any way to create admin role only for one resource?
    I customized the tabbed user form to show only one resource attribute (deleting the missing fields and adding my tab for the resource) and then assigned this new User Form to the user(with the admin role) in security tab.
    It works fine. But the problem is that if any user(with the admin role) is also admin of some other resource then he/she will not be able to view the other resource attributes.
    Please suggest,
    thanks

    The loop function always repeats the same region so of course the fade is also copied. So option+drag the original region to make a (non clone) copy, fade the first region and loop the second one (which you just copied).

  • Is there any way to change the default font for outgoing text-messages, in "Messages"? (OSX 10.10)

    Is there any way to change the default font for outgoing text-messages, in "Messages"?
    I can change it for one conversation, but then it resets to the default, tiny font.
    The preferences menu only lets me change the conversation font.
    (OSX 10.10)

    Hi,
    As you may remember there used to be a Messages pane to the Preferences where the Font and colour of the Balloons or background and the Font text colour could be changed.
    And there was a Format Menu for character, word and Sentence changes in the current IM or iMessage.
    Those have gone in Yosemite's version of Messages (Despite it retaining the designation of Messages 8 the same as Mavericks' version).
    All that can be done now is set the size of the font and this has been moved to the General Section of the Preferences.
    The Yosemite version has also been fixed to using the Balloons style of send and receiving any type of messages as well.
    Changing the Font would involved editing the Balloon.transcript file.
    10:34 pm      Saturday; December 13, 2014
    ​  iMac 2.5Ghz i5 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad

  • Is there a way to change the default angle for effects or a quick way of selecting 90 or 180 without typing in numbers?

    is there a way to change the default angle for effects or a quick way of selecting 90 or 180 without typing in numbers?

    The app developer chooses the alert sound, or provides a way for you to change it.

  • Is there a way to fade music in iMovie for iPad2?

    Is there a way to fade music in iMovie for iPad2? I am making a short presentation using photos - not video. The music soundtrack ends abruptly. Is there a way to have it fade out?

    It shouldn't crash but it could be that your library has some user-agent detection that's going awry when running in an unknown browser. 
    You can always use the HTML5 WebAudio API to go beyond simple audio file playback. 
    -Mark

  • Is there a way to save a job action for YouTube upload in Compressor 3.5?

    Is there a way to save a job action for YouTube upload? I have about 25 - ten minute clips I want to upload and they all pretty much have the same description and tags. Is there a way to save/make a preset of the job actions that way I don't have to keep inputing the same usernames, passwords, descriptions, tags? Thank you

    the method mentioned by benwiggy will certainly work.  If you want to an option that would give you more options, you could use a PDF Service.  You could then put a specific job on hold while still allowing others to use the printer.
    You can do this by opening AppleScript Editor (/Applications/Utilities).  You can copy and paste the following into an editor window --
    on open printJobs
    tell application "Finder"
    set trapFile to quoted form of POSIX path of (printJobs as string)
    end tell
    set defaultPrinter to do shell script "lpstat -d | awk -F: '{print $2}'"
    do shell script "lpr -P" & defaultPrinter & " -q " & trapFile
    end open
    Save the file as an Application.  You can name it something like Hold Print Job.  Then just put it in the PDF Services directory in the Library directory of your Home folder <yourname>/Library/PDF Services.  You may need to make the PDF Services directory as it may not already be there.
    Once the file is in place, you can use it by using the PDF drop down menu at the bottom left of a print window.  That will send the file to the printer and put it on hold.  Others can still use the printer.  You can then print your file whenever you want.  Just open the print queue as mentioned by benwiggy.  Highlight the job that is Paused.  You will see a little curly icon at the very right (looks like a reload icon in a web browser).  Just click that icon and the job will start printing.

  • Is there a way to have two different iTunes for two different iPhones on one Windows User account?

    Using Windows 7, iphone 4.
    I've read as many threads on these forums and as many kb's as I could find, but I sttill can't figure it out. I have 2 iPhones. Let's call them, "wife" and "hubby". I want to have two separate iTunes, one for each of the phones. Hubby is the Windoows User. I don't want to set up a different Windows User for wife.
    Hubby was the original iPhone. When I plug it in, iTunes recognized it has Hubby's iPhone. Then I unplug Hubby and close iTunes. I plug in Wife but iTunes stll comes up with Hubby under Devices and syncs Hubby's iTunes to Wife's iphone.
    I've tried using the shift key when I open iTunes to set up two separate .itl files to no avail.
    Is there a way to have two different iTunes for two different iPhones on one Windows User account?
    Thanks!

    What happens if you rename the iPhone "Wife" when it shows up as "Hubby", then choose a different set of apps/playlists to sync with? iTunes is supposed to be able to manage multiple devices, each with their own selection of content. Perhaps you "restored" "Wife" with a backup from "Hubby" when you first set things up which is now causing confusion.
    To create a new library press and hold down the shift key as you click the icon to start iTunes and keep holding shift until asked to choose or create a library. You need to use the same technique to switch back.
    tt2

Maybe you are looking for

  • Error while activating Data object in DOE workbench

    Hi all, I created a Data Object and when I try to activate  that DO it is showing an error as below. Mobile Java client attributes not maintained. Please give some clue to resolve this. Thanks and Regards, Rajesh.A

  • Can i copy an podcast URL from the podcast view in iTunes?

    Hi, is there any way to copy an podcast URL from the Podcast view in Itunes? I have about 20 podcasts right now and when i try to hookup someone else with these, its a long way guiding them tru the podcast directory or finding the website where the p

  • HP89410A VSA example problem, Trace data problem

    after downloading the VSA driver from NI web, i'm trying the VSA application example vi, but the instrument keeps giving me "invalid seperator;:CALC%d:UPHFFS %f DEG:" error, turned out to be in the DataFormat vi. I'm using the default setup, anyone k

  • Image with Transparent Background

    I put this in the .NET forum but I believe this is the forum where it should be. I have an image (it's a signature) that has a transparent background (I have it as GIF, BMP & PNG). It works in MS Word to where if I insert the image I am able to type

  • Creative Cloud - Photo Shop shuts down

    I signed up with Creative Cloud a couple of weeks ago.  Lightroom 5 works fine, but PhotoShop shuts down after a minute or so and says it has stopped working. I have uninstalled and reinstalled it already and it still does the same thing. Any suggest