本文整理汇总了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;
}
示例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());
}
示例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);
}
示例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);
}
});
}
示例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));
}
}
示例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));
}
}
}
示例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);
}
}
示例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);
}
示例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()));
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}