Can't create Area from Rectangle2D (SSCCE included)

Hi guys,
I'm trying to create an Area from a Rectangle2D as a workaround for being unable to create an Area from a Line2D.
It doesn't seem to work though; any idea why?
Here's a little SSCCE so you can see what I mean.
The area without any transformation applied displays fine (green). The 'line' produced from my Rectangle2D with the transformation also appears as desired (black). However, the Area produced from the transformation has no pixels in it (blue).
Help would be much appreciated x:o)
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.AffineTransform;
import java.awt.geom.Area;
import java.awt.geom.Rectangle2D;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Test implements ActionListener {
     private static Shape shape;
     private static Area area;
     private static JPanel component;
     public Test() {
          JFrame frame = new JFrame();
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          JPanel contentPane = new JPanel();
          component = new JPanel();
          component.setBackground(Color.WHITE);
          component.setOpaque(true);
          JButton button = new JButton("Draw");
          button.addActionListener(this);
          button.setActionCommand("draw");
          button.setPreferredSize(new Dimension(100, 20));
          component.setPreferredSize(new Dimension(400, 200));
          frame.setPreferredSize(new Dimension(400, 300));
          contentPane.add(component);
          contentPane.add(button);
          frame.setContentPane(contentPane);
          frame.pack();
          frame.setVisible(true);
     public static void main(String[] args) {
          new Test();
     public void actionPerformed(ActionEvent event) {
          if (event.getActionCommand().equals("draw")) {
               // Create graphics context
               Graphics2D g2d = (Graphics2D) component.getGraphics();
               // Create arbitrary endpoints for 'line'
               double x1 = 20;
               double x2 = 60;
               double y1 = 5;
               double y2 = 70;
               double deltaX = x1 - x2;
               double deltaY = y1 - y2;
               // Instantiate rectangle and derived area
               Rectangle2D.Double rectangle = new Rectangle2D.Double(x1, y1, Math.abs(deltaX), 10);
               area = new Area(rectangle);
               // Display area without transformation
               g2d.setColor(Color.GREEN);
               g2d.draw(area);
               // Construct matrix transformation for y = mx + c
               double m = deltaY / deltaX;
               double c = y1 / (m * x1);
               AffineTransform matrix = new AffineTransform(1, m, 0, 0, 0, c);
               // Transform Shape and Area by constructed matrix
               shape = matrix.createTransformedShape(rectangle);
               area = area.createTransformedArea(matrix);
               // Display the transformed Shape (black)
               g2d.setColor(Color.BLACK);
               g2d.draw(shape);
               // Shift 5 pixels right
               g2d.translate(5, 0);
               // Display the transformed Area (blue)
               g2d.setColor(Color.BLUE);
               g2d.draw(area);
               // Display transformed Area bounds as String
               g2d.drawString(area.getBounds().toString(), 80, 100);
}

I just came back to this, and realised that Area probably doesn't like there being no fillable area, lol slaps forehead
So this altered version works perfectly for a line of thickness 1:
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.AffineTransform;
import java.awt.geom.Area;
import java.awt.geom.Rectangle2D;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Test implements ActionListener {
     private static Shape shape;
     private static Area area;
     private static JPanel component;
     public Test() {
          JFrame frame = new JFrame();
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          JPanel contentPane = new JPanel();
          component = new JPanel();
          component.setBackground(Color.WHITE);
          component.setOpaque(true);
          JButton button = new JButton("Draw");
          button.addActionListener(this);
          button.setActionCommand("draw");
          button.setPreferredSize(new Dimension(100, 20));
          component.setPreferredSize(new Dimension(400, 200));
          frame.setPreferredSize(new Dimension(400, 300));
          contentPane.add(component);
          contentPane.add(button);
          frame.setContentPane(contentPane);
          frame.pack();
          frame.setVisible(true);
     public static void main(String[] args) {
          new Test();
     public void actionPerformed(ActionEvent event) {
          if (event.getActionCommand().equals("draw")) {
               // Create graphics context
               Graphics2D g2d = (Graphics2D) component.getGraphics();
               // Create arbitrary endpoints for 'line'
               double x1 = 20;
               double x2 = 60;
               double y1 = 5;
               double y2 = 70;
               double deltaX = x1 - x2;
               double deltaY = y1 - y2;
               // Instantiate rectangle and derived area
               Rectangle2D.Double rectangle = new Rectangle2D.Double(x1, y1, Math.abs(deltaX), 1); // Here's what's changed
               area = new Area(rectangle);
               // Display area without transformation
               g2d.setColor(Color.GREEN);
               g2d.draw(area);
               // Construct matrix transformation for y = mx + c
               double m = deltaY / deltaX;
               double c = y1 - (m * x1); // ** Sidenote: typo in the above version, d'oh!
               AffineTransform matrix = new AffineTransform(1, m, 0, 1, 0, c); // Here's what's changed
               // Transform Shape and Area by constructed matrix
               shape = matrix.createTransformedShape(rectangle);
               area = area.createTransformedArea(matrix);
               // Display the transformed Shape (black)
               g2d.setColor(Color.BLACK);
               g2d.draw(shape);
               // Shift 5 pixels right
               g2d.translate(5, 0);
               // Display the transformed Area (blue)
               g2d.setColor(Color.BLUE);
               g2d.draw(area);
               // Display transformed Area bounds as String
               g2d.drawString(area.getBounds().toString(), 80, 100);
}

Similar Messages

  • Can't create PDFs from Word due to Cambria font. Help.

    I'm using win 7 32 bit office 2010 acrobat pro 9. I can't create pdfs from word because of problems with cambria. I've ttried all the fixes I can find but none worked. Any more ideas?
    [thread title updated by moderator]

    How are you trying to create the PDF? With AA9 you have to print to the Adobe PDF printer or use the MS plugin.
    When you say you cannot create PDFs because of Cambria, what error messages are you getting and copy them here? At this point we really do not know what you are having problems with or how you are trying to create PDFs.
    In the future, please provide a topic to help folks that are stepping through all of the posts. A blank topic almost led me to simply skip your post.

  • Java.sql.SQLException: can't create statement from closed connection

    java.sql.SQLException: can't create statement from closed connection.
    at com.caucho.sql.QPooledConnectionImpl.prepareStatement(QPooledConnecti onImpl.java:411)
    I am getting this error with my JSP's, i am running on Resin on Win2k, and MySql as backend.
    Has anyone else also faced this issue ?
    Looking for someone to help me to solve this issue.
    rc

    Looking for someone to help me to solve this issue.Maybe you are closing the connections. You might want to verify that you are not doing that. Or if you are that that is the correct way to return the connection to the pool.
    Or you could have stale connections. Some databases will time out connections if the connection is no used in a while. (This is a good thing.) But this means connection pools must do something with connections that are not used for a while. The pools usually have a configuration option(s) which allows you to set up a keep alive message which keeps the database from closing the connection.

  • Can't create PDFs from Acrobat or Word?

    Downloaded the 8.1.4 update and now I can't create PDFs from Acrobat or Word.  If I try to create a PDF from the print menu, I get a message indicating that there are no print drivers for this...any ideas?

    Thanks for responding.  Yep, I tried repairing it...no dice.  Then I realized that I'd re-installed AA Pro 8 (having completely given up on the AA Pro 9 upgrade that crashed my system) but not the updates.  So I went through and re-installed each update.  Still no dice. Then I did another repair. Nope.  When I try to create a PDF via the print menu, I get a "Windows cannot print due to a problem with the current printer setup."  This tells me that I have driver problem. But everything else prints fine, and I'm pretty sure Acrobat doesn't have drivers.  I'm stumped...

  • Can't create Project from the Template or access project template

    Dear Experts,
    We are facing a issue while trying to access the project template/create the project from project template.
    we have 4 project template in place and of these two are working perfectly fine but
    From remaining two we are not being able to create project and even templates are not accesible , whenever we are trying to access the project template system rotates a circle for some time and keeps us on the same page.
    Even when we are trying to create project from the same template, system does the same again rotates the circle for some time and keeps us on the same screen.
    And System is not throwing any error for the same (we have checked in the log as well) just not letting us in and not allowing us to create project.
    Any Help Will be Highly Appreciated.
    Regards,
    Rakesh Daiya

    Dear Experts,
    We were able to find out the issue,
    We added 3 groups to the template with "Reviewer" access with "Document Only" Type in the project template.
    When we changed the type to "Template and Document" from "Document Only" and  system started allowing us to create projects from the template.
    Can anyone please help me with one query,
    Can we add a group(which includes all the buyers) with reviewer access and with Document only type?
    Does this really be a reason behind projects are not getting created from template?
    Any help will be appreciated
    Regards,
    Rakesh Daiya

  • Create table from another table including constraints

    Hi,
    Is there a way to create a table from another table including constraints.
    CREATE TABLE COPY_EMP
    as
    SELECT *
    FROM EMP
    WHERE 1 =2 ;
    This creates the table, but the constraints are not copied over.
    I was reading about DBMS_REDEFINITION - can that be used for this scenario ?
    Thanks!
    Anand

    >
    I tried that, but the constraint names are posing a problem. And unfortunately our constraints are not named in a standard, so am finding it difficult to replace them.
    Was just wondering if there were any simpler approach to this.
    >
    No - there isn't.
    You will have to use new names for the constraints. That usually means extracting the DDL and manually changing the constraint names.

  • Can't create PDF from Word file

    I may be missing some functionality or that functionality may not exist.
    I'm running Acrobat Pro 9.2 and MS Word 2004 (11.5) on OSX Leopard 10.5.8. I want to create a PDF from a Word file but NOT using the Print dialog. I want to either create it in Acrobat using File > Create PDF > From File or create it from within Word using the Acrobat menu/toolbar. This is so that it will end up as a tagged PDF.
    However, I don't have an Acrobat menu or toolbar in Word. I thought Acrobat was supposed to have installed these into MS Office when I installed Acrobat. And when within Acrobat if I select File > Create PDF > From File and choose a Word file, I get a message "Acrobat could not open 'filename.doc' because it is either not a supported file type or because the file has been damaged". This happens for all Word files.
    Looking in Acrobat > About Adobe Plug-Ins... under Convert2AdobePDF it says 'Loaded: no'.
    Are these two methods of converting Word files to PDFs something that can only be done in the Windows version of Acrobat? Or is there a plug-in or update I can download to install this missing functionality?
    Thanks for your help,
    Mark

    Keep your Office2004. But Office 2008 does have a way to create PDF's from within  the word and excel Programs.
    It works better than through the AdobePDF Printer, or through the Apple Print menus save as PDF. (Unless you have X.6.x Snow leopard)
    One thing it gets around is a long standing Problem Acrobat has had with word and excel since Word 6.0.1.a/Excel 5.0.1a. Acrobat doesn't know how to interpert Word Page section Breaks. Chopping up a word/excel document in to multiple PDFs that have to be merged back together. MS came up with their own PDF Converter that gets around that problem.

  • Can't create PDF from most MS Office files, or combine

    After behaving nicely for months, Acrobat suddenly won't create PDFs, either from the Acrobat menu or (for most) from right-clicking in Explorer. If I try File> Create PDF> From File, the dialog says it's looking for 'all supported formats' but doesn't show any of the files in the folder (not even .TXTs). It'll create a PDF from the right-click menu in Explorer, for only a very a few file types (for example, .docx but not .doc), and it won't do a Combine Files, either from Explorer or from the program, for any filetypes (says 'cannot convert file' on all filetypes).
    This worked fine up til today and I have the same setup at work (AA 9 Pro and Office 2010) where it works fine. Tried doing a 'Repair' but no change. Starting to panic here. What went south? Thanks for any clues!

    I said to print as a check, not to forget PDF Maker. The print is a temporary work around while you resolve the issue, partiuclarly if you are under time pressure. With versions before AA9, PDF Maker was simply a front end for the printer and when the printer was checked things might fail. So you get some trouble shooting of where the problem is. If you do not want to troubleshoot to see if everything is broken, that is fine.
    The updates and repairs are other steps to take. A reinstall is typically a last resort and should include deletion of the Acrobat folder and running a cleaner on the registry after the uninstall.
    Generally, if the PDF Maker in WORD does not work, then none of the other options to right click and create a PDF or creating a PDF directly in WORD will not work either. The whole point is to trace down to what is the major problem. Often folks have problems because the PDF Maker is not being recognized in WORD and has to be activated, but you have the icon and that suggests things should work.
    Your next step is to check the job settings file. Be sure you have access to the job settings file. You will usually get an error message if this access is denied for some reason and posting the error is helpful.

  • Can't Create PDF "from file" using any MS Office files

    Acrobat 8.1.1 Pro. (OS = XP), as part of the CS3 premium edition.
    I can no longer get Acrobat to recognize any of the MS Office applications extensions (.doc, .ppt, etc...) for use with either Create PDF "From File" or when using the Combine Files feature to Merge or Package. The extensions are no longer even listed as an option in the dialog box, or in the Preference settings under "Convert to PDF".
    FYI- I can still use the PDF Maker functionality from within the MS Office application to create a PDF.
    Any Idea what could have happened, or more importantly how to fix?
    ***Update***
    I have re-installed the Acrobat 8 application, and the problem still exists.
    I'm truly puzzled.

    I get this with my PC and I ran detect-repair and reinstalled. Some PDF's I can open and other's I cannot. I can send the email to a cohort and they can open fine.
    "Can't create file: Right-click the folder you want to create the file in and then click Properties on the shortcut menu to check your permissions for the folder"
    Any ideas would be great.
    Thanks!

  • Can't create VM from template on iSCSI

    Hello,
    I'm trying to create new VM from original Oracle template "OVM_EL5U3_X86_64_PVM_4GB" on iSCSI device without a success.
    Steps to reproduce:
    1) /OVS is mounted as iSCSI block device
    2) Original Oracle template is copied into /OVS/seed_pool/OVM_EL5U3_X86_64_PVM_4GB
    3) Oracle VM Manager - Import template (no problem)
    4) Oracle VM Manager - Create VM from template
    Result: Files are copied into running_pool, vm.cfg is updated, new VM is visible in VM Manager but with this message:
    failed: <Exception: Error updating the image.> StackTrace: File "/opt/ovs-agent-2.2/OVSSiteVM.py", line 471, in config_vm raise Exception("Error updating the image.")
    5) Oracle VM Manager - Start new VM
    Result:
    Status in VM is Running
    I can connect using VNC console
    But the VM is constantly rebooting with these messages on the console:
    Registering block device major 202
    xvda: xvda1 xvda2 xvda3
    xvda: p2 exceeds device capacity
    xvda: p3 exceeds device capacity
    Waiting for driver initialization.
    xvda: rw=0, want=101530648, limit-12707414
    attemp to access beyond end of device
    switchroot: mount failed: No such file or directory
    Kernel panic - not syncing: Attempted to kill init!
    Looks like there is a problem with partition sizes within the VM image file (xvda: p2 exceeds device capacity)
    I've tried to mount iSCSI formated with ocsf2 and ext3 - I'm getting the same error.
    However there is no problem when I mount /OVS as NFS or local drive and repeat the steps above.
    Any suggestion would be highly appreciated,
    Honza

    It's all sorted now.
    What I've learnt: OVS/Xen hypervisor doesn't seem to handle 4kB iSCSI block sizes.
    I had to change it to 512 bytes (configuration on the iSCSI storage - nothing on the Oracle VM side) and re-create all volumes.
    Just in case you experience something similar.
    Honza
    Edited by: Honza on Jul 21, 2009 3:00 PM

  • I can't create table from another table?

    Hi everyone!
    I have a problem that I don't known the reason why?
    I'm using Oracle version 8i and I want to create a table from another table, such as:
         CREATE TABLE a_backup as SELECT * FROM a => It's OK, table a_backup is created.
    But there is only a table that I can't created like that, such as:
         CREATE TABLE b_backup AS SELECT * FROM b;
    When I run over command, SQL Plus is not responding... and clients are can't access to DB or Executing forever
    This is the first time I met this problem.
    Can Anyone help me to resolved it?
    Thanks in advance!

    xi`tin wrote:
    Hi everyone!
    I have a problem that I don't known the reason why?
    I'm using Oracle version 8i and I want to create a table from another table, such as:You realize, of course, that 8i is completely out of support .... Is your OS and hardware just as old as your rdbms software, or is it only the rdbms that your company refuses to upgrade?
         CREATE TABLE a_backup as SELECT * FROM a => It's OK, table a_backup is created.
    But there is only a table that I can't created like that, such as:
         CREATE TABLE b_backup AS SELECT * FROM b;
    When I run over command, SQL Plus is not responding... and clients are can't access to DB or Executing forever
    This is the first time I met this problem.
    Can Anyone help me to resolved it?
    Thanks in advance!

  • Can't create archive from file menu

    Hello,
    I can't create 'archive' (tar.gz) from file menu in Color (Save Archive As...).
    I don't have authorization problem on my folder project; i can create myself a tar.gz archive in the folder Archive of my Color's project.
    The system.log file said:
    Jul 16 09:45:51 fcp1 [0x0-0x1e01e].com.apple.color[215]: tar: Cowardly refusing to create an empty archive
    Jul 16 09:45:51 fcp1 [0x0-0x1e01e].com.apple.color[215]: Try `tar --help' or `tar --usage' for more information.

    some other users report difficulties, crashes, freeze-ups and very long save times associated with the Operating System and Finder. There is apparently some background file compression utility that may be interfering with your save routine. There are a couple of threads related to this issue on this forum, so a bit of searching may yield a solution.
    I haven't encountered it in nearly four years of day-to-day with three separate systems in either Tiger or Leopard. Suffice to say that if you have any third-party whiz-bang utilities running, COLOR is very vulnerable to OS corruption as it is a stripped-out race car that doesn't expect or tolerate much else when it comes to sharing the computer.
    jPo

  • Can't creat PDF from .DWG file

    Using the world's most popular CAD program. Can't create a PDF from Adobe 3D. Apparently Adobe 3D wants to open the file using my AutoCAD, but thinks AutoCAD is not on my computer???

    Hi SWS,
    Didn't find it here, but found the answer by Googling and getting pointed to an AECBytes article from Feb '06, which had updated Revit 3D Capture settings (settings more updated than what Adobe gives you!).
    It's too bad the rotation tool is so unweildy and that the walkthru isn't right there with rotation, pan & zoom (crazy - no idea why that is). I need these to work in Reader for regular people, not computer/cad savvy types. Adobe 3D seems to have just great potential, but doesn't seem ready for prime-time yet on the PDF recipient end yet. Maybe version 8 is more polished/joe-regular-user friendly (which is what it's billed as if it's for use in Reader.
    Thanks again for your help.

  • Can't create invoice from the delivery

    Hello.
    Ship out the trade order then i created the delivery and PGI successfully.
    But when i went to VF01 to invoice the delivery i can´t create it.
    I take a look to the LOG and this is what i found:
    Error Log
                 6910517662 000010 The item is blocked for billing
    I double click the item and in the configuration of Financial processing there is a field called "Block" but there is nothing selected over there. Do you have any suggestion?
    I appreciate your help

    The item is blocked for billing
    Apart from the suggestions, if that particular material is kept open in some other system, then also, system will throw this error.  Also ensure that in material master Sales Org.1 view, this material is not blocked against the field "X-distr.chain status"
    thanks
    G. Lakshmipathi

  • Can't create system from par in Portal 7.3

    Hello experts,
    lately I have insatlled the new Netweaver 7.3 Portal AS Java. Now I want to create a new system to make email-connectivity like described on help.sap.com. Following the instructions I get stuck at the point choosing new system from par. This option is not given...
    Can somebody help? How can I create a connectivity to our exchange without that option? Or is there a note poitning to to this case?
    Thanks in advance.
    Kind regards
    Lu Huynh

    Hi,
    In Netweaver 7.3, you have a tool called
    SystemFromParConverter to achieve this requirement. Please follow the below help link for more details.
    http://help.sap.com/saphelp_nwce711/helpdata/en/45/26d6a3522b4c2de10000000a1553f6/frameset.htm
    PS: Please  do the  steps mentioned in the above help link from the EP server itself and not from your own local system. Browse the EP server folders to locate the Par file.
    you have to place the par file in the EP server.
    Thanks and Regards,
    Sowmya K

Maybe you are looking for

  • How to Load a data for database when format is different??

    Hai all... I have problem in Apex while loading the data to a database from external files.. Like i have my project input data in spreadsheet format..I wanted to load that in to Database.. But sequence and column names are different in spreadsheet an

  • Error in allocating Despatch number Interval not found Number object J_1IIN

    Dear All, I am facing a problem while doing an excise invoice. System is throwing an error saying that " Error in allocating Despatch number Interval not found Number object J_1IINTPR2. Can somebody help me with a solution ? Rgds, Indrajit Dey

  • Addaitional Data on BP's in R/3 available in CRM?

    In R/3 via transaction VD03 (Display Customer General Data) there is a menu Extras > Additional Data section There it is possible to maintain some Freely Definable Attributes As standard Attributes 1 - 10 are displayed Definition Identifies a particu

  • Third party in my problem system launch daemons

    I read in another post that if I had third party links in my problem system launch daemons section, then I had a problem.  I have ftp-proxy.plist listed under that section.  This is my etrecheck report. Hardware Information:           iMac (27-inch,

  • Itunes 12.01.26 Crashes Synching Apps on NAS

    I am extremely disappointed that Apples has still not provided a fix to iTunes crashing when it starts to synch apps following the release of iTunes 12 The crash happens every time I try to sync and just because my iTunes Library iOS on a NAS Server