当前位置: 首页>>代码示例>>Java>>正文


Java GraphicalViewer.getEditPartRegistry方法代码示例

本文整理汇总了Java中org.eclipse.gef.GraphicalViewer.getEditPartRegistry方法的典型用法代码示例。如果您正苦于以下问题:Java GraphicalViewer.getEditPartRegistry方法的具体用法?Java GraphicalViewer.getEditPartRegistry怎么用?Java GraphicalViewer.getEditPartRegistry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.gef.GraphicalViewer的用法示例。


在下文中一共展示了GraphicalViewer.getEditPartRegistry方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createDiagramPage

import org.eclipse.gef.GraphicalViewer; //导入方法依赖的package包/类
private void createDiagramPage() {

    try {
      diagramEditor = new ActivitiDiagramEditor();
      int index = addPage(diagramEditor, getEditorInput());
      setPageText(index, ActivitiMultiPageEditor.DIAGRAM_PANE_TILE);
      GraphicalViewer graphicalViewer = (GraphicalViewer) diagramEditor.getAdapter(GraphicalViewer.class);
      if (graphicalViewer != null && graphicalViewer.getEditPartRegistry() != null) {
        ScalableFreeformRootEditPart rootEditPart = (ScalableFreeformRootEditPart) graphicalViewer.getEditPartRegistry().get(LayerManager.ID);
        IFigure gridFigure = ((LayerManager) rootEditPart).getLayer(LayerConstants.GRID_LAYER);
        gridFigure.setVisible(false);
      }
    } catch (PartInitException e) {
      ErrorDialog.openError(getSite().getShell(), "Error creating nested Activiti Diagram editor", null, e.getStatus());
    }
  }
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:17,代码来源:ActivitiMultiPageEditor.java

示例2: createPartControl

import org.eclipse.gef.GraphicalViewer; //导入方法依赖的package包/类
@Override
public void createPartControl(Composite parent) {
  super.createPartControl(parent);
  GraphicalViewer graphicalViewer = (GraphicalViewer) getAdapter(GraphicalViewer.class);
   if (graphicalViewer != null && graphicalViewer.getEditPartRegistry() != null) {
     ScalableFreeformRootEditPart rootEditPart = (ScalableFreeformRootEditPart) graphicalViewer.getEditPartRegistry().get(LayerManager.ID);
     IFigure gridFigure = ((LayerManager) rootEditPart).getLayer(LayerConstants.GRID_LAYER);
     gridFigure.setVisible(false);
   }
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:11,代码来源:ActivitiDiagramEditor.java

示例3: saveEditorContentsAsImage

import org.eclipse.gef.GraphicalViewer; //导入方法依赖的package包/类
private static void saveEditorContentsAsImage(IEditorPart editorPart,
		GraphicalViewer viewer, String saveFilePath, int format) {
	/*
	 * 1. First get the figure whose visuals we want to save as image. So we
	 * would like to save the rooteditpart which actually hosts all the
	 * printable layers.
	 * 
	 * NOTE: ScalableRootEditPart manages layers and is registered
	 * graphicalviewer's editpartregistry with the key LayerManager.ID ...
	 * well that is because ScalableRootEditPart manages all layers that are
	 * hosted on a FigureCanvas. Many layers exist for doing different
	 * things
	 */
	Map editPartRegistry = viewer.getEditPartRegistry();
	LayerManager rootEditPart = (LayerManager) editPartRegistry.get(LayerManager.ID);
	IFigure rootFigure = rootEditPart.getLayer(LayerConstants.PRINTABLE_LAYERS);
	
	for (Object obj : editPartRegistry.values()) {
		if (obj instanceof ScreenEditPart){
			rootFigure = ((ScreenEditPart)obj).getFigure();
			break;
		}
	}
	Rectangle rootFigureBounds = rootFigure.getBounds();

	/*
	 * 2. Now we want to get the GC associated with the control on which all
	 * figures are painted by SWTGraphics. For that first get the SWT
	 * Control associated with the viewer on which the rooteditpart is set
	 * as contents
	 */
	Control figureCanvas = viewer.getControl();
	GC figureCanvasGC = new GC(figureCanvas);

	/*
	 * 3. Create a new Graphics for an Image onto which we want to paint
	 * rootFigure
	 */
	Image img = new Image(null, rootFigureBounds.width,
			rootFigureBounds.height);
	GC imageGC = new GC(img);
	imageGC.setBackground(figureCanvasGC.getBackground());
	imageGC.setForeground(figureCanvasGC.getForeground());
	imageGC.setFont(figureCanvasGC.getFont());
	imageGC.setLineStyle(figureCanvasGC.getLineStyle());
	imageGC.setLineWidth(figureCanvasGC.getLineWidth());
	imageGC.setXORMode(figureCanvasGC.getXORMode());
	Graphics imgGraphics = new SWTGraphics(imageGC);

	/*
	 * 4. Draw rootFigure onto image. After that image will be ready for
	 * save
	 */
	rootFigure.paint(imgGraphics);

	/* 5. Save image */
	ImageData[] imgData = new ImageData[1];
	imgData[0] = img.getImageData();

	ImageLoader imgLoader = new ImageLoader();
	imgLoader.data = imgData;
	imgLoader.save(saveFilePath, format);

	/* release OS resources */
	figureCanvasGC.dispose();
	imageGC.dispose();
	img.dispose();
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:69,代码来源:ImageSaveUtil.java

示例4: marshallImage

import org.eclipse.gef.GraphicalViewer; //导入方法依赖的package包/类
private void marshallImage() {
  try {

    // Retrieve GraphicalViewer from the save handler
    final GraphicalViewer graphicalViewer = ActivitiDiagramEditor.getActiveGraphicalViewer();

    if (graphicalViewer == null || graphicalViewer.getEditPartRegistry() == null)
      return;
    final ScalableFreeformRootEditPart rootEditPart = (ScalableFreeformRootEditPart) graphicalViewer.getEditPartRegistry().get(LayerManager.ID);
    final IFigure rootFigure = ((LayerManager) rootEditPart).getLayer(LayerConstants.PRINTABLE_LAYERS);
    final IFigure gridFigure = ((LayerManager) rootEditPart).getLayer(LayerConstants.GRID_LAYER);
    final Rectangle rootFigureBounds = rootFigure.getBounds();

    final boolean toggleRequired = gridFigure.isShowing();

    final Display display = Display.getDefault();

    final Image img = new Image(display, rootFigureBounds.width, rootFigureBounds.height);
    final GC imageGC = new GC(img);
    final SWTGraphics grap = new SWTGraphics(imageGC);

    // Access UI thread from runnable to print the canvas to the image
    display.syncExec(new Runnable() {

      public void run() {
        if (toggleRequired) {
          // Disable any grids temporarily
          gridFigure.setVisible(false);
        }
        // Deselect any selections
        graphicalViewer.deselectAll();
        rootFigure.paint(grap);
      }
    });

    ImageLoader imgLoader = new ImageLoader();
    imgLoader.data = new ImageData[] { img.getImageData() };

    ByteArrayOutputStream baos = new ByteArrayOutputStream(imgLoader.data.length);

    imgLoader.save(baos, SWT.IMAGE_PNG);

    imageGC.dispose();
    img.dispose();

    // Access UI thread from runnable
    display.syncExec(new Runnable() {

      public void run() {
        if (toggleRequired) {
          // Re-enable any grids
          gridFigure.setVisible(true);
        }
      }
    });

    final byte[] bytes = baos.toByteArray();
    final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
    saveResource(getRelativeURIForDiagram(diagram, FILENAME_PATTERN), bais, this.monitor);

  } catch (Exception e) {
    e.printStackTrace();
    addProblemToDiagram(diagram, "An exception occurred while creating the image: " + e.getCause(), null);
  }
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:66,代码来源:ImageExportMarshaller.java


注:本文中的org.eclipse.gef.GraphicalViewer.getEditPartRegistry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。