Draw2Dの使い方1


※上記の広告は60日以上更新のないWIKIに表示されています。更新することで広告が下部へ移動します。

package com.sample.editor1.editors;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.draw2d.FigureCanvas;
import org.eclipse.draw2d.FreeformLayer;
import org.eclipse.draw2d.FreeformViewport;
import org.eclipse.draw2d.RectangleFigure;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.EditorPart;

public class MiniDraw2DEditor1 extends EditorPart {
   @Override
   public void doSave(IProgressMonitor monitor) {
   }
   @Override
   public void doSaveAs() {
   }
   @Override
   public void init(IEditorSite site, IEditorInput input) throws PartInitException {
       setInput(input);
       setSite(site);
   }
   @Override
   public boolean isDirty() {
       return false;
   }
   @Override
   public boolean isSaveAsAllowed() {
       return false;
   }
   @Override
   public void createPartControl(Composite parent) {
       // FigureCanvas
       FigureCanvas figureCanvas = new FigureCanvas(parent);
       // ViewPort
       FreeformViewport viewport = new FreeformViewport();
       figureCanvas.setViewport(viewport);
       // レイヤー
       FreeformLayer l = new FreeformLayer();
       l.setLayoutManager(new XYLayout());
       // ノード
       RectangleFigure rect = new RectangleFigure();
       l.add(rect, new Rectangle(1, 2, 500, 600));
       // コンテンツのセット
       figureCanvas.setContents(l);
   }
   @Override
   public void setFocus() {
   }
}


plugins.xml
 <?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
  <extension
        point="org.eclipse.ui.editors">
     <editor
           name="MiniDraw2DEditor1"
           extensions="mini1"
           icon="icons/sample.gif"
           class="com.sample.editor1.editors.MiniDraw2DEditor1"
           id="com.sample.editor1.editors.MiniDraw2DEditor1">
     </editor>
  </extension>
</plugin>
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。