本文整理汇总了Java中org.eclipse.draw2d.IFigure.add方法的典型用法代码示例。如果您正苦于以下问题:Java IFigure.add方法的具体用法?Java IFigure.add怎么用?Java IFigure.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.draw2d.IFigure
的用法示例。
在下文中一共展示了IFigure.add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connect
import org.eclipse.draw2d.IFigure; //导入方法依赖的package包/类
private void connect ( final IFigure figure, final IFigure source, final IFigure target )
{
final PolylineConnection c = new PolylineConnection ();
c.setSourceAnchor ( new ChopboxAnchor ( source ) );
c.setTargetAnchor ( new ChopboxAnchor ( target ) );
final PolygonDecoration dec = new PolygonDecoration ();
dec.setTemplate ( PolygonDecoration.TRIANGLE_TIP );
dec.setBackgroundColor ( ColorConstants.black );
c.setTargetDecoration ( dec );
figure.add ( c );
}
示例2: align
import org.eclipse.draw2d.IFigure; //导入方法依赖的package包/类
/**
* Aligns the selected {@link PossibleStepEditPart}.
*/
private void align() {
final IFigure figure = getFigure();
int existing = 0;
while (figure.getChildren().size() - existing - 2 >= 0
&& figure.getChildren().get(figure.getChildren().size() - existing - 2) instanceof PaddingFigure) {
++existing;
}
final int offset = ((BranchEditPart)getParent()).getModel().getTimelineWindow().getMaxSelectedIndex(
getModel().getBranch())
- getModel().getConnectedIndex();
if (existing < offset) {
for (int i = 0; i < offset - existing; ++i) {
figure.add(new PaddingFigure(), figure.getChildren().size() - 1);
}
} else if (existing > offset) {
for (int i = 1; i <= existing - offset; ++i) {
if (figure.getChildren().size() - 2 >= 0) {
final IFigure toRemoveFigure = (IFigure)figure.getChildren().get(
figure.getChildren().size() - 2);
if (toRemoveFigure instanceof PaddingFigure) {
figure.remove(toRemoveFigure);
}
}
}
}
}
示例3: createDiagram
import org.eclipse.draw2d.IFigure; //导入方法依赖的package包/类
private static void createDiagram(IFigure root, VarParser parser) {
VariableInfo sum = parser.locateVariable("sum", 24);
VariableInfo i = parser.locateVariable("i", 24);
MockArray array = new MockArray("int", "a", 1,2,3,4);
MockArrayIndex i1 = new MockArrayIndex(i.getName(), null, 1, IArrayIndexModel.Direction.FORWARD,-4);
// MockArrayIndex v = new MockArrayIndex(v, null, 0, IArrayIndexModel.Direction.FORWARD, 3); ;
array.addIndexVariable(i1);
ArrayPrimitiveFigure fig = new ArrayPrimitiveFigure(array);
fig.setSize(fig.getPreferredSize());
fig.setLocation(new Point(100, 100));
root.add(fig);
Button but = new Button("test");
but.setLocation(new Point(5, 5));
but.setSize(but.getPreferredSize());
but.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
try {
array.set(i1.getCurrentIndex(), 9);
i1.set(i1.getCurrentIndex() + 1);
i1.set(i1.getCurrentIndex() - 1);
}
catch(IndexOutOfBoundsException e) {
e.printStackTrace();
}
}
});
root.add(but);
}
示例4: createFigure
import org.eclipse.draw2d.IFigure; //导入方法依赖的package包/类
/**
* Returns the CustomFeedbackFigure.
*
* @return the CustomFeedbackFigure
*/
protected IFigure createFigure(GraphicalEditPart part, IFigure parent) {
IFigure child = getCustomFeedbackFigure(part.getModel());
if (parent != null)
parent.add(child);
Rectangle childBounds = part.getFigure().getBounds().getCopy();
IFigure walker = part.getFigure().getParent();
while (walker != ((GraphicalEditPart)part.getParent()).getFigure()) {
walker.translateToParent(childBounds);
walker = walker.getParent();
}
child.setBounds(childBounds);
Iterator i = part.getChildren().iterator();
while (i.hasNext())
createFigure((GraphicalEditPart)i.next(), child);
return child;
}
示例5: createDiagram
import org.eclipse.draw2d.IFigure; //导入方法依赖的package包/类
private static void createDiagram(IFigure root) {
// Array com iteradores
MockArray array = new MockArray("Integer", 1,2,3,4,5);
// MockVariable var = new MockVariable("int[]", "v", null, array);
MockReference ref = new MockReference("int[]", "v", array, false);
MockValue i1 = new MockValue("int", "i1", null, 0, false);
MockArrayIndex ii1 = new MockArrayIndex(i1, ref, Direction.NONE);
MockValue i2 = new MockValue("int", "i2", null, 1, false);
MockArrayIndex ii2 = new MockArrayIndex(i2, ref, Direction.FORWARD);
MockValue i3 = new MockValue("int", "i3", null, 5, false);
MockArrayIndex ii3 = new MockArrayIndex(i3, ref, Direction.FORWARD, new MyBound(-1, BoundType.OPEN, "-1"));
// array.addIndexVariable(ii1);
// array.addIndexVariable(ii2);
// array.addIndexVariable(ii3);
List<IArrayIndexModel> vars = new ArrayList<>();
vars.add(ii1);
vars.add(ii2);
ArrayReferenceFigure fig = new ArrayReferenceFigure(array);
fig.setLocation(new Point(100, 100));
root.add(fig);
// IllustrationBorder b = new IllustrationBorder(vars, fig);
// MarginBorder b = new MarginBorder(15);
// fig.setBorder(b);
// Array com lenght maior que o tamanho maximo da figura
MockArray array2 = new MockArray("int", 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25);
ArrayPrimitiveFigure fig2 = new ArrayPrimitiveFigure(array2);
fig2.setLocation(new Point(250, 300));
root.add(fig2);
// Array vazia
MockArray array3 = new MockArray("int");
ArrayPrimitiveFigure fig3 = new ArrayPrimitiveFigure(array3);
fig3.setLocation(new Point(400, 200));
root.add(fig3);
Connection c = new PolylineConnection();
ChopboxAnchor a = new ChopboxAnchor(fig);
ChopboxAnchor b = new ChopboxAnchor(fig2);
c.setSourceAnchor(a);
c.setTargetAnchor(b);
root.add(c);
Button but = new Button("test");
but.setLocation(new Point(5, 5));
but.setSize(but.getPreferredSize());
but.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
i1.set(ii1.getCurrentIndex()+1);
try {
if(ii3.getBound().getValue() != ii3.getCurrentIndex()) {
i3.set(ii3.getCurrentIndex() - 1);
}
array.set(ii3.getCurrentIndex(), 9);
}
catch(IndexOutOfBoundsException e) {
e.printStackTrace();
}
fig.repaint();
}
});
root.add(but);
}