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


Java PrecisionPoint类代码示例

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

}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:25,代码来源:AdjustIdentityAnchorCommand.java

示例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);
	}
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:24,代码来源:BandResizeTracker.java

示例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();
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:24,代码来源:LineFigure.java

示例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;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:19,代码来源:PrecisionPointList.java

示例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++;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:27,代码来源:PrecisionPointList.java

示例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;
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:18,代码来源:PrecisionPointList.java

示例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);
}
 
开发者ID:ghillairet,项目名称:gef-gwt,代码行数:22,代码来源:DragEditPartsTracker.java

示例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);
	}
}
 
开发者ID:ghillairet,项目名称:gef-gwt,代码行数:25,代码来源:DragEditPartsTracker.java

示例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()));
}
 
开发者ID:ghillairet,项目名称:gef-gwt,代码行数:22,代码来源:RelativeBendpoint.java

示例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;
}
 
开发者ID:aktion-hip,项目名称:relations,代码行数:27,代码来源:DefaultBrowserPart.java

示例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 );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:33,代码来源:LineController.java

示例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 );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:24,代码来源:LineController.java

示例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 );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:33,代码来源:PolygonController.java

示例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)
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:11,代码来源:AdjustIdentityAnchorCommand.java

示例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;
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:8,代码来源:FixedConnectionAnchor.java


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