本文整理汇总了Java中org.eclipse.gef.requests.CreateRequest.getSize方法的典型用法代码示例。如果您正苦于以下问题:Java CreateRequest.getSize方法的具体用法?Java CreateRequest.getSize怎么用?Java CreateRequest.getSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.gef.requests.CreateRequest
的用法示例。
在下文中一共展示了CreateRequest.getSize方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showTargetFeedback
import org.eclipse.gef.requests.CreateRequest; //导入方法依赖的package包/类
/**
* Factors feedback requests into two more specific methods.
*
* @see org.eclipse.gef.EditPolicy#showTargetFeedback(Request)
*/
public void showTargetFeedback(Request request) {
if (REQ_ADD.equals(request.getType())
|| REQ_CLONE.equals(request.getType())
|| REQ_MOVE.equals(request.getType())
|| REQ_RESIZE_CHILDREN.equals(request.getType())
|| REQ_CREATE.equals(request.getType()))
showLayoutTargetFeedback(request);
if (REQ_CREATE.equals(request.getType())) {
CreateRequest createReq = (CreateRequest) request;
if (createReq.getSize() != null) {
showSizeOnDropFeedback(createReq);
}
}
}
示例2: enforceConstraintsForSizeOnDropCreate
import org.eclipse.gef.requests.CreateRequest; //导入方法依赖的package包/类
/**
* Ensures size constraints (by default minimum and maximum) are respected
* by the given request. May be overwritten by clients to enforce additional
* constraints.
*
* @since 3.7
*/
protected void enforceConstraintsForSizeOnDropCreate(CreateRequest request) {
CreateRequest createRequest = (CreateRequest) getTargetRequest();
if (createRequest.getSize() != null) {
// ensure create request respects minimum and maximum size
// constraints
PrecisionRectangle constraint = new PrecisionRectangle(
createRequest.getLocation(), createRequest.getSize());
((GraphicalEditPart) getTargetEditPart()).getContentPane()
.translateToRelative(constraint);
constraint.setSize(Dimension.max(constraint.getSize(),
getMinimumSizeFor(createRequest)));
constraint.setSize(Dimension.min(constraint.getSize(),
getMaximumSizeFor(createRequest)));
((GraphicalEditPart) getTargetEditPart()).getContentPane()
.translateToAbsolute(constraint);
createRequest.setSize(constraint.getSize());
}
}
示例3: placeComponentOnCanvasByDoubleClickOnPalette
import org.eclipse.gef.requests.CreateRequest; //导入方法依赖的package包/类
private void placeComponentOnCanvasByDoubleClickOnPalette(
CreateRequest componentRequest) {
GraphicalViewer graphViewer = graphicalViewer;
ComponentCreateCommand createComponent = new ComponentCreateCommand(
(hydrograph.ui.graph.model.Component) componentRequest
.getNewObject(),
(Container) graphViewer.getContents().getModel(),
new Rectangle(componentRequest.getLocation(), componentRequest
.getSize()));
graphViewer.getEditDomain().getCommandStack().execute(createComponent);
}
示例4: getCreateCommand
import org.eclipse.gef.requests.CreateRequest; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected Command getCreateCommand(final CreateRequest request) {
final ERDiagramEditPart editPart = (ERDiagramEditPart) getHost();
final Point point = request.getLocation();
editPart.getFigure().translateToRelative(point);
final NodeElement element = (NodeElement) request.getNewObject();
final ERDiagram diagram = (ERDiagram) editPart.getModel();
Dimension size = request.getSize();
final List<NodeElement> enclosedElementList = new ArrayList<NodeElement>();
if (size != null) {
final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager();
final double zoom = zoomManager.getZoom();
size = new Dimension((int) (size.width / zoom), (int) (size.height / zoom));
for (final Object child : editPart.getChildren()) {
if (child instanceof NodeElementEditPart) {
final NodeElementEditPart nodeElementEditPart = (NodeElementEditPart) child;
final Rectangle bounds = nodeElementEditPart.getFigure().getBounds();
if (bounds.x > point.x && bounds.x + bounds.width < point.x + size.width && bounds.y > point.y && bounds.y + bounds.height < point.y + size.height) {
enclosedElementList.add((NodeElement) nodeElementEditPart.getModel());
}
}
}
}
return new CreateElementCommand(diagram, element, point.x, point.y, size, enclosedElementList);
}
示例5: getDropLocation
import org.eclipse.gef.requests.CreateRequest; //导入方法依赖的package包/类
protected Point getDropLocation(CreateRequest request) {
IFigure figure = getLayoutContainer();
Point where = request.getLocation().getCopy();
Dimension size = request.getSize();
figure.translateToRelative(where);
figure.translateFromParent(where);
where.translate(getLayoutOrigin().getNegated());
return where;
}
示例6: CreateCombinedFragmentNodeCommand
import org.eclipse.gef.requests.CreateRequest; //导入方法依赖的package包/类
/**
* @param editDomain
* @param parentNodeModel
* @param request
*/
public CreateCombinedFragmentNodeCommand(EditPart parentNodeEditPart, CreateRequest request, Rectangle createBounds) {
this.editPart = parentNodeEditPart;
this.parentNodeModel = (AbstractNode) editPart.getModel();
this.request = request;
this.createBounds = createBounds;
this.size = request.getSize();
}
示例7: getCreateCommand
import org.eclipse.gef.requests.CreateRequest; //导入方法依赖的package包/类
/**
* @see ContainerEditPolicy#getCreateCommand(org.eclipse.gef.requests.CreateRequest)
*/
protected Command getCreateCommand(CreateRequest request) {
Object newObject = request.getNewObject();
MFrom parent = null;
if (getHost() instanceof QueryEditPart) {
MSQLRoot mroot = ((QueryEditPart) getHost()).getModel();
parent = Util.getKeyword(mroot, MFrom.class);
}
if (getHost().getModel() instanceof MFrom)
parent = (MFrom) getHost().getModel();
if (parent != null)
if (newObject instanceof Collection<?>) {
Rectangle r = new Rectangle(10, 10, 100, 100);
if (request.getLocation() != null) {
r.setLocation(request.getLocation().getCopy());
GraphicalEditPart ep = (GraphicalEditPart) getHost();
if (getHost() instanceof QueryEditPart) {
r.translate(-20, -20);
} else {
Rectangle ca = ep.getFigure().getClientArea();
r.translate(-ca.x, -ca.y);
}
}
if (request.getSize() != null) {
r.width = request.getSize().width;
r.height = request.getSize().height;
}
return new AddTableCommand(parent, (Collection<MSqlTable>) newObject, r);
}
return null;
}
示例8: getCreateCommand
import org.eclipse.gef.requests.CreateRequest; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected Command getCreateCommand(CreateRequest request) {
ERDiagramEditPart editPart = (ERDiagramEditPart) this.getHost();
Point point = request.getLocation();
editPart.getFigure().translateToRelative(point);
NodeElement element = (NodeElement) request.getNewObject();
ERDiagram diagram = (ERDiagram) editPart.getModel();
Dimension size = request.getSize();
List<NodeElement> enclosedElementList = new ArrayList<NodeElement>();
if (size != null) {
ZoomManager zoomManager = ((ScalableFreeformRootEditPart) this
.getHost().getRoot()).getZoomManager();
double zoom = zoomManager.getZoom();
size = new Dimension((int) (size.width / zoom),
(int) (size.height / zoom));
for (Object child : editPart.getChildren()) {
if (child instanceof NodeElementEditPart) {
NodeElementEditPart nodeElementEditPart = (NodeElementEditPart) child;
Rectangle bounds = nodeElementEditPart.getFigure()
.getBounds();
if (bounds.x > point.x
&& bounds.x + bounds.width < point.x + size.width
&& bounds.y > point.y
&& bounds.y + bounds.height < point.y + size.height) {
enclosedElementList
.add((NodeElement) nodeElementEditPart
.getModel());
}
}
}
}
return new CreateElementCommand(diagram, element, point.x, point.y,
size, enclosedElementList);
}
示例9: getCreateCommand
import org.eclipse.gef.requests.CreateRequest; //导入方法依赖的package包/类
@Override
protected Command getCreateCommand(CreateRequest request) {
// #willanalyze what is this? by jflute
// if (getHost() instanceof ERModelEditPart) {
// ERModelEditPart editPart = (ERModelEditPart) this.getHost();
//
// Point point = request.getLocation();
// editPart.getFigure().translateToRelative(point);
//
// NodeElement element = (NodeElement) request.getNewObject();
// ERDiagram diagram = (ERDiagram) editPart.getModel();
//
// Dimension size = request.getSize();
// List<NodeElement> enclosedElementList = new ArrayList<NodeElement>();
//
// if (size != null) {
// ZoomManager zoomManager = ((ScalableFreeformRootEditPart) this
// .getHost().getRoot()).getZoomManager();
// double zoom = zoomManager.getZoom();
// size = new Dimension((int) (size.width / zoom),
// (int) (size.height / zoom));
//
// for (Object child : editPart.getChildren()) {
// if (child instanceof NodeElementEditPart) {
// NodeElementEditPart nodeElementEditPart = (NodeElementEditPart) child;
// Rectangle bounds = nodeElementEditPart.getFigure()
// .getBounds();
//
// if (bounds.x > point.x
// && bounds.x + bounds.width < point.x + size.width
// && bounds.y > point.y
// && bounds.y + bounds.height < point.y + size.height) {
// enclosedElementList
// .add((NodeElement) nodeElementEditPart
// .getModel());
// }
// }
// }
// }
// return new CreateElementCommand(diagram, element, point.x, point.y,
// size, enclosedElementList);
// }
final AbstractModelEditPart editPart = (AbstractModelEditPart) getHost();
final Point point = request.getLocation();
editPart.getFigure().translateToRelative(point);
final DiagramWalker walker = (DiagramWalker) request.getNewObject(); // e.g. table, note, group
final ERDiagram diagram = ERModelUtil.getDiagram(editPart);
Dimension size = request.getSize();
final List<DiagramWalker> enclosedElementList = new ArrayList<>();
if (size != null) {
final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager();
final double zoom = zoomManager.getZoom();
size = new Dimension((int) (size.width / zoom), (int) (size.height / zoom));
for (final Object child : editPart.getChildren()) {
if (child instanceof DiagramWalkerEditPart) {
final DiagramWalkerEditPart nodeElementEditPart = (DiagramWalkerEditPart) child;
final Rectangle bounds = nodeElementEditPart.getFigure().getBounds();
if (bounds.x > point.x && bounds.x + bounds.width < point.x + size.width
&& bounds.y > point.y && bounds.y + bounds.height < point.y + size.height) {
enclosedElementList.add((DiagramWalker) nodeElementEditPart.getModel());
}
}
}
}
return new CreateElementCommand(diagram, walker, point.x, point.y, size, enclosedElementList);
}