public void setSelection(boolean sel) { if (sel) { lblCnnName.setBorder(border); } else { lblCnnName.setBorder(null); } }
public AbstractLabeledFigure(Figure shape, Color borderColor, Color fillColor) { this.defaultBorderColor = borderColor; this.defaultFillColor = fillColor; setCornerDimensions(new Dimension(12, 12)); setFill(false); setBorder(new MarginBorder(1)); label = createLabel(); label.setBorder(new MarginBorder(1, 6, 1, 6)); label.setForegroundColor(ColorConstants.black); label.setOpaque(true); this.shape = shape; setLayoutManager(createFigureLayout()); doAddShape(shape); doAddLabel(label); setBorderColor(null); setFillColor(null); setMinimumSize(new Dimension(50, -1)); setMaximumSize(new Dimension(300, 100)); }
private IFigure getContents() { IFigure panel = new Panel(); BorderLayout lm = new BorderLayout(); panel.setLayoutManager(lm); arrowButton = new ArrowButton(direction); arrowButton.setCursor(Display.getCurrent().getSystemCursor(SWT.CURSOR_HAND)); arrowButton.setBackgroundColor(ColorConstants.white); Label lbl = new Label(lblText); lbl.setBackgroundColor(ColorConstants.black); lbl.setForegroundColor(ColorConstants.black); setTriangleColor(READY_COLOUR); Label imgLblFigure = new Label( TomoClientActivator.getDefault().getImageRegistry().get(ImageConstants.ICON_CTRL_BTN)); panel.setBackgroundColor(ColorConstants.white); panel.add(imgLblFigure); panel.setConstraint(imgLblFigure, BorderLayout.TOP); arrowButton.add(lbl); panel.add(arrowButton); panel.setConstraint(arrowButton, BorderLayout.CENTER); lbl.addMouseListener(mousePressListener); return panel; }
/** * Sets the name. * * @param name the new name */ @Override public void setName(String name) { text.setText(name); textFigure.setSize(width, 10); text.setSize(width, 10); text.setLocation(getLocation()); textFigure.setLocation(getLocation()); }
@Override protected IFigure createFigure() { Label l = (Label) super.createFigure(); l.setIcon( IntegrationImages.getImageWithBadge( IntegrationImages.TRANSFORMER, IntegrationImages.BADGE_SI_FILE)); return l; }
@Override public void relocate(CellEditor celleditor) { Text text = (Text) celleditor.getControl(); Point prefSize = text.computeSize(SWT.DEFAULT, SWT.DEFAULT); Rectangle rectangle = label.getTextBounds().getCopy(); label.translateToAbsolute(rectangle); text.setBounds(rectangle.x - 1, rectangle.y - 1, prefSize.x + 1, prefSize.y + 1); }
@Override protected IFigure createFigure() { Label l = (Label) super.createFigure(); l.setIcon( IntegrationImages.getImageWithBadge( IntegrationImages.INBOUND_ADAPTER, IntegrationImages.BADGE_SI_JPA)); return l; }
/** * Set the label that displays the text. * * @param textLabel the label to display the text, may be the same as the icon label or <code>null * </code> to ignore the text * @see #setIconLabel(Label) */ public void setTextLabel(Label textLabel) { this.textLabel = textLabel; textLabel.setFont(getFont()); if (text != null) { textLabel.setText(text); } }
/** * Instantiates a new node figure. * * @param name the name * @param width the weight */ public SimpleNodeFigure(Node node, int width, MouseListener mouseListener) { super(); this.node = node; LineBorder b = new LineBorder(); b.setColor(NodeUtil.FG_COLOR); setBorder(b); textFigure = new RectangleFigure(); text = new Label(getNodeName()); text.setForegroundColor(NodeUtil.FG_COLOR_DARK); setSize(width, 10); textFigure.add(text); hideButton = new RectangleFigure(); hideSymbol = new Label(getSymbol()); hideSymbol.setSize(10, 10); hideSymbol.setTextAlignment(PositionConstants.CENTER); hideSymbol.setFont(hideButtonFont); hideSymbol.setForegroundColor(NodeUtil.FG_COLOR_DARK); hideButton.add(hideSymbol); hideButton.setBackgroundColor(exitClor); hideButton.addMouseListener(mouseListener); hideButton.addMouseMotionListener( new MouseMotionListener() { @Override public void mouseMoved(MouseEvent me) {} @Override public void mouseHover(MouseEvent me) {} @Override public void mouseExited(MouseEvent me) { hideButton.setBackgroundColor(exitClor); } @Override public void mouseEntered(MouseEvent me) { hideButton.setBackgroundColor(entredClor); } @Override public void mouseDragged(MouseEvent me) {} }); hideButton.setSize(10, 10); setLayoutManager(new XYLayout()); add(textFigure); }
/** * Construct a new instance * * @param term the term containing the descriptor and possibly the visualization mode * @param parent the figure in which this figure is placed * @throws TermVisualizationException if visualization of the term has failed, e.g., if the query * failed. * @throws TermInstantiationException if a visualization object could not be instantiated */ public VisualTerm(Compound term, TermContext parent) throws TermVisualizationException, TermInstantiationException { context = parent; // Register this object with the content context.registerTermFigure(path, this); try { // The first argument is the descriptor, containing the path and additional information descriptor = (Compound) term.arg(1); if (!descriptor.name().equals("::")) System.err.println("Bad descriptor: " + descriptor.name()); path = ((Compound) descriptor.arg(1)).arg(1); if (term.arity() > 1) { projType = (Compound) term.arg(2); } else { projType = Compound.createCompound("cpi#default"); } // Set up the GUI setLayoutManager(new FlowLayout()); setRequestFocusEnabled(true); // Create the child figures contentFigure = createContentFigure(descriptor); add(contentFigure); unreg = Notifier.instance() .register( new Compound("::", path, Compound.createCompound("cpi#path")), new Runnable() { @Override public void run() { try { updateFigure(); } catch (TermVisualizationException e) { e.printStackTrace(); } catch (TermInstantiationException e) { e.printStackTrace(); } } }); } catch (TermVisualizationException e) { e.printStackTrace(); Label label = new Label("<<<" + e.getMessage() + ">>>"); label.setForegroundColor(new Color(context.getTextEditor().getDisplay(), 255, 0, 0)); add(label); } catch (ClassCastException e) { e.printStackTrace(); Label label = new Label("<<<" + e.getMessage() + ">>>"); label.setForegroundColor(new Color(context.getTextEditor().getDisplay(), 128, 128, 0)); add(label); } pathOwner.put(path, this); }
protected IFigure createBaseFigure() { Image image = null; byte[] icon = null; ComponentInterface ci = ((WorkflowNode) getModel()) .getComponentDescription() .getComponentInstallation() .getComponentRevision() .getComponentInterface(); if (ci.getSize() == ComponentSize.SMALL) { icon = ((WorkflowNode) getModel()).getComponentDescription().getIcon24(); } else { icon = ((WorkflowNode) getModel()).getComponentDescription().getIcon32(); } if (icon != null) { try { image = new Image(Display.getCurrent(), new ByteArrayInputStream(icon)); } catch (SWTException e) { // The images of integrated tools may be broken, so the default will be used. LogFactory.getLog(getClass()).info("Could not load tool icon, loading default. ", e); image = ImageManager.getInstance().getSharedImage(StandardImages.RCE_LOGO_32); } } else if (ci.getIdentifier().startsWith(ComponentUtils.MISSING_COMPONENT_PREFIX)) { if (ci.getSize() == ComponentSize.SMALL) { image = ImageManager.getInstance().getSharedImage(StandardImages.RCE_LOGO_24_GREY); } else { image = ImageManager.getInstance().getSharedImage(StandardImages.RCE_LOGO_32_GREY); } } else { if (ci.getSize() == ComponentSize.SMALL) { image = ImageManager.getInstance().getSharedImage(StandardImages.RCE_LOGO_24); } else { image = ImageManager.getInstance().getSharedImage(StandardImages.RCE_LOGO_32); } } Color color = getColor(ci); if (ci.getSize() == ComponentSize.SMALL) { IconLabel iconLabel = new IconLabel(image, ci); iconLabel.setOpaque(true); iconLabel.setBorder(null); iconLabel.setBackgroundColor(color); return iconLabel; } else { final String labelText = ((WorkflowNode) getModel()).getName(); final Label label = new Label(labelText, image); label.setTextPlacement(PositionConstants.SOUTH); label.setBorder(new LineBorder()); label.setOpaque(true); label.setBackgroundColor(color); return label; } }
/** @generated */ protected IFigure createSelectionFeedbackFigure() { if (getHostFigure() instanceof Label) { Label feedbackFigure = new Label(); feedbackFigure.setOpaque(true); feedbackFigure.setBackgroundColor(ColorConstants.menuBackgroundSelected); feedbackFigure.setForegroundColor(ColorConstants.menuForegroundSelected); return feedbackFigure; } else { RectangleFigure feedbackFigure = new RectangleFigure(); feedbackFigure.setFill(false); return feedbackFigure; } }
/* * (non-Javadoc) * * @see org.eclipse.draw2d.Figure#repaint() */ @Override public void repaint() { int x = getLocation().x; int y = getLocation().y; if (collapsing) { width = Constants.SIZE_16; height = Constants.SIZE_18; getBounds().height = height; getBounds().width = width; } else { if (hideButton != null) { if (hide) { super.setSize(width, 18); } else { super.setSize(width, height); } textFigure.setSize(width, 10); text.setSize(width, 15); text.setLocation(new Point(x, y)); if (getChildren().size() > 1) { if (!textFigure.getChildren().contains(hideButton)) { textFigure.add(hideButton); } hideButton.setLocation(new Point(x + width - 11, y + 1)); } else { if (textFigure.getChildren().contains(hideButton)) { textFigure.remove(hideButton); } } } for (int i = 0; i < getChildren().size(); i++) { IFigure figure = (IFigure) getChildren().get(i); if (figure == textFigure || hide) { figure.setSize(width, 16); figure.setLocation(new Point(x, y)); } else { figure.setSize(width - 5, 15); figure.setLocation(new Point(x + 5, y + 16 + 15 * i)); } } } super.repaint(); }
public void propertyChange(PropertyChangeEvent evt) { SyncMessageConnectionFigure figure = (SyncMessageConnectionFigure) getFigure(); Label label = figure.getLabel(); SyncMessageModel model = (SyncMessageModel) getModel(); if (evt.getPropertyName().equals(MessageModel.P_NAME)) { label.setText(model.getOrder() + "." + model.getName()); } if (evt.getPropertyName().equals(SyncMessageModel.P_ORDER)) { label.setText(model.getOrder() + "." + model.getName()); } if (evt.getPropertyName().equals(SyncMessageModel.P_DIRECTION)) { figure.locateLabel(model.isDirection()); } super.propertyChange(evt); }
/** * Set the label that displays the icon. * * @param iconLabel the label to display the icon, may be the same as the text label or <code>null * </code> to ignore the icon * @see #setTextLabel(Label) */ public void setIconLabel(Label iconLabel) { this.iconLabel = iconLabel; if (icon != null) { iconLabel.setIcon(icon); } }
/** @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { if (figure instanceof WrappingLabel) { ((WrappingLabel) figure).setIcon(icon); } else { ((Label) figure).setIcon(icon); } }
public GaugeFigure() { super(); transparent = true; scale.setScaleLineVisible(false); scale.setTickLabelSide(LabelSide.Secondary); ramp.setRampWidth(10); valueLabel = new Label(); valueLabel.setFont(DEFAULT_LABEL_FONT); needle = new Needle(); needle.setFill(true); needle.setOutline(false); needleCenter = new NeedleCenter(); needleCenter.setOutline(false); setLayoutManager(new GaugeLayout()); add(ramp, GaugeLayout.RAMP); add(scale, GaugeLayout.SCALE); add(valueLabel, GaugeLayout.VALUE_LABEL); add(needle, GaugeLayout.NEEDLE); add(needleCenter, GaugeLayout.NEEDLE_CENTER); addFigureListener( new FigureListener() { public void figureMoved(IFigure source) { ramp.setDirty(true); revalidate(); } }); }
public NodeFigure() { super(); labelControl.setForegroundColor(ColorConstants.black); add(labelControl, 0); setConstraint(labelControl, new Rectangle(1, 1, -1, -1)); }
/** @generated */ protected void setLabelTextHelper(IFigure figure, String text) { if (figure instanceof WrappingLabel) { ((WrappingLabel) figure).setText(text); } else { ((Label) figure).setText(text); } }
public void paint(Graphics g) { if (lblCnnName.getBorder() != null) { g.setLineWidth(2); } else { g.setLineWidth(1); } super.paint(g); }
public void markError(String errMsg) { errStr = errMsg; if (errStr != null) { // lblCnnName.setIcon(ImageFactory.getErrorImg()); } else { lblCnnName.setIcon(null); } }
/** * @param contents Draw2dGraph * @param node IVertex * @param color Color * @param busLabel String * @param busId String String * @return PolylineConnection */ private PolylineConnection createBusConnexion( final Draw2dGraph contents, final IVertex node, final Color color, final String busId, final String busLabel) { final PolylineConnection conn = addConnectionFromRoute(contents, null, (DotRoute) node.getAttr(busId)); conn.setForegroundColor(color); contents.add(conn, conn.getBounds()); final Label label = new Label( busLabel + " " + node.getName(), Application.getInstance().getImage(Application.LINK_ICON)); label.setFont(Application.getInstance().getBoldFont(Application.TOOLTIP_FONT)); conn.setToolTip(label); return conn; }
@Override public void setText(String text) { this.text = text; if (textLabel != null) { textLabel.setText(text); adjustSize(); } }
@Override public void setIcon(Image icon) { this.icon = icon; if (iconLabel != null) { iconLabel.setIcon(icon); adjustSize(); } }
public int setVerticalLocation(Point parentTopCenter, int currentHeight) { Dimension topSize = fTopChannel.getSize(); Dimension pipelineSize = getSize(); Dimension headerSize = fHeader.getSize(); Dimension arrowSize = fArrow.getSize(); Dimension bottomSize = fBottomChannel.getSize(); if (fTopChannel.setSelf(parentTopCenter.getTranslated(-topSize.width / 2, currentHeight), true)) currentHeight += topSize.height; setLocation(parentTopCenter.getTranslated(-pipelineSize.width / 2, currentHeight)); fHeader.setLocation( parentTopCenter.getTranslated( -pipelineSize.width / 2 + IStreamItGraphConstants.MARGIN / 2, IStreamItGraphConstants.MARGIN / 2 + currentHeight)); if (!isExpanded()) { // collapsed location fArrow.setLocation( parentTopCenter.getTranslated( -arrowSize.width / 2, IStreamItGraphConstants.MARGIN / 2 + headerSize.height + currentHeight)); currentHeight += pipelineSize.height; } else { // expanded location fArrow.setLocation( parentTopCenter.getTranslated( -pipelineSize.width / 2 + IStreamItGraphConstants.MARGIN / 2, IStreamItGraphConstants.MARGIN / 2 + headerSize.height + currentHeight)); int last = fChildren.size() - 1; for (int i = 0; i < last + 1; i++) currentHeight = ((IStreamStructureWidget) fChildren.get(i)) .setVerticalLocation(parentTopCenter, currentHeight); } if (fBottomChannel.setSelf( parentTopCenter.getTranslated(-bottomSize.width / 2, currentHeight), false)) currentHeight += bottomSize.height; return currentHeight; }
private void doUpdateFigure(Connection connection) { if (connection == null || this.isDisposed()) { return; } Shape connectionShape = (Shape) connection; connectionShape.setLineStyle(getLineStyle()); if (this.getText() != null || this.getImage() != null) { if (this.getImage() != null) { this.connectionLabel.setIcon(this.getImage()); } if (this.getText() != null) { this.connectionLabel.setText(this.getText()); } this.connectionLabel.setFont(this.getFont()); } if (highlighted) { connectionShape.setForegroundColor(getHighlightColor()); connectionShape.setLineWidth(getLineWidth() * 2); } else { connectionShape.setForegroundColor(getLineColor()); connectionShape.setLineWidth(getLineWidth()); } if (connection instanceof PolylineArcConnection) { PolylineArcConnection arcConnection = (PolylineArcConnection) connection; arcConnection.setDepth(curveDepth); } if (connectionFigure != null) { applyConnectionRouter(connectionFigure); } if ((connectionStyle & ZestStyles.CONNECTIONS_DIRECTED) > 0) { PolygonDecoration decoration = new PolygonDecoration(); if (getLineWidth() < 3) { decoration.setScale(9, 3); } else { double logLineWith = getLineWidth() / 2.0; decoration.setScale(7 * logLineWith, 3 * logLineWith); } ((PolylineConnection) connection).setTargetDecoration(decoration); } IFigure toolTip; if (this.getTooltip() == null && getText() != null && getText().length() > 0 && hasCustomTooltip == false) { toolTip = new Label(); ((Label) toolTip).setText(getText()); } else { toolTip = this.getTooltip(); } connection.setToolTip(toolTip); }
private Viewport getViewPort() { Viewport result = null; IFigure parent = label.getParent(); while (parent != null && !(parent instanceof Viewport)) { parent = parent.getParent(); } if (parent != null) { result = (Viewport) parent; } return result; }
/** @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { if (figure instanceof WrappingLabel) { ((WrappingLabel) figure).setIcon(icon); return; } else if (figure instanceof Label) { ((Label) figure).setIcon(icon); return; } else { getLabelDelegate().setIcon(icon, 0); } }
/* * (non-Javadoc) * * @see org.eclipse.gef.editparts.AbstractConnectionEditPart#createFigure() */ @Override protected IFigure createFigure() { PolylineConnection connection = new PolylineConnection(); PolygonDecoration decoration = new PolygonDecoration(); decoration.setTemplate(PolygonDecoration.TRIANGLE_TIP); connection.setTargetDecoration(decoration); connection.setLineWidth(2); if (getCastedModel().isAlternate()) { ConditionalElement prevous = (ConditionalElement) getCastedModel().getPrevous(); Label conditionLbl = new Label("[" + prevous.getAlternativeLabel() + "]"); conditionLbl.setOpaque(true); connection.add(conditionLbl, new MidpointLocator(connection, 0)); } return connection; }
public NestedBigraphFigure() { super(); name.setForegroundColor(ColorConstants.black); add(name, 0); // setConstraint(name, new Rectangle(100, 100, 100, 100)); setForegroundColor(ColorConstants.black); setBackgroundColor(ColorConstants.white); }