package samples; import java.io.FileNotFoundException; import java.io.IOException; import javax.vecmath.Vector3f; import org.jdesktop.lg3d.utils.action.ScaleActionBoolean; import org.jdesktop.lg3d.utils.c3danimation.NaturalMotionAnimation; import org.jdesktop.lg3d.utils.eventadapter.MouseEnteredEventAdapter; import org.jdesktop.lg3d.utils.shape.ImagePanel; import org.jdesktop.lg3d.wg.Component3D; import org.jdesktop.lg3d.wg.Cursor3D; import org.jdesktop.lg3d.wg.Frame3D; import org.jdesktop.lg3d.wg.Thumbnail; public class HelloWorld4 { private static final String IMAGE_FILE = "helloworld.png"; // 画像の大きさ 200x25 pixel // メートル変換用 0.0254 [inch/m] / 72.0f [pixel/inch] private static final float WIDTH = 200.0f * 0.0254f / 72.0f; private static final float HEIGHT = 25.0f * 0.0254f / 72.0f; private static final float DEPTH = 0.005f; public HelloWorld4() { Frame3D frame3d = new Frame3D(); try { ImagePanel panel = new ImagePanel(IMAGE_FILE, WIDTH, HEIGHT); Component3D comp3d = new Component3D(); comp3d.addChild(panel); comp3d.setCursor(Cursor3D.DEFAULT_CURSOR); frame3d.addChild(comp3d); doEnableToChangeSize(comp3d); Thumbnail thumbnail = new Thumbnail(); ImagePanel thumbnailPanel = new ImagePanel(IMAGE_FILE, WIDTH*4f, HEIGHT*4f); Component3D thumbnailComp3d = new Component3D(); thumbnailComp3d.addChild(thumbnailPanel); thumbnail.addChild(thumbnailComp3d); thumbnail.setPreferredSize(new Vector3f(WIDTH*4f, HEIGHT*4f, DEPTH)); frame3d.setThumbnail(thumbnail); frame3d.setPreferredSize(new Vector3f(WIDTH, HEIGHT, DEPTH)); frame3d.changeEnabled(true); frame3d.changeVisible(true); } catch (FileNotFoundException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } } private void doEnableToChangeSize(Component3D comp3d) { // なめらかに動かすようにする comp3d.setAnimation(new NaturalMotionAnimation(1000)); // Mouse が panel に入ったらサイズを拡大する comp3d.addListener(new MouseEnteredEventAdapter( new ScaleActionBoolean(comp3d, 1.1f, 500))); // 親にイベントを伝播する comp3d.setMouseEventPropagatable(true); } public static void main(String[] args) { new HelloWorld4(); } }