本文整理汇总了Java中org.eclipse.draw2d.RectangleFigure.setSize方法的典型用法代码示例。如果您正苦于以下问题:Java RectangleFigure.setSize方法的具体用法?Java RectangleFigure.setSize怎么用?Java RectangleFigure.setSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.draw2d.RectangleFigure
的用法示例。
在下文中一共展示了RectangleFigure.setSize方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: createRootTreeNode
import org.eclipse.draw2d.RectangleFigure; //导入方法依赖的package包/类
protected TreeNode createRootTreeNode(IFigure parent) {
final List<IFigure> rootFigures = getGraphRootFigures(parent);
if (rootFigures.size() > 1) {
// initializes a "virtual" root
// tree level (needed for correct size calculations)
RectangleFigure rootFigure = new RectangleFigure();
rootFigure.setPreferredSize(1, 1);
rootFigure.setSize(1, 1);
setConstraint(rootFigure, new Rectangle(0, 0, 0, 0));
TreeNode rootTreeNode = new TreeNode(null, rootFigure);
for (IFigure figure : rootFigures) {
rootTreeNode.children.add(new TreeNode(null, figure));
}
return rootTreeNode;
} else if (rootFigures.size() == 1) {
return new TreeNode(null, rootFigures.get(0));
}
return null;
}
示例3: SplitFigure
import org.eclipse.draw2d.RectangleFigure; //导入方法依赖的package包/类
public SplitFigure(int orientation) {
this.orientation = orientation;
setLayoutManager(new SplitFigureLayout());
dividerFigure = new RectangleFigure();
dividerFigure.setOutline(false);
dividerFigure.setBorder(new SimpleRaisedBorder());
switch(getOrientation()) {
case HORIZONTAL_SPLIT:
dividerFigure.setSize(5, 0);
dividerFigure.setPreferredSize(new Dimension(5, 0));
break;
case VERTICAL_SPLIT:
dividerFigure.setSize(0, 5);
dividerFigure.setPreferredSize(new Dimension(0, 5));
break;
}
add(dividerFigure, DIVIDER);
}
示例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: ForkNodeFigure
import org.eclipse.draw2d.RectangleFigure; //导入方法依赖的package包/类
/**
* ForkNodeFigure
*/
public ForkNodeFigure() {
rectangle = new RectangleFigure();
rectangle.setSize(width, height);
// rectangle.setBackgroundColor(FigureUtil.getFigureImage());
add(rectangle);
}
示例8: JoinNodeFigure
import org.eclipse.draw2d.RectangleFigure; //导入方法依赖的package包/类
/**
* JoinNodeFigure
*/
public JoinNodeFigure() {
rectangle = new RectangleFigure();
rectangle.setSize(width, height);
// rectangle.setBackgroundColor(ColorConstants.lightGray);
add(rectangle);
}
示例9: 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;
}
示例10: 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);
}
示例11: 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);
}
示例12: 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);
}
示例13: addTitle
import org.eclipse.draw2d.RectangleFigure; //导入方法依赖的package包/类
protected void addTitle(IFigure figure) {
Object model = getModel();
final int rowHeight = TimelineUtils.getRowElementHeight(TreeTimelineHeaderRowEditPart.this);
Figure title = new Figure();
ToolbarLayout layout = new ToolbarLayout(true);
layout.setMinorAlignment(OrderedLayout.ALIGN_CENTER);
title.setLayoutManager(layout);
layout.setSpacing(6);
int depth = getDepth();
TreeTimelineContentProvider cp = getTimelineTreeContentProvider();
ILabelProvider lp = getLabelProvider();
String labelText = lp != null ? lp.getText(model) : model + "";
Image labelImage = lp != null ? lp.getImage(model) : null;
{
levelFigure = new RectangleFigure();
levelFigure.setOutline(false);
levelFigure.setSize(depth*LEVEL_PADDING, rowHeight);
levelFigure.setOpaque(true);
title.add(levelFigure);
}
{
expansionButton = new ArrowButton(PositionConstants.EAST) {
@Override
protected void createTriangle() {
Triangle tri = new Triangle();
tri.setOutline(true);
tri.setBackgroundColor(ColorConstants.listForeground);
tri.setForegroundColor(ColorConstants.listForeground);
setContents(tri);
}
};
expansionButton.setBorder(null);
expansionButton.setOpaque(true);
expansionButton.setPreferredSize(rowHeight,rowHeight);
expansionButton.setForegroundColor(ColorConstants.black);
expansionButton.setVisible(cp != null && cp.hasChildren(model));
expansionButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
toggleExpanded();
}
});
title.add(expansionButton);
}
{
titleLabel = new Label();
titleLabel.setTextAlignment(PositionConstants.CENTER);
titleLabel.setText(labelText);
if (labelImage != null) {
titleLabel.setIcon(labelImage);
}
titleLabel.setOpaque(true);
title.add(titleLabel);
refreshTitleLabelFont();
}
figure.add(title);
}