@Override protected void paintFigure(Graphics graphics) { IFigure figure = new RectangleFigure(); ((RectangleFigure) figure).setXOR(true); ((RectangleFigure) figure).setFill(true); figure.setBackgroundColor(ghostFillColor); figure.setForegroundColor(ColorConstants.white); figure.setBounds(getBounds()); figure.paint(graphics); /*Image feedbackImage = new Image(Display.getCurrent(), ghostImageData); graphics.setAlpha(alpha); graphics.setClip(getBounds().getCopy()); graphics.drawImage(feedbackImage, 0, 0, ghostImageData.width, ghostImageData.height, getBounds().x, getBounds().y, getBounds().width, getBounds().height); feedbackImage.dispose();*/ }
@Override protected void showLayoutTargetFeedback(Request request) { eraseLayoutTargetFeedback(request); if (request instanceof ChangeBoundsRequest || (request instanceof CreateRequest && acceptCreate((CreateRequest) request))){ targetFeedback = new RectangleFigure(); Rectangle parentBounds = ((ElementEditPart)getHost()).getBounds(); translateToAbsolute(getContainerFigure(), parentBounds); Rectangle lineBounds = parentBounds.getCopy(); lineBounds.height = 4; lineBounds.y--; targetFeedback.setForegroundColor(ColorConstants.green); targetFeedback.setBackgroundColor(ColorConstants.green); if (isInsertAfter((DropRequest) request)){ lineBounds.y += parentBounds.height; } targetFeedback.setBounds(lineBounds); addFeedback(targetFeedback); } else if (request instanceof ChangeBoundsRequest){ } }
/** * 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; }
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; }
protected IFigure createDragSourceFeedbackFigure() { RectangleFigure r = new FeedbackFigure(); r.setOpaque(false); r.setAlpha(50); r.setBackgroundColor(ColorConstants.gray); r.setFill(false); r.setBorder(new LineBorder(ColorConstants.gray, 1)); addFeedback(r); return r; }
@Override protected IFigure createFigure() { RectangleFigure figure = new RectangleFigure(); figure.setBackgroundColor(BACKGROUND_COLOR); Color borderCol = Display.getCurrent().getSystemColor(SWT.COLOR_GRAY); Border figureBorder = new LineBorder(borderCol, 2); figure.setBorder(figureBorder); figure.setOutline(false); GridLayout layoutManager = new GridLayout(); // zero margin, in order to connect the dependent axes to the shared one layoutManager.marginHeight = 0; layoutManager.marginWidth = 0; figure.setLayoutManager(layoutManager); datasetsPane = new RectangleFigure(); datasetsPane.setOutline(false); final SimpleLoweredBorder datasetBorder = new SimpleLoweredBorder(3); datasetsPane.setBorder(datasetBorder); GridLayout datasetsPaneLayout = new GridLayout(); datasetsPane.setLayoutManager(datasetsPaneLayout); figure.add(datasetsPane); arrowFigure = new ArrowFigure(false); figure.add(arrowFigure); axisNameLabel = new AxisNameFigure(this); figure.add(axisNameLabel); return figure; }
@Override protected IFigure createFigure() { final RectangleFigure figure = new RectangleFigure(); figure.setOutline(false); final Color borderCol = Display.getCurrent().getSystemColor(SWT.COLOR_GRAY); final Border figureBorder = new LineBorder(borderCol, 2); figure.setBorder(figureBorder); figure.setLayoutManager(new GridLayout()); nameLabel = new DirectionalLabel(Activator.FONT_8); final ChartPaneEditPart.AxisLandingPad pad = (ChartPaneEditPart.AxisLandingPad) getModel(); nameLabel.setText(pad.pos == ChartPanePosition.MIN ? "Min Axis" : "Max Axis"); figure.add(nameLabel); figure.getLayoutManager().setConstraint(nameLabel, new GridData( GridData.FILL, GridData.FILL, true, true)); return figure; }
@Override protected IFigure createFigure() { RectangleFigure rectangle = new RectangleFigure(); rectangle.setOutline(false); GridLayout gridLayout = new GridLayout(); gridLayout.marginHeight = 0; gridLayout.marginWidth = 0; rectangle.setLayoutManager(gridLayout); arrowFigure = new ArrowFigure(true); rectangle.add(arrowFigure); // and the text label axisNameLabel = new DirectionalIconLabel(StackedchartsImages.getImage( StackedchartsImages.DESC_AXIS)); axisNameLabel.getLabel().setTextAlignment(PositionConstants.TOP); rectangle.add(axisNameLabel); return rectangle; }
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); }
public DepartmentNodeFigure() { ToolbarLayout layout= new ToolbarLayout(); setLayoutManager(layout); label = new Label(); label.setLabelAlignment(PositionConstants.LEFT); label.setForegroundColor(ColorConstants.blue); label.setIcon(Activator.getDefault().getImageRegistry().get(Activator.STATE_MACHINE)); label.setPreferredSize(700, 50); label.setBorder(new MarginBorder(TOP_LEVEL_SPACE)); add(label); Figure line = new RectangleFigure(); line.setBackgroundColor(ColorConstants.lightGray); line.setForegroundColor(ColorConstants.lightGray); line.setPreferredSize(700, 1); add(line); figure = new Figure(); figure.setLayoutManager(new XYLayout()); add(figure); setBorder(new LineBorder(ColorConstants.lightGray, 1)); }
/** * Adjust the underline figure to the proper size and position of the text. * This is needed for that the figure looks like a hyperlink to signal that * the figure is clickable. * * @param inUnderline * RectangleFigure the figure to adjust. * @param inLabel * Label the label containing the text to underline, used for * calculating the underline's width. * @param inFont * Font the font to adjust the underline for, used for * calculating the underline's y position. */ private void adjustUnderline(final RectangleFigure inUnderline, final Label inLabel, final Font inFont) { int lWidth = inLabel.getPreferredSize(LABEL_WIDTH, RelationsConstants.ITEM_HEIGHT).width; if (lWidth >= LABEL_WIDTH) { lWidth -= 5; } // y position is calculated from the figures y position final int yPosFigure = getBounds().y; final int yPos = (int) (Math .round((double) (inFont.getFontData()[0].getHeight() + RelationsConstants.ITEM_HEIGHT) / 2)) + (yPosFigure == 0 ? 1 : yPosFigure + 2); // x position is taken from the underline's old x position, width is // adjusted to the label width final Rectangle lUnderlineBounds = new Rectangle(inUnderline.getBounds().x, yPos, lWidth, 1); inUnderline.setBounds(lUnderlineBounds); }
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); } }
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(); }
public PickerFigure() { super.setMargin(10); selection = new RectangleFigure(); selection.setAlpha(50); selection.setBackgroundColor(ColorConstants.blue); //setLayoutManager(new PickerFigureLayout()); }
/** * 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; }
/** * 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); } }
/** * PackageFigure * @param isDangling */ public PackageFigure(boolean isDangling) { setDangling(isDangling); setLayoutManager(new StackLayout() { @SuppressWarnings("unchecked") public void layout(IFigure figure) { Rectangle rectangle = figure.getClientArea(); List children = figure.getChildren(); IFigure child; org.eclipse.draw2d.geometry.Dimension dimension; int sizeValue = children.size(); for (int i = 0; i < children.size(); i++) { if (!(children.get(i) instanceof RectangleFigure)) { child = (IFigure) children.get(i); dimension = child.getPreferredSize(rectangle.width, rectangle.height); dimension.width = Math.min(dimension.width, rectangle.width); dimension.height = Math.min(dimension.height, rectangle.height); Rectangle childRect = new Rectangle(rectangle.x + (rectangle.width - dimension.width) / 2, rectangle.y + (rectangle.height - dimension.height) / 2 + (int) (i * dimension.height) - (sizeValue * 3), dimension.width, dimension.height); child.setBounds(childRect); } } } }); setOpaque(true); }
/** * DeleteSignFigure * @param string */ public DeleteSignFigure(String string) { setBorder(new LineBorder(ColorConstants.black)); setLayoutManager(new StackLayout() { @SuppressWarnings("unchecked") public void layout(IFigure figure) { Rectangle rectangle = figure.getClientArea(); List children = figure.getChildren(); IFigure child; org.eclipse.draw2d.geometry.Dimension dimension; int sizeValue = children.size(); for (int i = 0; i < children.size(); i++) { if (!(children.get(i) instanceof RectangleFigure)) { child = (IFigure) children.get(i); dimension = child.getPreferredSize(rectangle.width, rectangle.height); dimension.width = Math.min(dimension.width, rectangle.width); dimension.height = Math.min(dimension.height, rectangle.height); Rectangle childRect = new Rectangle(rectangle.x + (rectangle.width - dimension.width) / 2, rectangle.y + (rectangle.height - dimension.height) / 2 + (int) (i * dimension.height) - (sizeValue * 3), dimension.width, dimension.height); child.setBounds(childRect); } } } }); Label nameLabel = new Label(string); add(nameLabel); }
/** * 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; }
/** * ForkNodeFigure */ public ForkNodeFigure() { rectangle = new RectangleFigure(); rectangle.setSize(width, height); // rectangle.setBackgroundColor(FigureUtil.getFigureImage()); add(rectangle); }
/** * JoinNodeFigure */ public JoinNodeFigure() { rectangle = new RectangleFigure(); rectangle.setSize(width, height); // rectangle.setBackgroundColor(ColorConstants.lightGray); add(rectangle); }
/** * @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; }
/** * Creates the figure used for feedback. * * @return the new feedback figure */ protected IFigure createDragSourceFeedbackFigure() { // Use a ghost rectangle for feedback RectangleFigure r = new RectangleFigure(); FigureUtilities.makeGhostShape(r); r.setLineStyle(Graphics.LINE_DOT); r.setForegroundColor(ColorConstants.white); r.setBounds(getInitialFeedbackBounds()); addFeedback(r); return r; }
private void createContents() { nameLabel = new SyntaxColoringLabel(); GridData data = GridDataFactory.fillDefaults().grab(true, false).getData(); data.horizontalIndent = 5; nameLabel.setTextPlacement(PositionConstants.WEST); this.add(nameLabel, data); /** Compartment container **/ compartmentPane = new RectangleFigure(); compartmentPane.setOutline(false); compartmentPane.setLayoutManager(new StackLayout()); compartmentPane.setFill(false); this.add(compartmentPane, GridDataFactory.fillDefaults().grab(true, true).getData()); }
public StrokeWidget(Composite parent, int style) { super(parent, style); setLayout(new GridLayout()); square = new Canvas(this, SWT.NO_REDRAW_RESIZE | SWT.NO_BACKGROUND); lws = new J2DLightweightSystem(); lws.setControl(square); parentFigure = new RectangleFigure() { @Override public void paint(Graphics graphics) { if (stroke != null) { int offset = (int) stroke.getLineWidth(); int x = getBounds().x + offset; int y = getBounds().y + offset; int w = getBounds().width - 2 * offset - 10; int h = getBounds().height - 2 * offset - 10; graphics.setForegroundColor(ColorConstants.black); graphics.setBackgroundColor(ColorConstants.lightGray); Graphics2D g = ComponentFigure.getG2D(graphics); if (g != null) { g.setStroke(stroke); g.drawRect(x, y, w, h); } } } }; lws.setContents(parentFigure); Display.getCurrent().asyncExec(new Runnable() { public void run() { setTBounds(); } }); }
/** * Creates the figure used for feedback. * * @return the new feedback figure */ protected IFigure createDragSourceFeedbackFigure() { // Use a ghost rectangle for feedback RectangleFigure r = new ElementFeedbackFigure(); // FigureUtilities.makeGhostShape(r); r.setLineStyle(Graphics.LINE_DOT); r.setForegroundColor(ColorConstants.black); r.setBounds(getInitialFeedbackBounds().resize(-1, -1));// new Rectangle(ifb.x, ifb.y, ifb.width -100, // ifb.height)); addFeedback(r); return r; }
@Override protected IFigure createFigure() { RectangleFigure f = new RectangleFigure() { @Override protected void outlineShape(Graphics graphics) { } }; GridLayout lm = new GridLayout(2, true); lm.horizontalSpacing = 10; lm.verticalSpacing = 10; f.setLayoutManager(lm); f.setBounds(new Rectangle(10, 10, 600, 600)); f.setBorder(null); //Event to refresh the editor when a styles is added or removed getModel().getPropertyChangeSupport().addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { //To avoid to refresh removed elements if (getViewer() != null){ refresh(); } else { getModel().getPropertyChangeSupport().removePropertyChangeListener(this); } } }); return f; }
@Override protected IFigure createFigure() { final RectangleFigure figure = new RectangleFigure(); figure.setOutline(false); final GridLayout layoutManager = new GridLayout(); // zero margin, in order to connect the dependent axes to the shared one layoutManager.marginHeight = 0; layoutManager.marginWidth = 0; figure.setLayoutManager(layoutManager); return figure; }
@Override protected IFigure createFigure() { RectangleFigure rectangle = new RectangleFigure(); rectangle.setOutline(false); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; layout.horizontalSpacing = 10; layout.verticalSpacing = 10; rectangle.setLayoutManager(layout); rectangle.setBackgroundColor(Display.getDefault().getSystemColor( SWT.COLOR_WIDGET_BACKGROUND)); return rectangle; }
@Override protected IFigure createFigure() { RectangleFigure rectangle = new RectangleFigure(); rectangle.setOutline(false); GridLayout gridLayout = new GridLayout(); gridLayout.marginHeight = 10; gridLayout.marginWidth = 10; rectangle.setLayoutManager(gridLayout); rectangle.setBackgroundColor(Display.getDefault().getSystemColor( SWT.COLOR_WIDGET_BACKGROUND)); return rectangle; }
@Override protected IFigure createDragSourceFeedbackFigure() { // Use a ghost rectangle for feedback RectangleFigure r = new RectangleFigure(); r.setFill(false); r.setLineStyle(Graphics.LINE_DOT); r.setForegroundColor(ColorConstants.black); r.setLineWidth(1); r.setBounds(getInitialFeedbackBounds()); addFeedback(r); return r; }
protected void addBreak() { final RectangleFigure messageBreak = new RectangleFigure(); messageBreak.setBackgroundColor(ColorConstants.white); messageBreak.setOutline(false); final Rectangle bounds = Rectangle.SINGLETON; bounds.x = -1; bounds.y = -1; bounds.width = 4; bounds.height = 13; messageBreak.setBounds(bounds); messageBreak.setBorder(MessageFigure.MESSAGE_BREAK_BORDER); add(messageBreak, new MidpointLocator(this, 0)); }
public QueueNodeFigure() { ToolbarLayout layout= new ToolbarLayout(); layout.setHorizontal(false); layout.setSpacing(1); layout.setStretchMinorAxis(false); layout.setMinorAlignment(ToolbarLayout.ALIGN_TOPLEFT); setLayoutManager(layout); this.setBorder(new MarginBorder(5)); Label entry = new Label(); entry.setLabelAlignment(PositionConstants.CENTER); entry.setForegroundColor(ColorConstants.darkGreen); entry.setIcon(Activator.getDefault().getImageRegistry().get(Activator.QUEUE_NODE)); entry.setText("Queue"); add(entry); Figure line = new RectangleFigure(); line.setBackgroundColor(ColorConstants.lightGray); line.setForegroundColor(ColorConstants.lightGray); line.setPreferredSize(1000, 1); add(line); nameLabel = new Label(); nameLabel.setLabelAlignment(PositionConstants.CENTER); nameLabel.setForegroundColor(ColorConstants.darkGreen); add(nameLabel); }
public ActorNodeFigure() { ToolbarLayout layout= new ToolbarLayout(); layout.setHorizontal(false); layout.setSpacing(1); layout.setStretchMinorAxis(false); layout.setMinorAlignment(ToolbarLayout.ALIGN_TOPLEFT); setLayoutManager(layout); this.setBorder(new MarginBorder(5)); Label entry = new Label(); entry.setLabelAlignment(PositionConstants.CENTER); entry.setForegroundColor(ColorConstants.darkGreen); entry.setIcon(Activator.getDefault().getImageRegistry().get(Activator.ACTOR_NODE)); entry.setText("Actor"); add(entry); Figure line = new RectangleFigure(); line.setBackgroundColor(ColorConstants.lightGray); line.setForegroundColor(ColorConstants.lightGray); line.setPreferredSize(1000, 1); add(line); nameLabel = new Label(); nameLabel.setLabelAlignment(PositionConstants.CENTER); nameLabel.setForegroundColor(ColorConstants.darkGreen); add(nameLabel); }
public TopicNodeFigure() { ToolbarLayout layout= new ToolbarLayout(); layout.setHorizontal(false); layout.setSpacing(1); layout.setStretchMinorAxis(false); layout.setMinorAlignment(ToolbarLayout.ALIGN_TOPLEFT); setLayoutManager(layout); this.setBorder(new MarginBorder(5)); Label entry = new Label(); entry.setLabelAlignment(PositionConstants.CENTER); entry.setForegroundColor(ColorConstants.darkGreen); entry.setIcon(Activator.getDefault().getImageRegistry().get(Activator.TOPIC_NODE)); entry.setText("Topic"); add(entry); Figure line = new RectangleFigure(); line.setBackgroundColor(ColorConstants.lightGray); line.setForegroundColor(ColorConstants.lightGray); line.setPreferredSize(1000, 1); add(line); nameLabel = new Label(); nameLabel.setLabelAlignment(PositionConstants.CENTER); nameLabel.setForegroundColor(ColorConstants.darkGreen); add(nameLabel); }
/** * Return a IFigure depending on the instance of the current model element. * This allows this EditPart to be used for both sublasses of Shape. */ private IFigure createFigureForModel() { if (getModel() instanceof EllipticalShape) { return new Ellipse(); } else if (getModel() instanceof RectangularShape) { return new RectangleFigure(); } else { // if Shapes gets extended the conditions above must be updated throw new IllegalArgumentException(); } }
public HumanCircleFigure() { setLayoutManager(new XYLayout()); rectangle = new RectangleFigure(); add(rectangle); label = new Label(); add(label); }