本文整理了Java中com.mxgraph.view.mxGraph.snap()
方法的一些代码示例,展示了mxGraph.snap()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。mxGraph.snap()
方法的具体详情如下:
包路径:com.mxgraph.view.mxGraph
类名称:mxGraph
方法名:snap
[英]Snaps the given numeric value to the grid if is true.
[中]如果为true,则将给定的数值捕捉到网格。
代码示例来源:origin: org.tinyjee.jgraphx/jgraphx
/**
* Returns an mxPoint representing the given event in the unscaled,
* non-translated coordinate space and applies the grid.
*/
public mxPoint getPointForEvent(MouseEvent e, boolean addOffset)
{
double s = graph.getView().getScale();
mxPoint tr = graph.getView().getTranslate();
double off = (addOffset) ? graph.getGridSize() / 2 : 0;
double x = graph.snap(e.getX() / s - tr.getX() - off);
double y = graph.snap(e.getY() / s - tr.getY() - off);
return new mxPoint(x, y);
}
代码示例来源:origin: com.github.vlsi.mxgraph/jgraphx
/**
* Returns an mxPoint representing the given event in the unscaled,
* non-translated coordinate space and applies the grid.
*/
public mxPoint getPointForEvent(MouseEvent e, boolean addOffset)
{
double s = graph.getView().getScale();
mxPoint tr = graph.getView().getTranslate();
double off = (addOffset) ? graph.getGridSize() / 2 : 0;
double x = graph.snap(e.getX() / s - tr.getX() - off);
double y = graph.snap(e.getY() / s - tr.getY() - off);
return new mxPoint(x, y);
}
代码示例来源:origin: com.github.vlsi.mxgraph/jgraphx
/**
*
*/
protected mxPoint transformScreenPoint(double x, double y)
{
mxGraph graph = graphComponent.getGraph();
mxPoint tr = graph.getView().getTranslate();
double scale = graph.getView().getScale();
return new mxPoint(graph.snap(x / scale - tr.getX()), graph.snap(y
/ scale - tr.getY()));
}
代码示例来源:origin: org.tinyjee.jgraphx/jgraphx
/**
*
*/
protected mxPoint transformScreenPoint(double x, double y)
{
mxGraph graph = graphComponent.getGraph();
mxPoint tr = graph.getView().getTranslate();
double scale = graph.getView().getScale();
return new mxPoint(graph.snap(x / scale - tr.getX()), graph.snap(y
/ scale - tr.getY()));
}
代码示例来源:origin: com.github.vlsi.mxgraph/jgraphx
dxg = graph.snap(dxg);
dyg = graph.snap(dyg);
代码示例来源:origin: org.tinyjee.jgraphx/jgraphx
dxg = graph.snap(dxg);
dyg = graph.snap(dyg);
代码示例来源:origin: com.github.vlsi.mxgraph/jgraphx
dx = graph.snap(dx);
dy = graph.snap(dy);
int x = (int) graph.snap(rect.x);
int y = (int) graph.snap(rect.y);
rect.width = (int) graph.snap(rect.width - x + rect.x);
rect.height = (int) graph.snap(rect.height - y + rect.y);
rect.x = x;
rect.y = y;
代码示例来源:origin: org.tinyjee.jgraphx/jgraphx
dx = graph.snap(dx);
dy = graph.snap(dy);
int x = (int) graph.snap(rect.x);
int y = (int) graph.snap(rect.y);
rect.width = (int) graph.snap(rect.width - x + rect.x);
rect.height = (int) graph.snap(rect.height - y + rect.y);
rect.x = x;
rect.y = y;
代码示例来源:origin: com.github.vlsi.mxgraph/jgraphx
/**
*
*/
public Object createTargetVertex(MouseEvent e, Object source)
{
mxGraph graph = graphComponent.getGraph();
Object clone = graph.cloneCells(new Object[] { source })[0];
mxIGraphModel model = graph.getModel();
mxGeometry geo = model.getGeometry(clone);
if (geo != null)
{
mxPoint point = graphComponent.getPointForEvent(e);
geo.setX(graph.snap(point.getX() - geo.getWidth() / 2));
geo.setY(graph.snap(point.getY() - geo.getHeight() / 2));
}
return clone;
}
代码示例来源:origin: org.tinyjee.jgraphx/jgraphx
/**
*
*/
public Object createTargetVertex(MouseEvent e, Object source)
{
mxGraph graph = graphComponent.getGraph();
Object clone = graph.cloneCells(new Object[] { source })[0];
mxIGraphModel model = graph.getModel();
mxGeometry geo = model.getGeometry(clone);
if (geo != null)
{
mxPoint point = graphComponent.getPointForEvent(e);
geo.setX(graph.snap(point.getX() - geo.getWidth() / 2));
geo.setY(graph.snap(point.getY() - geo.getHeight() / 2));
}
return clone;
}
代码示例来源:origin: org.tinyjee.jgraphx/jgraphx
/**
*
*/
public mxPoint snapScaledPoint(mxPoint pt, double dx, double dy)
{
if (pt != null)
{
double scale = graph.getView().getScale();
mxPoint trans = graph.getView().getTranslate();
pt.setX((graph.snap(pt.getX() / scale - trans.getX() + dx / scale) + trans
.getX()) * scale - dx);
pt.setY((graph.snap(pt.getY() / scale - trans.getY() + dy / scale) + trans
.getY()) * scale - dy);
}
return pt;
}
代码示例来源:origin: com.github.vlsi.mxgraph/jgraphx
/**
*
*/
public mxPoint snapScaledPoint(mxPoint pt, double dx, double dy)
{
if (pt != null)
{
double scale = graph.getView().getScale();
mxPoint trans = graph.getView().getTranslate();
pt.setX((graph.snap(pt.getX() / scale - trans.getX() + dx / scale) + trans
.getX()) * scale - dx);
pt.setY((graph.snap(pt.getY() / scale - trans.getY() + dy / scale) + trans
.getY()) * scale - dy);
}
return pt;
}
代码示例来源:origin: org.tinyjee.jgraphx/jgraphx
dx = graph.snap(dx / scale);
dy = graph.snap(dy / scale);
代码示例来源:origin: com.github.vlsi.mxgraph/jgraphx
dx = graph.snap(dx / scale);
dy = graph.snap(dy / scale);
代码示例来源:origin: org.tinyjee.jgraphx/jgraphx
dx = graph.snap(dx / scale) * scale;
dy = graph.snap(dy / scale) * scale;
代码示例来源:origin: com.github.vlsi.mxgraph/jgraphx
dx = graph.snap(dx / scale) * scale;
dy = graph.snap(dy / scale) * scale;
代码示例来源:origin: org.tinyjee.jgraphx/jgraphx
handler.setOffset(new Point((int) graph.snap(dx / scale),
(int) graph.snap(dy / scale)));
pt.translate(dx, dy);
代码示例来源:origin: com.github.vlsi.mxgraph/jgraphx
handler.setOffset(new Point((int) graph.snap(dx / scale),
(int) graph.snap(dy / scale)));
pt.translate(dx, dy);
代码示例来源:origin: com.github.vlsi.mxgraph/jgraphx
/**
*
* @param point
* @param gridEnabled
* @return Returns the scaled, translated and grid-aligned point.
*/
protected mxPoint convertPoint(mxPoint point, boolean gridEnabled)
{
mxGraph graph = graphComponent.getGraph();
double scale = graph.getView().getScale();
mxPoint trans = graph.getView().getTranslate();
double x = point.getX() / scale - trans.getX();
double y = point.getY() / scale - trans.getY();
if (gridEnabled)
{
x = graph.snap(x);
y = graph.snap(y);
}
point.setX(x - state.getOrigin().getX());
point.setY(y - state.getOrigin().getY());
return point;
}
代码示例来源:origin: org.tinyjee.jgraphx/jgraphx
/**
*
* @param point
* @param gridEnabled
* @return Returns the scaled, translated and grid-aligned point.
*/
protected mxPoint convertPoint(mxPoint point, boolean gridEnabled)
{
mxGraph graph = graphComponent.getGraph();
double scale = graph.getView().getScale();
mxPoint trans = graph.getView().getTranslate();
double x = point.getX() / scale - trans.getX();
double y = point.getY() / scale - trans.getY();
if (gridEnabled)
{
x = graph.snap(x);
y = graph.snap(y);
}
point.setX(x - state.getOrigin().getX());
point.setY(y - state.getOrigin().getY());
return point;
}
内容来源于网络,如有侵权,请联系作者删除!