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


Java SnapToGrid类代码示例

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


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

示例1: getAdapter

import org.eclipse.gef.SnapToGrid; //导入依赖的package包/类
@Override 
public Object getAdapter(Class key) {
    if (key == SnapToHelper.class) {
        List<SnapToHelper> helpers = new ArrayList<SnapToHelper>();
        if (Boolean.TRUE.equals(getViewer().getProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED))) {
            helpers.add(new SnapToGeometry(this));
        }
        if (Boolean.TRUE.equals(getViewer().getProperty(SnapToGrid.PROPERTY_GRID_ENABLED))) {
            helpers.add(new SnapToGrid(this));
        }
        if(helpers.size()==0) {
            return null;
        } else {
            return new CompoundSnapToHelper(helpers.toArray(new SnapToHelper[0]));
        }
    }
    if (key == IPropertySource.class) {
       return new GW4EGraphEditPartProperties(this);
    }
    return null;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:22,代码来源:GraphPart.java

示例2: initializeGraphicalViewer

import org.eclipse.gef.SnapToGrid; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void initializeGraphicalViewer() {
    final GraphicalViewer viewer = getGraphicalViewer();
    viewer.setEditPartFactory(editPartFactory);

    initViewerAction(viewer);
    initDragAndDrop(viewer);

    viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1), MouseWheelZoomHandler.SINGLETON);
    viewer.setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, true);
    viewer.setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, true);
    viewer.setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, true);

    final MenuManager menuMgr = new ERDiagramPopupMenuManager(getActionRegistry(), diagram);

    extensionLoader.addERDiagramPopupMenu(menuMgr, getActionRegistry());

    viewer.setContextMenu(menuMgr);

    viewer.setContents(diagram);

    outlineMenuMgr = new ERDiagramOutlinePopupMenuManager(diagram, getActionRegistry(), outlinePage.getOutlineActionRegistory(), outlinePage.getViewer());
}
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:27,代码来源:ERDiagramEditor.java

示例3: initializeGraphicalViewer

import org.eclipse.gef.SnapToGrid; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void initializeGraphicalViewer() {
	GraphicalViewer viewer = this.getGraphicalViewer();
	viewer.setEditPartFactory(editPartFactory);

	this.initViewerAction(viewer);
	this.initDragAndDrop(viewer);

	viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1),
			MouseWheelZoomHandler.SINGLETON);
	viewer.setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, true);
	viewer.setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, true);
	viewer.setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, true);

	MenuManager menuMgr = new ERDiagramPopupMenuManager(
			this.getActionRegistry(), this.diagram, this);

	this.extensionLoader.addERDiagramPopupMenu(menuMgr,
			this.getActionRegistry());

	viewer.setContextMenu(menuMgr);

	viewer.setContents(diagram);
}
 
开发者ID:kozake,项目名称:ermaster-k,代码行数:28,代码来源:ERDiagramEditor.java

示例4: addPreferencesPropertyListener

import org.eclipse.gef.SnapToGrid; //导入依赖的package包/类
/**
 * Adding the property change for the grid.
 */
public void addPreferencesPropertyListener() {
	final IPreferenceStore store = GUIEditorPlugin.getDefault()
			.getPreferenceStore();
	store.addPropertyChangeListener(new IPropertyChangeListener() {

		@Override
		public void propertyChange(PropertyChangeEvent event) {
			// TODO Auto-generated method stub
			Dimension newDim = new Dimension();
			if (event.getProperty().equals(EditorPreferences.GRID_WIDTH)) {
				float widthValue = store
						.getFloat(EditorPreferences.GRID_WIDTH);
				newDim.width = (int) widthValue;
			} else if (event.getProperty().equals(
					EditorPreferences.GRID_HEIGHT)) {
				float heightValue = store
						.getFloat(EditorPreferences.GRID_HEIGHT);
				newDim.height = (int) heightValue;
			}
			viewer.setProperty(SnapToGrid.PROPERTY_GRID_SPACING, newDim);
		}
	});
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:27,代码来源:GUIEditor.java

示例5: updateRulers

import org.eclipse.gef.SnapToGrid; //导入依赖的package包/类
@Override
public void updateRulers() {
	// get mtable
	// get max size (table and tablemanager.size)
	MCrosstab table = getCrosstab();
	if (table != null) {
		Dimension d = table.getCrosstabManager().getSize();

		int dh = Math.max(d.height, (Integer) table
				.getPropertyValue(JRDesignElement.PROPERTY_HEIGHT));
		int dw = Math.max(d.width, (Integer) table
				.getPropertyValue(JRDesignElement.PROPERTY_WIDTH));

		getViewer().setProperty(ReportRuler.PROPERTY_HOFFSET, X_OFFSET);
		getViewer().setProperty(ReportRuler.PROPERTY_VOFFSET, Y_OFFSET);
		getViewer().setProperty(ReportRuler.PROPERTY_HEND, dw);
		getViewer().setProperty(ReportRuler.PROPERTY_VEND, dh);

		getViewer().setProperty(SnapToGrid.PROPERTY_GRID_ORIGIN,
				new Point(X_OFFSET, Y_OFFSET));
	}
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:23,代码来源:ACrosstabCellEditPart.java

示例6: updateRulers

import org.eclipse.gef.SnapToGrid; //导入依赖的package包/类
public void updateRulers() {
	ANode model = getModel().getParent();
	if (model instanceof IGraphicElement && model.getValue() != null) {
		Rectangle bounds = ((IGraphicElement) model).getBounds();
		if (bounds != null){
			int x = bounds.x + ReportPageFigure.PAGE_BORDER.left;
			int y = bounds.y + ReportPageFigure.PAGE_BORDER.top;

			getViewer().setProperty(ReportRuler.PROPERTY_HOFFSET, x);
			getViewer().setProperty(ReportRuler.PROPERTY_VOFFSET, y);
			getViewer().setProperty(ReportRuler.PROPERTY_HEND, bounds.width); //$NON-NLS-1$
			getViewer().setProperty(ReportRuler.PROPERTY_VEND, bounds.height);//$NON-NLS-1$

			getViewer().setProperty(SnapToGrid.PROPERTY_GRID_ORIGIN, new Point(x, y));
		}
	}
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:18,代码来源:FigureEditPart.java

示例7: refreshGridLayer

import org.eclipse.gef.SnapToGrid; //导入依赖的package包/类
/**
 * Updates the {@link GridLayer grid} based on properties set on the {@link #getViewer() graphical viewer}:
 * {@link SnapToGrid#PROPERTY_GRID_VISIBLE}, {@link SnapToGrid#PROPERTY_GRID_SPACING}, and
 * {@link SnapToGrid#PROPERTY_GRID_ORIGIN}.
 * <p>
 * This method is invoked initially when the GridLayer is created, and when any of the above-mentioned properties are
 * changed on the viewer.
 */
protected void refreshGridLayer() {
	if (jConfig != null) {
		boolean visible = jConfig.getPropertyBoolean(RulersGridPreferencePage.P_PAGE_RULERGRID_SHOWGRID, true);
		GridLayer grid = ((APageFigure) getFigure()).getGrid();
		grid.setOrigin((Point) getViewer().getProperty(SnapToGrid.PROPERTY_GRID_ORIGIN));

		int x = jConfig.getPropertyInteger(RulersGridPreferencePage.P_PAGE_RULERGRID_GRIDSPACEX, 10);
		int y = jConfig.getPropertyInteger(RulersGridPreferencePage.P_PAGE_RULERGRID_GRIDSPACEY, 10);

		grid.setSpacing(new Dimension(x, y));
		grid.setVisible(visible);
		getViewer().setProperty(SnapToGrid.PROPERTY_GRID_SPACING, new Dimension(x, y));

		String mcolor = jConfig.getProperty(RulersGridPreferencePage.P_PAGE_GRID_COLOR,
				RulersGridPreferencePage.DEFAULT_GRIDCOLOR);
		Color fg = SWTResourceManager.getColor(StringConverter.asRGB(mcolor));
		grid.setForegroundColor(fg);
	}
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:28,代码来源:PageEditPart.java

示例8: setupPageFigure

import org.eclipse.gef.SnapToGrid; //导入依赖的package包/类
/**
 * Setup page figure.
 * 
 * @param jd
 *          the jasper design
 * @param figure2
 *          the figure2
 */
protected void setupPageFigure(APageFigure figure2) {
	JasperDesign jd = getJasperDesign();
	int w = 2000;// jd.getPageWidth() + 20;
	int h = 5000;// designHeight + 10;

	figure2.setSize(w, h);

	getViewer().setProperty("RULER_HOFFSET", APageFigure.PAGE_BORDER.left); //$NON-NLS-1$
	getViewer().setProperty("RULER_VOFFSET", APageFigure.PAGE_BORDER.top); //$NON-NLS-1$
	getViewer().setProperty("RULER_HEND", jd.getPageWidth()); //$NON-NLS-1$
	getViewer().setProperty("RULER_VEND", jd.getPageHeight() - APageFigure.PAGE_BORDER.top); //$NON-NLS-1$

	getViewer().setProperty(SnapToGrid.PROPERTY_GRID_ORIGIN,
			new Point(APageFigure.PAGE_BORDER.left, APageFigure.PAGE_BORDER.top));

	setupPagePreferences(figure2);
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:26,代码来源:PageEditPart.java

示例9: updateRullers

import org.eclipse.gef.SnapToGrid; //导入依赖的package包/类
public void updateRullers() {
	JasperDesign jd = getJasperDesign();

	List<JRBand> bands = ModelUtils.getAllBands(jd);
	int dh = ModelUtils.getDesignHeight(bands);
	int tx = jd.getLeftMargin() + ReportPageFigure.PAGE_BORDER.left;
	int ty = jd.getTopMargin() + ReportPageFigure.PAGE_BORDER.top;

	getViewer().setProperty(ReportRuler.PROPERTY_HOFFSET, tx);
	getViewer().setProperty(ReportRuler.PROPERTY_VOFFSET, ty);
	getViewer().setProperty(ReportRuler.PROPERTY_HEND, jd.getPageWidth() - jd.getLeftMargin() - jd.getRightMargin());
	getViewer().setProperty(ReportRuler.PROPERTY_VEND, dh);

	getViewer().setProperty(SnapToGrid.PROPERTY_GRID_ORIGIN,
			new Point(tx, ReportPageFigure.PAGE_BORDER.top + jd.getTopMargin()));
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:17,代码来源:ReportPageEditPart.java

示例10: initializeGraphicalViewer

import org.eclipse.gef.SnapToGrid; //导入依赖的package包/类
@Override
protected void initializeGraphicalViewer() {
    final GraphicalViewer viewer = getGraphicalViewer();
    viewer.setEditPartFactory(editPartFactory);
    initViewerAction(viewer);
    initDragAndDrop(viewer);
    viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1), MouseWheelZoomHandler.SINGLETON);
    viewer.setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, true);
    viewer.setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, true);
    viewer.setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, true);

    prepareERDiagramPopupMenu(viewer);

    prepareERDiagramOutlinePopupMenu();

    this.gotoMaker = new ERDiagramGotoMarker(this);
}
 
开发者ID:dbflute-session,项目名称:erflute,代码行数:18,代码来源:MainDiagramEditor.java

示例11: getAdapter

import org.eclipse.gef.SnapToGrid; //导入依赖的package包/类
/**
 * {@inheritDoc} In this {@link EditPart} this method add adapter types for creating a
 * {@link SnapToHelper} when the editor is in snapping mode (either to grid or to shapes).
 */
@Override
public Object getAdapter(final Class key) {
  if (key == SnapToHelper.class) {
    List<SnapToHelper> helpers = new ArrayList<SnapToHelper>();
    if (Boolean.TRUE.equals(getViewer().getProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED))) {
      helpers.add(new SnapToGeometry(this));
    }
    if (Boolean.TRUE.equals(getViewer().getProperty(SnapToGrid.PROPERTY_GRID_ENABLED))) {
      helpers.add(new SnapToGrid(this));
    }
    if (helpers.size() == 0) {
      return null;
    } else {
      return new CompoundSnapToHelper(helpers.toArray(new SnapToHelper[0]));
    }
  }
  return super.getAdapter(key);
}
 
开发者ID:leondart,项目名称:FRaMED,代码行数:23,代码来源:ORMModelEditPart.java

示例12: getAdapter

import org.eclipse.gef.SnapToGrid; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public Object getAdapter(Class key) {
	if (IPropertySource.class == key) {
		return getPropertySource();
	}
	if (key == SnapToHelper.class) {
		List<SnapToHelper> helpers = new ArrayList<SnapToHelper>();
		if (Boolean.TRUE.equals(getViewer().getProperty(
				SnapToGeometry.PROPERTY_SNAP_ENABLED))) {
			helpers.add(new SnapToGeometry(this));
		}
		if (Boolean.TRUE.equals(getViewer().getProperty(
				SnapToGrid.PROPERTY_GRID_ENABLED))) {
			helpers.add(new SnapToGrid(this));
		}
		if (helpers.size() == 0) {
			return null;
		} else {
			return new CompoundSnapToHelper(
					helpers.toArray(new SnapToHelper[0]));
		}
	}

	return super.getAdapter(key);
}
 
开发者ID:snakerflow,项目名称:snaker-designer,代码行数:27,代码来源:ProcessEditPart.java

示例13: initializeGraphicalViewer

import org.eclipse.gef.SnapToGrid; //导入依赖的package包/类
/**
 * 初始化View
 */
@Override
protected void initializeGraphicalViewer() {
	GraphicalViewer viewer = this.getGraphicalViewer();
	viewer.setEditPartFactory(editPartFactory);
	
	this.initViewerAction(viewer);
	
	
	super.getGraphicalViewer().addDropTargetListener(
			new DiagramTemplateTransferDropTargetListener(super.getGraphicalViewer()));
	viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1),
			MouseWheelZoomHandler.SINGLETON);
	viewer.setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, true);
	viewer.setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, true);
	viewer.setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, true);
	 GraphicalViewer view=getGraphicalViewer();
	viewer.setContents(diagram);

}
 
开发者ID:winture,项目名称:wt-studio,代码行数:23,代码来源:BODesignerEditor.java

示例14: getAdapter

import org.eclipse.gef.SnapToGrid; //导入依赖的package包/类
public Object getAdapter(Class adapter)
{
	if (adapter == SnapToHelper.class) {
		List snapStrategies = new ArrayList();
		Boolean val = (Boolean) getViewer()
				.getProperty(RulerProvider.PROPERTY_RULER_VISIBILITY);
		if (val != null && val.booleanValue())
			snapStrategies.add(new SnapToGuides(this));
		val = (Boolean) getViewer().getProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED);
		if (val != null && val.booleanValue())
			snapStrategies.add(new SnapToGeometry(this));
		val = (Boolean) getViewer().getProperty(SnapToGrid.PROPERTY_GRID_ENABLED);
		if (val != null && val.booleanValue())
			snapStrategies.add(new SnapToGrid(this));

		if (snapStrategies.size() == 0)
			return null;
		if (snapStrategies.size() == 1)
			return snapStrategies.get(0);
		SnapToHelper ss[] = new SnapToHelper[snapStrategies.size()];
		for (int i = 0; i < snapStrategies.size(); i++)
			ss[i] = (SnapToHelper) snapStrategies.get(i);
		return new CompoundSnapToHelper(ss);
	}
	return super.getAdapter(adapter);
}
 
开发者ID:winture,项目名称:wt-studio,代码行数:27,代码来源:BONodeEditPart.java

示例15: initializeGraphicalViewer

import org.eclipse.gef.SnapToGrid; //导入依赖的package包/类
/**
 * 初始化View
 */
@Override
protected void initializeGraphicalViewer() {
	GraphicalViewer viewer = this.getGraphicalViewer();
	viewer.setEditPartFactory(editPartFactory);
	
	this.initViewerAction(viewer);
	
	super.getGraphicalViewer().addDropTargetListener(
			new DiagramTemplateTransferDropTargetListener(super.getGraphicalViewer()));
	viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1),
			MouseWheelZoomHandler.SINGLETON);
	viewer.setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, true);
	viewer.setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, true);
	viewer.setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, true);
	 GraphicalViewer view=getGraphicalViewer();
	viewer.setContents(diagram);

}
 
开发者ID:winture,项目名称:wt-studio,代码行数:22,代码来源:FunctionDesignerEditor.java


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