Joined: Dec 26, 2009
Post Count: 13
Status:
Offline
how to get selected drawing to another swing interface
hi, I'm a university student, i try to arrange the furniture inside a rectangular room, with use of 2D bin packing algorithms. Its not productively make sense (in real world), but in scope wise, it was approved to develop. My project have more things to do, like: *Check area selected larger than selected furniture inside room. *Add human posture value to furniture before arrangement. *Arrange them in new interface using 2D First Fit and Next Fit Decreasing Height algorithms. *Show final arrangement in 3D.
It lot ha...:) but in this case i want to know how to get selected item, which we draw (which we select always rectangular area) to another swing interface. I tried http://www.sweethome3d.com/pluginDeveloperGuide.jsp as starting step, but its not work due to following line. or (PieceOfFurniture piece : getHome().getFurniture()) { it says there is no getHome() method. But i called a new swing interface, after click on that created plugin menu.
I tried your API, since i'm not expert with API's i cudnt find good path yet.
Can any one guide me, in this case, like what are the materials or classes i should follow, and more detail on this. How i should start this.
France
Joined: Nov 7, 2005
Post Count: 9426
Status:
Offline
Re: how to get selected drawing to another swing interface
getHome method is coming from com.eteks.sweethome3d.plugin.Plugin class from which VolumePlugin class inherits. If you look at VolumePlugin source code, you'll see that VolumeAction is an inner class that's why it can access to this method available in its VolumePlugin outer class. So, I guess you just defined VolumeAction class in a separate file and not as an inner class. It's not a problem but then, you'll have to store in the VolumeAction class a link to a VolumePlugin instance to access its getHome method.
The current selection in the plan is returned by the getSelectedItems method in Home class. This method returns a list of Selectable objects, and you can test the class of each object to know whether it's a piece of furniture, a wall...
Good luck for your project. It sounds interesting!
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator
Joined: Dec 26, 2009
Post Count: 13
Status:
Offline
Re: how to get selected drawing to another swing interface
Puybaret ; thanx bro. As you told, i messed with inner class, VolumePlugin worked fine. I am trying on getSelectedItems method, and selectable. Its implements many objects. I'll give a try first and comment, or ask further. Tx.
Joined: Dec 26, 2009
Post Count: 13
Status:
Offline
Re: how to get selected drawing to another swing interface
bro i try to get area of selected room by this code. float area; float s1[][]={{1,2},{3,5}}; Room r =new Room(s1); area=r.getArea(); JOptionPane.showMessageDialog(null,area);