-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add catch click event on objects in SH3D and send them to Scratch3
- Loading branch information
Showing
13 changed files
with
100 additions
and
50 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
JavaProject/bin/src/com/ScratchHome/ScratchHomePlugin$1.class
Binary file not shown.
Binary file modified
BIN
+534 Bytes
(110%)
JavaProject/bin/src/com/ScratchHome/ScratchHomePlugin.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package src.com.ScratchHome; | ||
|
||
import java.awt.event.MouseEvent; | ||
import java.awt.event.MouseListener; | ||
import java.io.DataOutputStream; | ||
import java.io.IOException; | ||
import java.net.Socket; | ||
import java.net.UnknownHostException; | ||
|
||
import com.eteks.sweethome3d.model.HomePieceOfFurniture; | ||
import com.eteks.sweethome3d.model.Selectable; | ||
import com.eteks.sweethome3d.swing.HomeComponent3D; | ||
|
||
public class ClickListener implements MouseListener { | ||
|
||
@Override | ||
public void mouseClicked(MouseEvent e) { | ||
// TODO Auto-generated method stub | ||
System.out.println("mouse is clicked"); | ||
int x=e.getX(); | ||
int y=e.getY(); | ||
HomeComponent3D comp = (HomeComponent3D) e.getSource(); | ||
Selectable closetSelectable = comp.getClosestItemAt(x,y); | ||
if (closetSelectable instanceof HomePieceOfFurniture) { | ||
HomePieceOfFurniture piece = (HomePieceOfFurniture) closetSelectable; | ||
System.out.println("closet piece : " +piece.getName()); | ||
try { | ||
Socket masocket = new Socket("localhost",2022); | ||
DataOutputStream out= new DataOutputStream(masocket.getOutputStream()); | ||
out.writeUTF("click/"+piece.getName()+"("+piece.getDescription()+")"); | ||
masocket.close(); | ||
|
||
} catch (UnknownHostException ex) { | ||
// TODO Auto-generated catch block | ||
ex.printStackTrace(); | ||
} catch (IOException ex) { | ||
// TODO Auto-generated catch block | ||
ex.printStackTrace(); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void mousePressed(MouseEvent e) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public void mouseReleased(MouseEvent e) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public void mouseEntered(MouseEvent e) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public void mouseExited(MouseEvent e) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters