本文整理汇总了Java中org.eclipse.draw2d.RectangleFigure.setLocation方法的典型用法代码示例。如果您正苦于以下问题:Java RectangleFigure.setLocation方法的具体用法?Java RectangleFigure.setLocation怎么用?Java RectangleFigure.setLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.draw2d.RectangleFigure
的用法示例。
在下文中一共展示了RectangleFigure.setLocation方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCenterPoint
import org.eclipse.draw2d.RectangleFigure; //导入方法依赖的package包/类
/**
* getCenterPoint
*
* @param nodeLabel
* @return Point
*/
private Point getCenterPoint(LabelNode nodeLabel) {
AbstractConnection abstractConnection = (AbstractConnection) nodeLabel.getOwner();
AbstractNode sourceNode = (AbstractNode) abstractConnection.getSource();
AbstractNode targetNode = (AbstractNode) abstractConnection.getTarget();
RectangleFigure sourceFigure = new RectangleFigure();
sourceFigure.setSize(sourceNode.getWidth(), sourceNode.getHeight());
sourceFigure.setLocation(new Point(sourceNode.getX(), sourceNode.getY()));
RectangleFigure targetFigure = new RectangleFigure();
targetFigure.setSize(targetNode.getWidth(), targetNode.getHeight());
targetFigure.setLocation(new Point(targetNode.getX(), targetNode.getY()));
ChopboxAnchor sourceAnchor = new ChopboxAnchor(sourceFigure);
ChopboxAnchor targetAnchor = new ChopboxAnchor(targetFigure);
Point source = new Point(sourceAnchor.getReferencePoint().x, sourceAnchor.getReferencePoint().y);
Point target = new Point(targetAnchor.getReferencePoint().x, targetAnchor.getReferencePoint().y);
Point centerPoint = new Point((source.x + target.x) / 2, (source.y + target.y) / 2);
return centerPoint;
}
示例2: updateDynamicDuplicate
import org.eclipse.draw2d.RectangleFigure; //导入方法依赖的package包/类
protected void updateDynamicDuplicate(int x, int y)
{
int dx = x - lastX;
int dy = y - lastY;
Iterator<RectangleFigure> frameFigs =
duplicatingDynamic.iterator();
while (frameFigs.hasNext()) {
RectangleFigure frameFig = frameFigs.next();
Point frameOrigin = frameFig.getLocation();
frameOrigin.x += dx;
frameOrigin.y += dy;
frameFig.setLocation(frameOrigin);
}
}
示例3: updateDynamicDuplicate
import org.eclipse.draw2d.RectangleFigure; //导入方法依赖的package包/类
protected void updateDynamicDuplicate(int x, int y)
{
double dx = x - lastX;
double dy = y - lastY;
Iterator<RectangleFigure> frameFigs = duplicatingDynamic.iterator();
while (frameFigs.hasNext()) {
RectangleFigure frameFig = frameFigs.next();
Point frameOrigin = frameFig.getLocation();
frameOrigin.x += dx;
frameOrigin.y += dy;
frameFig.setLocation(frameOrigin);
}
ui.performRepaintUpdates();
}
示例4: getCenterPoint
import org.eclipse.draw2d.RectangleFigure; //导入方法依赖的package包/类
/**
* getCenterPoint
*
* @param nodeLabel
* @return Point
*/
private Point getCenterPoint(LabelNode nodeLabel) {
AbstractConnection abstractConnection = (AbstractConnection) nodeLabel.getParent();
AbstractNode sourceNode = (AbstractNode) abstractConnection.getSource();
AbstractNode targetNode = (AbstractNode) abstractConnection.getTarget();
RectangleFigure sourceFigure = new RectangleFigure();
if (sourceNode != null) {
sourceFigure.setSize(sourceNode.getWidth(), sourceNode.getHeight());
sourceFigure.setLocation(new Point(sourceNode.getX(), sourceNode.getY()));
}
RectangleFigure targetFigure = new RectangleFigure();
if (targetNode != null) {
targetFigure.setSize(targetNode.getWidth(), targetNode.getHeight());
targetFigure.setLocation(new Point(targetNode.getX(), targetNode.getY()));
}
ChopboxAnchor sourceAnchor = new ChopboxAnchor(sourceFigure);
ChopboxAnchor targetAnchor = new ChopboxAnchor(targetFigure);
Point source = new Point(sourceAnchor.getReferencePoint().x, sourceAnchor.getReferencePoint().y);
Point target = new Point(targetAnchor.getReferencePoint().x, targetAnchor.getReferencePoint().y);
Point centerPoint = new Point((source.x + target.x) / 2, (source.y + target.y) / 2);
return centerPoint;
}
示例5: getTargetPoint
import org.eclipse.draw2d.RectangleFigure; //导入方法依赖的package包/类
/**
* getTargetPoint
*
* @param nodeLabel
* @return Point
*/
private Point getTargetPoint(LabelNode nodeLabel) {
AbstractConnection abstractConnection = (AbstractConnection) nodeLabel.getParent();
AbstractNode sourceNode = (AbstractNode) abstractConnection.getSource();
AbstractNode targetNode = (AbstractNode) abstractConnection.getTarget();
RectangleFigure sourceFigure = new RectangleFigure();
sourceFigure.setSize(sourceNode.getWidth(), sourceNode.getHeight());
sourceFigure.setLocation(new Point(sourceNode.getX(), sourceNode.getY()));
RectangleFigure targetFigure = new RectangleFigure();
targetFigure.setSize(targetNode.getWidth(), targetNode.getHeight());
targetFigure.setLocation(new Point(targetNode.getX(), targetNode.getY()));
ChopboxAnchor sourceAnchor = new ChopboxAnchor(sourceFigure);
ChopboxAnchor targetAnchor = new ChopboxAnchor(targetFigure);
Point sourceAnchorLocation = new Point();
Point targetAnchorLocation = new Point();
sourceAnchorLocation = sourceAnchor.getLocation(targetAnchor.getReferencePoint());
targetAnchorLocation = targetAnchor.getLocation(sourceAnchor.getReferencePoint());
// sourceAnchorLocation = sourceAnchor.getReferencePoint();
// targetAnchorLocation = targetAnchor.getReferencePoint();
Point source = new Point(sourceAnchorLocation.x, sourceAnchorLocation.y);
Point target = new Point(targetAnchorLocation.x, targetAnchorLocation.y);
if (nodeLabel.getType().equals(LabelType.SOURCE_ROLE) || nodeLabel.getType().equals(LabelType.SOURCE_MULTIPLEX)) {
return source;
} else if (nodeLabel.getType().equals(LabelType.TARGET_ROLE)
|| nodeLabel.getType().equals(LabelType.TARGET_MULTIPLEX)) {
return target;
} else {
return new Point((source.x + target.x) / 2, (source.y + target.y) / 2);
}
}
示例6: createRectangleFigure
import org.eclipse.draw2d.RectangleFigure; //导入方法依赖的package包/类
/**
* createRectangleFigure
*
* @param model
* @return RectangleFigure
*/
public static RectangleFigure createRectangleFigure(AbstractNode model) {
RectangleFigure figure = new RectangleFigure();
figure.setLocation(new Point(model.getX(), model.getY()));
figure.setSize(new Dimension(model.getWidth(), model.getHeight()));
return figure;
}
示例7: createFigure
import org.eclipse.draw2d.RectangleFigure; //导入方法依赖的package包/类
/**
* @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
*/
protected IFigure createFigure() {
NotationNode notationNode = (NotationNode) getModel();
RectangleFigure figure = new RectangleFigure();
figure.setBackgroundColor(ColorConstants.lightBlue);
figure.setForegroundColor(UiCorePlugin.getDefault().getColor(IConstantColorRegistry.Black));
figure.setLineWidth(2);
figure.setFill(true);
figure.setLocation(new Point(notationNode.getX(), notationNode.getY()));
figure.setSize(notationNode.getWidth(), notationNode.getHeight());
return figure;
}
示例8: setAssociationLabel
import org.eclipse.draw2d.RectangleFigure; //导入方法依赖的package包/类
/**
* setAssociationLabel
*
* @param connection void
*/
public static void setAssociationLabel(AbstractConnection connection) {
Association association = (Association) connection.getUmlModel();
AbstractConnection relation = (AbstractConnection) connection;
NotationNode source = (NotationNode) relation.getSource();
NotationNode target = (NotationNode) relation.getTarget();
if (((NotationNode) relation.getSource()).getUmlModel().equals(association.getMemberEnds().get(0).getType())) {
if (((NotationNode) relation.getSource()).getUmlModel() instanceof Actor) {
sourceProperty = association.getMemberEnds().get(0);
targetProperty = association.getMemberEnds().get(1);
} else {
sourceProperty = association.getMemberEnds().get(1);
targetProperty = association.getMemberEnds().get(0);
}
} else if (((NotationNode) relation.getSource()).getUmlModel().equals(association.getMemberEnds()
.get(1)
.getType())) {
if (((NotationNode) relation.getSource()).getUmlModel() instanceof Actor) {
sourceProperty = association.getMemberEnds().get(1);
targetProperty = association.getMemberEnds().get(0);
} else {
sourceProperty = association.getMemberEnds().get(0);
targetProperty = association.getMemberEnds().get(1);
}
}
RectangleFigure sourceFigure = new RectangleFigure();
sourceFigure.setLocation(new Point(source.getX(), source.getY()));
sourceFigure.setSize(source.getWidth(), source.getHeight());
RectangleFigure targetFigure = new RectangleFigure();
targetFigure.setLocation(new Point(target.getX(), target.getY()));
targetFigure.setSize(target.getWidth(), target.getHeight());
ChopboxAnchor sourceAnchor = new ChopboxAnchor(targetFigure);
ChopboxAnchor targetAnchor = new ChopboxAnchor(sourceFigure);
Point sourceAnchorLocation = new Point();
Point targetAnchorLocation = new Point();
sourceAnchorLocation = targetAnchor.getLocation(sourceAnchor.getReferencePoint());
targetAnchorLocation = sourceAnchor.getLocation(targetAnchor.getReferencePoint());
boolean hasSourceRole = false;
boolean hasTargetRole = false;
boolean hasSourceMultiplex = false;
boolean hasTargetMultiplex = false;
boolean hasNameLabel = false;
for (LabelNode label : relation.getLabels()) {
if (LabelType.SOURCE_ROLE.equals(label.getType())) {
hasSourceRole = true;
} else if (LabelType.TARGET_ROLE.equals(label.getType())) {
hasTargetRole = true;
} else if (LabelType.SOURCE_MULTIPLEX.equals(label.getType())) {
hasSourceMultiplex = true;
} else if (LabelType.TARGET_MULTIPLEX.equals(label.getType())) {
hasTargetMultiplex = true;
} else if (LabelType.COMPARTMENT.equals(label.getType())) {
hasNameLabel = true;
}
}
createSourceRoleLabel(relation, sourceAnchorLocation, hasSourceRole);
createTargetRoleLabel(relation, targetAnchorLocation, hasTargetRole);
createSourceMultiplexLabel(relation, sourceAnchorLocation, hasSourceMultiplex);
createTargetMultiplexLabel(relation, targetAnchorLocation, hasTargetMultiplex);
createConnectionNameLabel(association, relation, sourceAnchorLocation, targetAnchorLocation, hasNameLabel);
}
示例9: setAssociationLabel
import org.eclipse.draw2d.RectangleFigure; //导入方法依赖的package包/类
/**
* setAssociationLabel
*
* @param connection void
*/
private void setAssociationLabel(AbstractConnection connection) {
Association association = (Association) connection.getUmlModel();
AbstractConnection relation = (AbstractConnection) connection;
NotationNode source = (NotationNode) relation.getSource();
NotationNode target = (NotationNode) relation.getTarget();
if (((NotationNode) relation.getSource()).getUmlModel().equals(association.getMemberEnds().get(0).getType())) {
if (((NotationNode) relation.getSource()).getUmlModel() instanceof Actor) {
sourceProperty = association.getMemberEnds().get(0);
targetProperty = association.getMemberEnds().get(1);
} else {
sourceProperty = association.getMemberEnds().get(1);
targetProperty = association.getMemberEnds().get(0);
}
} else if (((NotationNode) relation.getSource()).getUmlModel().equals(association.getMemberEnds()
.get(1)
.getType())) {
if (((NotationNode) relation.getSource()).getUmlModel() instanceof Actor) {
sourceProperty = association.getMemberEnds().get(1);
targetProperty = association.getMemberEnds().get(0);
} else {
sourceProperty = association.getMemberEnds().get(0);
targetProperty = association.getMemberEnds().get(1);
}
}
RectangleFigure sourceFigure = new RectangleFigure();
sourceFigure.setLocation(new Point(source.getX(), source.getY()));
sourceFigure.setSize(source.getWidth(), source.getHeight());
RectangleFigure targetFigure = new RectangleFigure();
targetFigure.setLocation(new Point(target.getX(), target.getY()));
targetFigure.setSize(target.getWidth(), target.getHeight());
ChopboxAnchor sourceAnchor = new ChopboxAnchor(targetFigure);
ChopboxAnchor targetAnchor = new ChopboxAnchor(sourceFigure);
Point sourceAnchorLocation = new Point();
Point targetAnchorLocation = new Point();
sourceAnchorLocation = targetAnchor.getLocation(sourceAnchor.getReferencePoint());
targetAnchorLocation = sourceAnchor.getLocation(targetAnchor.getReferencePoint());
boolean hasSourceRole = false;
boolean hasTargetRole = false;
boolean hasSourceMultiplex = false;
boolean hasTargetMultiplex = false;
boolean hasNameLabel = false;
for (LabelNode label : relation.getLabels()) {
if (label.getType().equals(LabelType.SOURCE_ROLE)) {
hasSourceRole = true;
} else if (label.getType().equals(LabelType.TARGET_ROLE)) {
hasTargetRole = true;
} else if (label.getType().equals(LabelType.SOURCE_MULTIPLEX)) {
hasSourceMultiplex = true;
} else if (label.getType().equals(LabelType.TARGET_MULTIPLEX)) {
hasTargetMultiplex = true;
} else if (label.getType().equals(LabelType.LABEL)) {
hasNameLabel = true;
}
}
createSourceRoleLabel(relation, sourceAnchorLocation, hasSourceRole);
createTargetRoleLabel(relation, targetAnchorLocation, hasTargetRole);
createSourceMultiplexLabel(relation, sourceAnchorLocation, hasSourceMultiplex);
createTargetMultiplexLabel(relation, targetAnchorLocation, hasTargetMultiplex);
createConnectionNameLabel(association, relation, sourceAnchorLocation, targetAnchorLocation, hasNameLabel);
}
示例10: execute
import org.eclipse.draw2d.RectangleFigure; //导入方法依赖的package包/类
/**
* @see org.eclipse.gef.commands.Command#execute()
*/
public void execute() {
connection.setSource(sourceNode);
connection.setTarget(targetNode);
RectangleFigure sourceFigure = new RectangleFigure();
sourceFigure.setLocation(new Point(sourceNode.getX(), sourceNode.getY()));
sourceFigure.setSize(sourceNode.getWidth(), sourceNode.getHeight());
ChopboxAnchor sourceAnchor = new ChopboxAnchor((IFigure) sourceFigure);
RectangleFigure targetFigure = new RectangleFigure();
targetFigure.setLocation(new Point(targetNode.getX(), targetNode.getY()));
targetFigure.setSize(targetNode.getWidth(), targetNode.getHeight());
ChopboxAnchor targetAnchor = new ChopboxAnchor((IFigure) targetFigure);
Dimension sourceDimension = UMLDiagramFactory.eINSTANCE.createDimension();
sourceDimension.setWidth(sourceAnchor.getLocation(targetAnchor.getReferencePoint()).x - sourceNode.getX());
sourceDimension.setHeight(sourceAnchor.getLocation(targetAnchor.getReferencePoint()).y - sourceNode.getY());
connection.setSourceAnchor(sourceDimension);
Dimension targetDimension = UMLDiagramFactory.eINSTANCE.createDimension();
targetDimension.setWidth(targetAnchor.getLocation(sourceAnchor.getReferencePoint()).x - targetNode.getX());
targetDimension.setHeight(targetAnchor.getLocation(sourceAnchor.getReferencePoint()).y - targetNode.getY());
connection.setTargetAnchor(targetDimension);
if (connection.getUmlModel() instanceof Association) {
if (!(connection.getSource().getUmlModel() instanceof UseCase
|| connection.getSource().getUmlModel() instanceof Actor
|| connection.getTarget().getUmlModel() instanceof UseCase || connection.getTarget().getUmlModel() instanceof Actor)) {
setAssociationLabel(connection);
} else {
setLabelNode(connection);
}
setSelfConnection();
}
else if (!((connection).getUmlModel() instanceof Generalization
|| (connection).getUmlModel() instanceof Message || (connection).getUmlModel() instanceof ControlFlow
|| (connection).getUmlModel() instanceof ObjectFlow || connection instanceof Attachement)) {
setLabelNode(connection);
}
if (parent instanceof Diagram) {
((Diagram) parent).getConnectionList().add(connection);
} else if (parent instanceof ContainerNode) {
((ContainerNode) parent).getConnectionList().add(connection);
}
DiagramUtil.attachSourceOfConnection(connection);
DiagramUtil.attachTargetOfConnection(connection);
}