本文整理汇总了Java中org.eclipse.draw2d.geometry.PrecisionPoint类的典型用法代码示例。如果您正苦于以下问题:Java PrecisionPoint类的具体用法?Java PrecisionPoint怎么用?Java PrecisionPoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PrecisionPoint类属于org.eclipse.draw2d.geometry包,在下文中一共展示了PrecisionPoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: adjustAnchors
import org.eclipse.draw2d.geometry.PrecisionPoint; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void adjustAnchors(EditPart editPart) {
if (editPart instanceof IGraphicalEditPart) {
View view = ((IGraphicalEditPart) editPart).getNotationView();
EList<Edge> targetEdges = view.getTargetEdges();
for (Edge edge : targetEdges) {
Anchor targetAnchor = edge.getTargetAnchor();
if (targetAnchor instanceof IdentityAnchor) {
PrecisionPoint anchorPoint = BaseSlidableAnchor.parseTerminalString(((IdentityAnchor) targetAnchor)
.getId());
IFigure figure = ((IGraphicalEditPart) editPart).getFigure();
Dimension sizeBefore = figure.getBounds().getSize();
float widthFactor = (float) (sizeBefore.width() + request.getSizeDelta().width())
/ (float) sizeBefore.width();
float heightFactor = (float) (sizeBefore.height() + request.getSizeDelta().height())
/ (float) sizeBefore.height();
PrecisionPoint newPoint = new PrecisionPoint(anchorPoint.preciseX() / widthFactor,
anchorPoint.preciseY() / heightFactor);
((IdentityAnchor) targetAnchor).setId(composeTerminalString(newPoint));
}
}
}
}
示例2: snapPoint
import org.eclipse.draw2d.geometry.PrecisionPoint; //导入依赖的package包/类
/**
* This method can be overridden by clients to customize the snapping behavior.
*
* @param request
* the <code>ChangeBoundsRequest</code> from which the move delta can be extracted and updated
* @since 3.4
*/
protected void snapPoint(ChangeBoundsRequest request) {
Point moveDelta = request.getMoveDelta();
if (editpart != null && getOperationSet().size() > 0)
snapToHelper = (SnapToHelper) editpart.getParent().getAdapter(SnapToHelper.class);
if (snapToHelper != null && !getCurrentInput().isModKeyDown(MODIFIER_NO_SNAPPING)) {
PrecisionRectangle baseRect = sourceRectangle.getPreciseCopy();
PrecisionRectangle jointRect = compoundSrcRect.getPreciseCopy();
baseRect.translate(moveDelta);
jointRect.translate(moveDelta);
PrecisionPoint preciseDelta = new PrecisionPoint(moveDelta);
snapToHelper.snapPoint(request, PositionConstants.HORIZONTAL | PositionConstants.VERTICAL,
new PrecisionRectangle[] { baseRect, jointRect }, preciseDelta);
request.setMoveDelta(preciseDelta);
}
}
示例3: setNormalizedPointList
import org.eclipse.draw2d.geometry.PrecisionPoint; //导入依赖的package包/类
public void setNormalizedPointList(PrecisionPointList norms) {
this.norms = norms;
// dimensions
Dimension parentSize = getParent().getSize();
int parentY = (int) (parentSize.height * ChartFigure.DESIGN_BOUNDARY_PERCENTAGE);
int parentHeight = (int) (parentSize.height - 2*parentSize.height*ChartFigure.DESIGN_BOUNDARY_PERCENTAGE);
PointList pointList = new PointList();
int length = norms.size();
int previous_x = Integer.MIN_VALUE;
int previous_y = Integer.MIN_VALUE;
for (int i=0; i<length; i++) {
PrecisionPoint pt = (PrecisionPoint) norms.getPoint(i);
int x = Math.max(0, (int)pt.preciseX());
int y = (int)((parentHeight * (1.0 - pt.preciseY())) + parentY);
if ((x != previous_x) || (y != previous_y)) {
pointList.addPoint(x, y);
previous_x = x;
previous_y = y;
}
}
setPoints(pointList);
intArray = pointList.toIntArray();
}
示例4: getPoint
import org.eclipse.draw2d.geometry.PrecisionPoint; //导入依赖的package包/类
@Override
public Point getPoint(Point p, int index) {
if (index < 0 || index >= size)
throw new IndexOutOfBoundsException(
"Index: " + index + //$NON-NLS-1$
", Size: " + size); //$NON-NLS-1$
index *= 2;
if (p instanceof PrecisionPoint) {
PrecisionPoint preciseP = (PrecisionPoint) p;
preciseP.setPreciseX(points[index]);
preciseP.setPreciseY(points[index + 1]);
// preciseP.updateInts(); done automatically from setPreciseX/Y
} else {
p.x = (int)Math.floor(points[index] + 0.000000001);
p.y = (int)Math.floor(points[index + 1] + 0.000000001);
}
return p;
}
示例5: insertPoint
import org.eclipse.draw2d.geometry.PrecisionPoint; //导入依赖的package包/类
@Override
public void insertPoint(Point p, int index) {
if (bounds != null && !bounds.contains(p))
bounds = null;
if (index > size || index < 0)
throw new IndexOutOfBoundsException(
"Index: " + index + //$NON-NLS-1$
", Size: " + size); //$NON-NLS-1$
index *= 2;
int length = points.length;
double old[] = points;
points = new double[length + 2];
System.arraycopy(old, 0, points, 0, index);
System.arraycopy(old, index, points, index + 2, length - index);
if (p instanceof PrecisionPoint) {
PrecisionPoint precisionPt = (PrecisionPoint)p;
points[index] = precisionPt.preciseX();
points[index + 1] = precisionPt.preciseY();
} else {
points[index] = p.x;
points[index + 1] = p.y;
}
size++;
}
示例6: setPoint
import org.eclipse.draw2d.geometry.PrecisionPoint; //导入依赖的package包/类
@Override
public void setPoint(Point pt, int index) {
if (index < 0 || index >= size)
throw new IndexOutOfBoundsException(
"Index: " + index + //$NON-NLS-1$
", Size: " + size); //$NON-NLS-1$
if (bounds != null && !bounds.contains(pt))
bounds = null;
if (pt instanceof PrecisionPoint) {
PrecisionPoint precisionPt = (PrecisionPoint)pt;
points[index * 2] = precisionPt.preciseX();
points[index * 2 + 1] = precisionPt.preciseY();
} else {
points[index * 2] = pt.x;
points[index * 2 + 1] = pt.y;
}
}
示例7: repairStartLocation
import org.eclipse.draw2d.geometry.PrecisionPoint; //导入依赖的package包/类
/**
* If auto scroll (also called auto expose) is being performed, the start
* location moves during the scroll. This method updates that location.
*/
protected void repairStartLocation() {
if (sourceRelativeStartPoint == null)
return;
IFigure figure = ((GraphicalEditPart) getSourceEditPart()).getFigure();
PrecisionPoint newStart = (PrecisionPoint) sourceRelativeStartPoint
.getCopy();
figure.translateToAbsolute(newStart);
Point delta = new Point(newStart.x - getStartLocation().x, newStart.y
- getStartLocation().y);
setStartLocation(newStart);
// sourceRectangle and compoundSrcRect need to be updated as well when
// auto-scrolling
if (sourceRectangle != null)
sourceRectangle.translate(delta);
if (compoundSrcRect != null)
compoundSrcRect.translate(delta);
}
示例8: snapPoint
import org.eclipse.draw2d.geometry.PrecisionPoint; //导入依赖的package包/类
/**
* This method can be overridden by clients to customize the snapping
* behavior.
*
* @param request
* the <code>ChangeBoundsRequest</code> from which the move delta
* can be extracted and updated
* @since 3.4
*/
protected void snapPoint(ChangeBoundsRequest request) {
Point moveDelta = request.getMoveDelta();
if (snapToHelper != null && request.isSnapToEnabled()) {
PrecisionRectangle baseRect = sourceRectangle.getPreciseCopy();
PrecisionRectangle jointRect = compoundSrcRect.getPreciseCopy();
baseRect.translate(moveDelta);
jointRect.translate(moveDelta);
PrecisionPoint preciseDelta = new PrecisionPoint(moveDelta);
snapToHelper.snapPoint(request, PositionConstants.HORIZONTAL
| PositionConstants.VERTICAL, new PrecisionRectangle[] {
baseRect, jointRect }, preciseDelta);
request.setMoveDelta(preciseDelta);
}
}
示例9: getLocation
import org.eclipse.draw2d.geometry.PrecisionPoint; //导入依赖的package包/类
/**
* Calculates and returns this Bendpoint's new location.
*
* @return This Bendpoint's new location
* @since 2.0
*/
public Point getLocation() {
PrecisionPoint a1 = new PrecisionPoint(getConnection()
.getSourceAnchor().getReferencePoint());
PrecisionPoint a2 = new PrecisionPoint(getConnection()
.getTargetAnchor().getReferencePoint());
getConnection().translateToRelative(a1);
getConnection().translateToRelative(a2);
return new PrecisionPoint(
(a1.preciseX() + d1.preciseWidth()) * (1.0 - weight) + weight
* (a2.preciseX() + d2.preciseWidth()),
(a1.preciseY() + d1.preciseHeight()) * (1.0 - weight) + weight
* (a2.preciseY() + d2.preciseHeight()));
}
示例10: setAroundCenter
import org.eclipse.draw2d.geometry.PrecisionPoint; //导入依赖的package包/类
/**
* In this relations browser, we want the related items to be displayed in
* concentric circles around the center of the browser window.
*/
@SuppressWarnings("unchecked")
private void setAroundCenter() {
final Map<IItemModel, GraphicalEditPart> lRegistry = viewer.getEditPartRegistry();
final org.eclipse.swt.graphics.Point lSize = getSize();
final PrecisionPoint lTranslate = new PrecisionPoint(lSize.x / 2 - (RelationsConstants.ITEM_WIDTH / 2),
(lSize.y / 2) - RelationsConstants.ITEM_HEIGHT);
moveFigure(lRegistry, model.getCenter(), new PrecisionPoint(0, 0), lTranslate);
final List<ItemAdapter> lRelated = model.getRelatedItems();
int lNumber = lRelated.size();
int lCount = 0;
int lOffset = 0;
final ItemPositionCalculator lCalculator = new ItemPositionCalculator(RelationsConstants.ITEM_WIDTH,
RelationsConstants.ITEM_HEIGHT, getRadius(++lCount), lNumber);
while (lCalculator.hasMore()) {
lOffset = setPositions(lRegistry, lCalculator.getPositions(), lOffset, lRelated, lTranslate);
lNumber -= lCalculator.getCount();
lCalculator.recalculate(getRadius(++lCount), lNumber);
}
setPositions(lRegistry, lCalculator.getPositions(), lOffset, lRelated, lTranslate);
oldSize = lSize;
}
示例11: LineController
import org.eclipse.draw2d.geometry.PrecisionPoint; //导入依赖的package包/类
public LineController ( final SymbolController controller, final Line element, final ResourceManager manager )
{
super ( controller, manager );
this.figure = new PolylineShape () {
@Override
public void addNotify ()
{
super.addNotify ();
start ();
}
@Override
public void removeNotify ()
{
stop ();
super.removeNotify ();
}
};
final PointList points = new PointList ();
for ( final Position pos : element.getPoints () )
{
final Point p = new PrecisionPoint ( pos.getX (), pos.getY () );
points.addPoint ( p );
}
setPoints ( points );
controller.addElement ( element, this );
applyCommon ( element );
}
示例12: setPointsString
import org.eclipse.draw2d.geometry.PrecisionPoint; //导入依赖的package包/类
/**
* Set points as string
* <p>
* <code>
* 1.5;2.5|1.5;2.5
* </code>
* </p>
*
* @param points
*/
public void setPointsString ( final String pointsString )
{
final PointList pointList = new PointList ();
final String[] points = pointsString.split ( "\\|" );
for ( final String point : points )
{
final String[] toks = point.split ( ";" );
final PrecisionPoint p = new PrecisionPoint ( Double.parseDouble ( toks[0] ), Double.parseDouble ( toks[1] ) );
pointList.addPoint ( p );
}
setPoints ( pointList );
}
示例13: PolygonController
import org.eclipse.draw2d.geometry.PrecisionPoint; //导入依赖的package包/类
public PolygonController ( final SymbolController controller, final Polygon element, final ResourceManager manager )
{
super ( controller, manager );
this.figure = new PolygonShape () {
@Override
public void addNotify ()
{
super.addNotify ();
start ();
}
@Override
public void removeNotify ()
{
stop ();
super.removeNotify ();
}
};
final PointList points = new PointList ();
for ( final Position pos : element.getPoints () )
{
final Point p = new PrecisionPoint ( pos.getX (), pos.getY () );
points.addPoint ( p );
}
setPoints ( points );
controller.addElement ( element, this );
applyCommon ( element );
}
示例14: composeTerminalString
import org.eclipse.draw2d.geometry.PrecisionPoint; //导入依赖的package包/类
protected String composeTerminalString(PrecisionPoint p) {
StringBuffer s = new StringBuffer(24);
s.append(TERMINAL_START_CHAR); // 1 char
s.append(p.preciseX()); // 10 chars
s.append(TERMINAL_DELIMITER_CHAR); // 1 char
s.append(p.preciseY()); // 10 chars
s.append(TERMINAL_END_CHAR); // 1 char
return s.toString(); // 24 chars max (+1 for safety, i.e. for string
// termination)
}
示例15: getLocation
import org.eclipse.draw2d.geometry.PrecisionPoint; //导入依赖的package包/类
public Point getLocation() {
Rectangle r = getOwner().getBounds();
Point p = new PrecisionPoint(r.x + r.width * xOffset, r.y + r.height
* yOffset);
getOwner().translateToAbsolute(p);
return p;
}