• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PrecisionPoint类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.draw2d.geometry.PrecisionPoint的典型用法代码示例。如果您正苦于以下问题:Java PrecisionPoint类的具体用法?Java PrecisionPoint怎么用?Java PrecisionPoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PrecisionPoint类属于org.eclipse.draw2d.geometry包,在下文中一共展示了PrecisionPoint类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: setConnectionAnchorsTest

import org.eclipse.draw2d.geometry.PrecisionPoint; //导入依赖的package包/类
/**
 * Test for setConnectionAnchors
 */
@Test
public void setConnectionAnchorsTest() {
	Pair<String, Class<?>> A = new Pair<String, Class<?>>("ClassA",
			org.eclipse.uml2.uml.Class.class);
	Pair<String, Class<?>> B = new Pair<String, Class<?>>("ClassB",
			org.eclipse.uml2.uml.Class.class);

	List<Pair<String, Class<?>>> objects = Arrays.asList(A, B);
	List<Pair<Pair<String, Class<?>>, Pair<String, Class<?>>>> associations = Arrays
			.asList(new Pair<Pair<String, Class<?>>, Pair<String, Class<?>>>(
					A, B));

	init(objects, associations);
	@SuppressWarnings("unchecked")
	List<EditPart> eps = getDiagramEditPart().getChildren();
	ClassEditPart classAEp = (ClassEditPart) eps.get(0);
	ClassEditPart classBEp = (ClassEditPart) eps.get(1);

	@SuppressWarnings("unchecked")
	List<ConnectionEditPart> conns = classBEp.getSourceConnections();
	ConnectionEditPart assoc = conns.get(0);
	DiagramElementsModifier.setConnectionAnchors(assoc, "(1, 0.5)",
			"(0, 0.5)");

	ConnectionAnchor source = classAEp.getSourceConnectionAnchor(assoc);
	ConnectionAnchor target = classBEp.getTargetConnectionAnchor(assoc);
	Point sourceReferencePoint = ((SlidableAnchor) source)
			.getReferencePoint();
	Point targetReferencePoint = ((SlidableAnchor) target)
			.getReferencePoint();
	PrecisionPoint sourceAnchor = SlidableAnchor.getAnchorRelativeLocation(
			sourceReferencePoint, source.getOwner().getBounds());
	PrecisionPoint targetAnchor = SlidableAnchor.getAnchorRelativeLocation(
			targetReferencePoint, target.getOwner().getBounds());

	Assert.assertEquals(new PrecisionPoint(1, 0.5), sourceAnchor);
	Assert.assertEquals(new PrecisionPoint(0, 0.5), targetAnchor);
}
 
开发者ID:ELTE-Soft,项目名称:txtUML,代码行数:42,代码来源:DiagramElementsModifierTest.java


示例17: updatePointList

import org.eclipse.draw2d.geometry.PrecisionPoint; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void updatePointList() throws ProfileUpdatedException {
	final LineFigure figure = (LineFigure)getFigure();
	Profile profile = getModel().getProfile();
	PrecisionPointList pointList = null;
	if (profile != null) {
		// SPF-9109 Removed boolean check of isNumeric value that is
		// returned from createPrecisionPoints(pointList, profile). We will
		// go ahead and plot all data from the pointList.
		pointList = createPrecisionPoints(profile);
		if (pointList.size() > 0) {
			PrecisionPoint first_pt = (PrecisionPoint) pointList.getFirstPoint();
			pointList.insertPoint(new PrecisionPoint(0, first_pt.preciseY()), 0);
			
			PrecisionPoint last_pt = (PrecisionPoint) pointList.getLastPoint();
			pointList.addPrecisionPoint(figure.getParent().getBounds().width, last_pt.preciseY());
		}
	} else {
		pointList = new PrecisionPointList();
	}
	final PrecisionPointList list;
	if(profile!=null && 
			(INTERPOLATION.INSTANTANEOUS == profile.getInterpolation())) {
		// Instantaneous, no need to strip midpoints
		list = new PrecisionPointList(pointList);
	}
	else {
		list = stripRedundantMidpoints(pointList);
	}
	GEFUtils.runInDisplayThread(this, new Runnable() {
		@Override
		public void run() {
			figure.setNormalizedPointList(list);
		}
	});
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:38,代码来源:LineDataEditPart.java


示例18: addPoint

import org.eclipse.draw2d.geometry.PrecisionPoint; //导入依赖的package包/类
@Override
public void addPoint(Point p) {
	if (p instanceof PrecisionPoint) {
		PrecisionPoint precisionPt = (PrecisionPoint)p;
		addPrecisionPoint(precisionPt.preciseX(), precisionPt.preciseY());
	} else {
		addPrecisionPoint(p.preciseX(), p.preciseY());
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:10,代码来源:PrecisionPointList.java


示例19: removePoint

import org.eclipse.draw2d.geometry.PrecisionPoint; //导入依赖的package包/类
@Override
public Point removePoint(int index) {
	bounds = null;
	if (index < 0 || index >= size)
	    throw new IndexOutOfBoundsException(
	    	"Index: " + index + //$NON-NLS-1$
	    	", Size: " + size); //$NON-NLS-1$
		
	index *= 2;
	PrecisionPoint pt = new PrecisionPoint(points[index], points[index + 1]);
	if (index != size * 2 - 2)
		System.arraycopy(points, index + 2, points, index, size * 2 - index - 2);
	size--;
	return pt;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:16,代码来源:PrecisionPointList.java


示例20: getBorderPoint

import org.eclipse.draw2d.geometry.PrecisionPoint; //导入依赖的package包/类
@Override
public Point getBorderPoint(Point reference) {
	// 得到owner矩形,转换为绝对坐标
	Rectangle r = Rectangle.SINGLETON;
	r.setBounds(getOwner().getBounds());
	getOwner().translateToAbsolute(r);
	
	// 根据角度,计算锚点相对于owner中心点的偏移
	double dx = 0.0, dy = 0.0;
	double tan = Math.atan2(r.height, r.width);
	if(angle >= -tan && angle <= tan) {
		dx = r.width >> 1;
		dy = dx * Math.tan(angle);
	} else if(angle >= tan && angle <= Math.PI - tan) {
		dy = r.height >> 1;
		dx = dy / Math.tan(angle);
	} else if(angle <= -tan && angle >= tan - Math.PI) {
		dy = -(r.height >> 1);
		dx = dy / Math.tan(angle);
	} else {
		dx = -(r.width >> 1);
		dy = dx * Math.tan(angle);
	}

	// 得到长方形中心点,加上偏移,得到最终锚点坐标
	PrecisionPoint pp = new PrecisionPoint(r.getCenter());	
	pp.translate((int)dx, (int)dy);
	return new Point(pp);	
}
 
开发者ID:winture,项目名称:wt-studio,代码行数:30,代码来源:RectangleBorderAnchor.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FileIterator类代码示例发布时间:2022-05-22
下一篇:
Java PIHandler类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap