本文整理汇总了Java中org.eclipse.gef.SnapToGeometry类的典型用法代码示例。如果您正苦于以下问题:Java SnapToGeometry类的具体用法?Java SnapToGeometry怎么用?Java SnapToGeometry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SnapToGeometry类属于org.eclipse.gef包,在下文中一共展示了SnapToGeometry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAdapter
import org.eclipse.gef.SnapToGeometry; //导入依赖的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;
}
示例2: initializeGraphicalViewer
import org.eclipse.gef.SnapToGeometry; //导入依赖的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());
}
示例3: initializeGraphicalViewer
import org.eclipse.gef.SnapToGeometry; //导入依赖的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);
}
示例4: showTargetFeedback
import org.eclipse.gef.SnapToGeometry; //导入依赖的package包/类
/**
* @see org.eclipse.gef.EditPolicy#showTargetFeedback(org.eclipse.gef.Request)
*/
public void showTargetFeedback(Request req) {
if (req.getType().equals(REQ_MOVE) || req.getType().equals(REQ_RESIZE) || req.getType().equals(REQ_CLONE)
|| req.getType().equals(REQ_ADD) || req.getType().equals(REQ_CREATE)) {
Integer value;
value = (Integer) req.getExtendedData().get(SnapToGeometry.KEY_WEST_ANCHOR);
highlightGuide(value, ColorConstants.lightBlue, 0);
value = (Integer) req.getExtendedData().get(SnapToGeometry.KEY_NORTH_ANCHOR);
highlightGuide(value, ColorConstants.lightBlue, 1);
value = (Integer) req.getExtendedData().get(SnapToGeometry.KEY_EAST_ANCHOR);
highlightGuide(value, ColorConstants.lightBlue, 2);
value = (Integer) req.getExtendedData().get(SnapToGeometry.KEY_SOUTH_ANCHOR);
highlightGuide(value, ColorConstants.lightBlue, 3);
value = (Integer) req.getExtendedData().get(SnapToGuides.KEY_VERTICAL_GUIDE);
highlightGuide(value, ColorConstants.red, 4);
value = (Integer) req.getExtendedData().get(SnapToGuides.KEY_HORIZONTAL_GUIDE);
highlightGuide(value, ColorConstants.red, 5);
}
}
示例5: initializeGraphicalViewer
import org.eclipse.gef.SnapToGeometry; //导入依赖的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);
}
示例6: getAdapter
import org.eclipse.gef.SnapToGeometry; //导入依赖的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);
}
示例7: getAdapter
import org.eclipse.gef.SnapToGeometry; //导入依赖的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);
}
示例8: initializeGraphicalViewer
import org.eclipse.gef.SnapToGeometry; //导入依赖的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);
}
示例9: getAdapter
import org.eclipse.gef.SnapToGeometry; //导入依赖的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);
}
示例10: initializeGraphicalViewer
import org.eclipse.gef.SnapToGeometry; //导入依赖的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);
}
示例11: initializeGraphicalViewer
import org.eclipse.gef.SnapToGeometry; //导入依赖的package包/类
@Override
protected void initializeGraphicalViewer() {
super.initializePaletteViewer();
super.getGraphicalViewer().setContents(this.diagram);
super.getGraphicalViewer().addDropTargetListener(
new DiagramTemplateTransferDropTargetListener(super
.getGraphicalViewer()));
super.getGraphicalViewer().setProperty(
SnapToGrid.PROPERTY_GRID_ENABLED, true);
super.getGraphicalViewer().setProperty(
SnapToGrid.PROPERTY_GRID_VISIBLE, true);
super.getGraphicalViewer().setProperty(
SnapToGeometry.PROPERTY_SNAP_ENABLED, true);
}
示例12: getAdapter
import org.eclipse.gef.SnapToGeometry; //导入依赖的package包/类
@Override
public Object getAdapter(final Class key) {
if (key == SnapToHelper.class) {
final List<SnapToHelper> helpers = new ArrayList<SnapToHelper>();
helpers.add(new SnapToGeometry(this));
if (Boolean.TRUE.equals(getViewer().getProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED))) {
helpers.add(new SnapToGrid(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);
}
示例13: getAdapter
import org.eclipse.gef.SnapToGeometry; //导入依赖的package包/类
@Override
public Object getAdapter(Class key) {
if (key == SnapToHelper.class) {
List<SnapToHelper> helpers = new ArrayList<SnapToHelper>();
helpers.add(new SnapToGeometry(this));
if (Boolean.TRUE.equals(getViewer().getProperty(
SnapToGeometry.PROPERTY_SNAP_ENABLED))) {
helpers.add(new SnapToGrid(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);
}
示例14: showTargetFeedback
import org.eclipse.gef.SnapToGeometry; //导入依赖的package包/类
/**
* @see org.eclipse.gef.EditPolicy#showTargetFeedback(org.eclipse.gef.Request)
*/
public void showTargetFeedback(Request req) {
if (req.getType().equals(REQ_MOVE) || req.getType().equals(REQ_RESIZE)
|| req.getType().equals(REQ_CLONE)
|| req.getType().equals(REQ_ADD)
|| req.getType().equals(REQ_CREATE)) {
Integer value;
value = (Integer) req.getExtendedData().get(
SnapToGeometry.KEY_WEST_ANCHOR);
highlightGuide(value, ColorConstants.blue, 0);
value = (Integer) req.getExtendedData().get(
SnapToGeometry.KEY_NORTH_ANCHOR);
highlightGuide(value, ColorConstants.blue, 1);
value = (Integer) req.getExtendedData().get(
SnapToGeometry.KEY_EAST_ANCHOR);
highlightGuide(value, ColorConstants.blue, 2);
value = (Integer) req.getExtendedData().get(
SnapToGeometry.KEY_SOUTH_ANCHOR);
highlightGuide(value, ColorConstants.blue, 3);
value = (Integer) req.getExtendedData().get(
SnapToGuides.KEY_VERTICAL_GUIDE);
highlightGuide(value, ColorConstants.blue, 4);
value = (Integer) req.getExtendedData().get(
SnapToGuides.KEY_HORIZONTAL_GUIDE);
highlightGuide(value, ColorConstants.blue, 5);
}
}
示例15: getAdapter
import org.eclipse.gef.SnapToGeometry; //导入依赖的package包/类
public Object getAdapter(Class adapter) {
if (adapter == SnapToHelper.class) {
List<SnapToHelper> snapStrategies = new ArrayList<SnapToHelper>();
Boolean val = (Boolean)getViewer().getProperty(RulerProvider.PROPERTY_RULER_VISIBILITY);
/*if (val != null && val.booleanValue())*/
//snapStrategies.add(new SnapToGuides((GraphicalEditPart) this.getParent()));
val = (Boolean)getViewer().getProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED);
//if (val != null && val.booleanValue())
snapStrategies.add(new SnapToGeometry(this){
@Override
protected List generateSnapPartsList(List exclusions) {
List children = super.generateSnapPartsList(exclusions);
children.add(container);//add snapToParent edges behaviour
return children;
}
});
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);
}