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


Java CellView.getBounds方法代码示例

本文整理汇总了Java中org.jgraph.graph.CellView.getBounds方法的典型用法代码示例。如果您正苦于以下问题:Java CellView.getBounds方法的具体用法?Java CellView.getBounds怎么用?Java CellView.getBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jgraph.graph.CellView的用法示例。


在下文中一共展示了CellView.getBounds方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRoots

import org.jgraph.graph.CellView; //导入方法依赖的package包/类
/**
 * Return all cells that intersect the given rectangle.
 */
public CellView[] getRoots(Rectangle clip) {
	java.util.List<CellView> result = new ArrayList<CellView>();
	CellView[] views = getRoots();
	Rectangle2D bounds;
	for (CellView view : views) {
		bounds = view.getBounds();
		if (bounds != null) {
			if (bounds.intersects(clip)) {
				result.add(view);
			}
		}
	}
	views = new CellView[result.size()];
	result.toArray(views);
	return views;
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:20,代码来源:JmtGraphLayoutCache.java

示例2: getEndPoint

import org.jgraph.graph.CellView; //导入方法依赖的package包/类
/** Returns the perimeter point where the end of this edge has to connect.
 * @param vertex the end vertex
 * @param source if {@code true}, we're computing this for the edge source,
 * otherwise for the edge target
 */
private Point2D getEndPoint(CellView vertex, boolean source) {
    JVertexView vertexView = (JVertexView) vertex;
    Point2D center = getCenterPoint(vertex);
    Point2D nextPoint = getNearestPoint(source);
    // adjust the centre and next point depending on the number of
    // parallel edges, as determined by the parameter rank
    Point2D adjustedCenter;
    Point2D adjustedNextPoint;
    int parRank = source ? getParRank() : -getParRank();
    if (parRank == 0) {
        adjustedCenter = center;
        adjustedNextPoint = nextPoint;
    } else {
        // direction of the next point
        double dx = nextPoint.getX() - center.getX();
        double dy = nextPoint.getY() - center.getY();
        // direction for the offset, perpendicular to the next point
        double offDirX = dy;
        double offDirY = -dx;
        double offDist = center.distance(nextPoint);
        // calculate vertex radius in the specified direction
        Rectangle2D bounds = vertex.getBounds();
        double offMax = vertexView.getCellVisuals()
            .getNodeShape()
            .getRadius(bounds, offDirX, offDirY);
        // calculate actual offset
        double offset =
            Math.signum(parRank) * Math.min(PAR_EDGES_DISTANCE * Math.abs(parRank), offMax);
        double offX = offset * offDirX / offDist;
        double offY = offset * offDirY / offDist;
        adjustedCenter = new Point2D.Double(center.getX() + offX, center.getY() + offY);
        adjustedNextPoint =
            new Point2D.Double(nextPoint.getX() + offX, nextPoint.getY() + offY);
    }
    return vertexView.getPerimeterPoint(this, adjustedCenter, adjustedNextPoint);
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:42,代码来源:JEdgeView.java

示例3: handleDrag

import org.jgraph.graph.CellView; //导入方法依赖的package包/类
@Override
public void handleDrag(MouseEvent e) {
	mediator.setIsReleased(false);
	mediator.autoscroll(e.getPoint());
	if (ml.getHandler() != null && ml.getHandler() == ml.getMarquee()) {
		ml.getMarquee().mouseDragged(e);
	} else if (ml.getHandler() == null && !mediator.isGraphEditing() && ml.getFocus() != null) {
		if (!mediator.isCellSelected(ml.getFocus().getCell())) {
			mediator.selectCellForEvent(ml.getFocus().getCell(), e);
			ml.setCell(null);
		}
		if (ml.getHandle() != null) {
			ml.getHandle().mousePressed(e);
		}
		ml.setHandler(ml.getHandle());
	}
	if (ml.getHandle() != null && ml.getHandler() == ml.getHandle()) {
		// BERTOLI MARCO - Added to avoid dragging of unselected elements (caused bugs)
		if (mediator.getGraph().getSelectionCells().length > 0) {
			ml.getHandle().mouseDragged(e);
			graphtmp = (JmtJGraph) mediator.getGraph();
			cells = graphtmp.getSelectionCells();
			Xmin = new Integer[cells.length];
			Ymin = new Integer[cells.length];
			//Xmax = new Integer[cells.length];
			//Ymax = new Integer[cells.length];
			if (cells.length > 0) {
				for (int i = 0; i < cells.length; i++) {
					if (cells[i] instanceof JmtCell) {
						Rectangle2D rett = GraphConstants.getBounds(((JmtCell) cells[i]).getAttributes());
						Xmin[i] = new Integer((int) rett.getMinX());
						Ymin[i] = new Integer((int) rett.getMinY());
						//Xmax[i] = new Integer((int) rett.getMaxX());
						//Ymax[i] = new Integer((int) rett.getMaxY());
						moved = true;
					}
					if (cells[i] instanceof BlockingRegion) {
						CellView groupview = (graphtmp.getGraphLayoutCache()).getMapping(cells[i], false);
						Rectangle2D rett2 = groupview.getBounds();
						if (rett2 != null) {
							Xmin[i] = new Integer((int) rett2.getMinX());
							Ymin[i] = new Integer((int) rett2.getMinY());
							//Xmax[i] = new Integer((int) rett2.getMaxX());
							//Ymax[i] = new Integer((int) rett2.getMaxY());
							moved = true;
						}
					}
				}
			}
		}
	}
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:53,代码来源:SelectState.java

示例4: handleDrag

import org.jgraph.graph.CellView; //导入方法依赖的package包/类
@Override
public void handleDrag(MouseEvent e) {

	mediator.setIsReleased(false);
	mediator.autoscroll(e.getPoint());
	if (ml.getHandler() != null && ml.getHandler() == ml.getMarquee()) {
		ml.getMarquee().mouseDragged(e);
	} else if (ml.getHandler() == null && !mediator.isGraphEditing() && ml.getFocus() != null) {
		if (!mediator.isCellSelected(ml.getFocus().getCell())) {
			mediator.selectCellForEvent(ml.getFocus().getCell(), e);
			ml.setCell(null);
		}
		if (ml.getHandle() != null) {
			ml.getHandle().mousePressed(e);
		}
		ml.setHandler(ml.getHandle());
	}
	if (ml.getHandle() != null && ml.getHandler() == ml.getHandle()) {
		// BERTOLI MARCO - Added to avoid dragging of unselected elements (caused bugs)
		if (mediator.getGraph().getSelectionCells().length > 0) {
			ml.getHandle().mouseDragged(e);
			Xmin = null;
			Ymin = null;
			Xmax = null;
			Ymax = null;
			graphtmp = (JmtJGraph) mediator.getGraph();
			cells = graphtmp.getSelectionCells();
			Xmin = new Integer[cells.length];
			Ymin = new Integer[cells.length];
			Xmax = new Integer[cells.length];
			Ymax = new Integer[cells.length];
			//System.out.println("Numero di cell  in drag: " + cells.length);
			if (cells.length > 0) {
				for (int i = 0; i < cells.length; i++) {
					if (cells[i] instanceof JmtCell) {
						Rectangle2D rett = GraphConstants.getBounds(((JmtCell) cells[i]).getAttributes());
						//                		rappresentano l angolo altro-sinistro di ogni cella selezionata
						Xmin[i] = new Integer((int) rett.getMinX());
						Ymin[i] = new Integer((int) rett.getMinY());
						Xmax[i] = new Integer((int) rett.getMaxX());
						Ymax[i] = new Integer((int) rett.getMaxY());
						moved = true;
					}
					if (cells[i] instanceof BlockingRegion) {
						CellView groupview = (graphtmp.getGraphLayoutCache()).getMapping(cells[i], false);
						Rectangle2D rett2 = groupview.getBounds();

						Object[] celgru = new Object[1];
						celgru[0] = cells[i];
						//celle presenti nel blocking region incluse port e regione

						//                			Object[] celless=graphtmp.getDescendants(celgru);
						//System.out.println("Numero di celle in gruppo: "+ celless.length);

						if (rett2 != null) {
							//System.out.println("Dentro DRAG mi restituisce un rettangolo se � di tipoBLockingRegion");
							Xmin[i] = new Integer((int) rett2.getMinX());
							Ymin[i] = new Integer((int) rett2.getMinY());
							//                        		Xmax[i]=new Integer((int) rett2.getMaxX());
							//                        		Ymax[i]=new Integer((int) rett2.getMaxY());
							//System.out.println("Valori: "+ X[i]+", "+Y[i]);
							moved = true;
						}

					}
				}
			}
		}
	}

}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:72,代码来源:SelectState.java


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