/** * {@inheritDoc} */ @Override protected void outlineShape(Graphics graphics) { Rectangle r = getBounds(); int x = r.x + getLineWidth() / 2; int y = r.y + getLineWidth() / 2; int w = r.width - Math.max(1, getLineWidth()); int h = r.height - Math.max(1, getLineWidth()); Rectangle bounds = new Rectangle(x, y, w, h); Point topRight1 = bounds.getTopRight().translate(0, RETURN_WIDTH); Point topRight2 = bounds.getTopRight().translate(-RETURN_WIDTH, 0); Point topRight3 = bounds.getTopRight().translate(-RETURN_WIDTH, RETURN_WIDTH); graphics.drawLine(bounds.getTopLeft(), bounds.getBottomLeft()); graphics.drawLine(bounds.getBottomLeft(), bounds.getBottomRight()); graphics.drawLine(bounds.getBottomRight(), topRight1); graphics.drawLine(topRight1, topRight2); graphics.drawLine(topRight2, bounds.getTopLeft()); graphics.drawLine(topRight2, topRight3); graphics.drawLine(topRight3, topRight1); }
/** * @see nexcore.tool.uml.ui.core.diagram.figure.AbstractNotationNodeFigure#paintFigure(org.eclipse.draw2d.Graphics) */ @Override protected void paintFigure(Graphics graphics) { super.paintFigure(graphics); graphics.drawRectangle(getLocation().x, getLocation().y, getSize().width - 1, getSize().height - 1); graphics.setAntialias(SWT.ON); Rectangle bounds = getBounds(); if(isDangling()){ graphics.setForegroundColor(ColorConstants.red); graphics.drawOval(bounds.x, bounds.y, 12, 12); graphics.drawLine(bounds.x + 2, bounds.y + 2, bounds.x + 10, bounds.y + 10); graphics.drawLine(bounds.x + 10, bounds.y + 2, bounds.x + 2, bounds.y + 10); } }
@Override protected void paintClientArea ( final Graphics graphics ) { if ( this.renderer != null ) { final Draw2DGraphics g = new Draw2DGraphics ( graphics, this.resourceManager.getDevice () ); try { this.renderer.paint ( g ); } finally { g.dispose (); } } }
public TextController ( final FigureCanvas canvas, final SymbolController controller, final Text element, final ResourceManager manager ) { super ( controller, manager ); this.canvas = canvas; this.figure = new Label ( element.getText ()) { @Override public void addNotify () { super.addNotify (); start (); } @Override protected void paintFigure ( final Graphics graphics ) { final Double alpha = getAlpha (); if ( alpha != null ) { graphics.setAlpha ( (int) ( Math.max ( 0.0, Math.min ( 1.0, alpha ) ) * 255.0 ) ); } super.paintFigure ( graphics ); } @Override public void removeNotify () { stop (); super.removeNotify ( ); } }; controller.addElement ( element, this ); applyCommon ( element ); }
/** * @see Shape#outlineShape(Graphics) */ @Override protected void outlineShape ( final Graphics graphics ) { final float lineInset = Math.max ( 1.0f, getLineWidthFloat () ) / 2.0f; final int inset1 = (int)Math.floor ( lineInset ); final int inset2 = (int)Math.ceil ( lineInset ); final Rectangle r = Rectangle.SINGLETON.setBounds ( getBounds () ); r.x += inset1; r.y += inset1; r.width -= inset1 + inset2; r.height -= inset1 + inset2; graphics.drawRectangle ( r ); }
@Override protected void paintFigure(Graphics graphics) { Rectangle r = getBounds().getCopy(); Object tempEllipse = new Rectangle(0, 0, r.width, r.height); if ( constraintRectangle==null || !constraintRectangle.equals(tempEllipse)) { constraintRectangle = tempEllipse; setConstraint(ellipse, constraintRectangle); ellipse.invalidate(); } Object tempName = new Rectangle(0, 0, r.width, r.height); if (constraintName==null || !constraintName.equals(tempName)) { constraintName = tempName; setConstraint(name, constraintName); name.invalidate(); } }
@Override protected void paintFigure(Graphics graphics) { Rectangle r = getBounds().getCopy(); Object tempRectangle = new Rectangle(0, 0, r.width, r.height); if ( constraintRectangle==null || !constraintRectangle.equals(tempRectangle)) { constraintRectangle = tempRectangle; setConstraint(rectangle, constraintRectangle); rectangle.invalidate(); } Object tempName = new Rectangle(0, 0, r.width, r.height); if (constraintName==null || !constraintName.equals(tempName) || isStateUpdate()) { constraintName = tempName; setConstraint(name, constraintName); name.invalidate(); } if (vertextStateFigure!=null) { if (constraintStateFigure==null || !constraintStateFigure.equals(r) || isStateUpdate()) { constraintStateFigure = r; setStateUpdate(false); vertextStateFigure.setConstraint(r); vertextStateFigure.invalidate(); } } }
private void trackExecution(Graphics graphics) { Rectangle rectangle = getBounds().getCopy(); if(componentStatus!=null){ if (componentStatus.equals(ComponentExecutionStatus.BLANK)){ compStatusImage = null; }else if (componentStatus.equals(ComponentExecutionStatus.PENDING)){ compStatusImage =ImagePathConstant.COMPONENT_PENDING_ICON.getImageFromRegistry(); }else if (componentStatus.equals(ComponentExecutionStatus.RUNNING)){ compStatusImage =ImagePathConstant.COMPONENT_RUNNING_ICON.getImageFromRegistry(); }else if (componentStatus.equals(ComponentExecutionStatus.SUCCESSFUL)){ compStatusImage =ImagePathConstant.COMPONENT_SUCCESS_ICON.getImageFromRegistry(); }else if (componentStatus.equals(ComponentExecutionStatus.FAILED)){ compStatusImage = ImagePathConstant.COMPONENT_FAILED_ICON.getImageFromRegistry(); } } if (compStatusImage != null) { graphics.drawImage(compStatusImage, new Point (8, rectangle.height - 22)); } }
/** * Draws the status image to right corner of the component * * @param graphics */ private void drawPropertyStatus(Graphics graphics) { Rectangle rectangle = getBounds().getCopy(); if (StringUtils.isNotBlank(getPropertyStatus()) && getPropertyStatus().equals(ValidityStatus.WARN.name())) { statusImage = ImagePathConstant.COMPONENT_WARN_ICON.getImageFromRegistry(); } else if (StringUtils.isNotBlank(getPropertyStatus()) && getPropertyStatus().equals(ValidityStatus.ERROR.name())) { statusImage = ImagePathConstant.COMPONENT_ERROR_ICON.getImageFromRegistry(); } else if (StringUtils.isNotBlank(getPropertyStatus()) && getPropertyStatus().equals(Constants.UPDATE_AVAILABLE)) { statusImage = ImagePathConstant.COMPONENT_UPDATE_ICON.getImageFromRegistry(); } else if (StringUtils.isNotBlank(getPropertyStatus()) && getPropertyStatus().equals(ValidityStatus.VALID.name())){ statusImage=null; } logger.trace("Component has {} property status.", getPropertyStatus()); if (statusImage != null && !statusImage.isDisposed()) { graphics.drawImage(statusImage, new Point(rectangle.width - 25, 8 + componentLabelMargin)); } }
@Override public void undo() { Iterator<Model> it = deleteLinks.iterator(); while(it.hasNext()){ Link restoreLink=(Link)it.next(); restoreLink.setLineStyle(Graphics.LINE_SOLID); restoreLink.attachSource(); restoreLink.getSource().engageOutputPort(restoreLink.getSourceTerminal()); restoreLink.setLineStyle(Graphics.LINE_SOLID); restoreLink.attachTarget(); restoreLink.getTarget().engageInputPort(restoreLink.getTargetTerminal()); } }
@Override protected void paintFigure(Graphics g) { super.paintFigure(g); final int LEG = 5; Rectangle r = getBounds(); g.setLineWidth(1); g.setForegroundColor(valid ? ColorConstants.black : PandionJConstants.Colors.ERROR); g.drawLine(r.x, r.y, r.x, r.y+r.height-1); g.drawLine(r.x, r.y, r.x+LEG, r.y); g.drawLine(r.x, r.y+r.height-1, r.x+LEG, r.y+r.height-1); g.drawLine(r.x+r.width-1, r.y, r.x+r.width-1, r.y+r.height); g.drawLine(r.x+r.width-1, r.y, r.x+r.width-1-LEG, r.y); g.drawLine(r.x+r.width-1, r.y+r.height-1, r.x+r.width-1-LEG, r.y+r.height-1); if(!valid) { g.setForegroundColor(PandionJConstants.Colors.ERROR); String text = "Invalid matrix"; int textWidth = FigureUtilities.getTextWidth(text, g.getFont()); Point p = r.getLocation().translate(r.width/2 - textWidth/2, 5); g.drawText(text, p); } }
@Override protected void paintFigure(Graphics g) { super.paintFigure(g); Rectangle r = getBounds(); Rectangle square = new Rectangle(r.getLocation().getTranslated(0, r.height/4), new Dimension(r.width/2, r.height/2)); center = new Point(square.x + square.width/2, square.y + square.height/2); g.setBackgroundColor(dirty ? PandionJConstants.Colors.HIGHLIGHT : PandionJConstants.Colors.VARIABLE_BOX); g.fillRectangle(square); g.setForegroundColor(ref.getRole() == Role.FIXED_VALUE ? PandionJConstants.Colors.CONSTANT : ColorConstants.black); g.drawRectangle(square); g.setBackgroundColor(error ? PandionJConstants.Colors.ERROR : ColorConstants.black); g.fillOval(center.x-3, center.y-3, 7, 7); if(isnull) { g.setForegroundColor(error ? PandionJConstants.Colors.ERROR : ColorConstants.black); Point dest = center.getTranslated(20, 0); g.drawLine(center, dest); g.drawLine(dest.getTranslated(-3, 5), dest.getTranslated(3, -5)); } }
@Override protected void paintFigure(Graphics graphics) { Date date = editor.getCurrentSelectedDate(); if (feature.hasVersionsAtDate(date)) { paintVersionAreaBackground(graphics); paintConnection(graphics, HyEvolutionUtil.getValidTemporalElements(feature.getWrappedModelElement().getVersions(), date).get(0)); } if (feature.hasAttributesAtDate(date)) { paintAttributeAreaBackground(graphics); } paintNameAreaBackground(graphics); }
@Override protected void paintVersionMarks(Graphics graphics) { HyFeature feature = this.feature.getWrappedModelElement(); List<HyVersion> versions = feature.getVersions(); for (HyVersion version : versions) { Rectangle versionMarkRectangle = getVersionMarkRectangle(version); HyConfiguration selectedConfiguration = ((DwFeatureModelConfiguratorViewer)editor).getSelectedConfiguration(); if (HyConfigurationUtil.configurationSelectsVersion(selectedConfiguration, version)) { DEDrawingUtil.drawSelection(graphics, versionMarkRectangle, this, false); } } super.paintVersionMarks(graphics); }
@Override protected void paintAttributeMarks(Graphics graphics) { HyFeature feature = this.feature.getWrappedModelElement(); List<HyFeatureAttribute> attributes = feature.getAttributes(); for (HyFeatureAttribute attribute : attributes) { Rectangle attributeMarkRectangle = getAttributeMarkRectangle(attribute); HyConfiguration selectedConfiguration = ((DwFeatureModelConfiguratorViewer)editor).getSelectedConfiguration(); for(HyConfigurationElement element : selectedConfiguration.getElements()){ if(element instanceof HyAttributeValueAssignment){ if(EcoreUtil.equals(((HyAttributeValueAssignment)element).getAttribute(), attribute)){ DEDrawingUtil.drawSelection(graphics, attributeMarkRectangle, this, false); } } } } super.paintVersionMarks(graphics); }
/** * {@inheritDoc} */ @Override public void paint(final IFigure figure, final Graphics graphics, final Insets insets) { if (getColor() != null) { graphics.setForegroundColor(getColor()); } tempRect.setBounds(getPaintRectangle(figure, insets)); if (getWidth() % 2 == 1) { tempRect.width--; tempRect.height--; } tempRect.shrink(getWidth() / 2, getWidth() / 2); graphics.setLineWidth(1); int g = 9 * DELTA; int b = 9 * DELTA; for (int i = 0; i <= 5; i++) { final Color color = Resources.getColor(new int[] {b, g, 255}); paint1(i, color, tempRect, graphics); g -= DELTA; b -= DELTA; } }
/** * {@inheritDoc} */ @Override public void paintFigure(final Graphics graphics) { final ERDiagramConnection connection = (ERDiagramConnection) getParent(); graphics.setAntialias(SWT.ON); final Color color = connection.getColor(); if (color != null) { graphics.setForegroundColor(color); graphics.setBackgroundColor(color); } super.paintFigure(graphics); }
/** * {@inheritDoc} */ @Override protected void fillShape(final Graphics graphics) { graphics.setAlpha(200); final Rectangle bounds = getBounds(); final Point topRight1 = bounds.getTopRight().translate(0, RETURN_WIDTH); final Point topRight2 = bounds.getTopRight().translate(-RETURN_WIDTH, 0); final PointList pointList = new PointList(); pointList.addPoint(bounds.getTopLeft()); pointList.addPoint(bounds.getBottomLeft()); pointList.addPoint(bounds.getBottomRight()); pointList.addPoint(topRight1); pointList.addPoint(topRight2); pointList.addPoint(bounds.getTopLeft()); graphics.fillPolygon(pointList); }
/** * {@inheritDoc} */ @Override protected void outlineShape(final Graphics graphics) { final Rectangle r = getBounds(); final int x = r.x + getLineWidth() / 2; final int y = r.y + getLineWidth() / 2; final int w = r.width - Math.max(1, getLineWidth()); final int h = r.height - Math.max(1, getLineWidth()); final Rectangle bounds = new Rectangle(x, y, w, h); final Point topRight1 = bounds.getTopRight().translate(0, RETURN_WIDTH); final Point topRight2 = bounds.getTopRight().translate(-RETURN_WIDTH, 0); final Point topRight3 = bounds.getTopRight().translate(-RETURN_WIDTH, RETURN_WIDTH); graphics.drawLine(bounds.getTopLeft(), bounds.getBottomLeft()); graphics.drawLine(bounds.getBottomLeft(), bounds.getBottomRight()); graphics.drawLine(bounds.getBottomRight(), topRight1); graphics.drawLine(topRight1, topRight2); graphics.drawLine(topRight2, bounds.getTopLeft()); graphics.drawLine(topRight2, topRight3); graphics.drawLine(topRight3, topRight1); }
/** * {@inheritDoc} */ @Override protected void printPages() { final Graphics graphics = getFreshPrinterGraphics(); final IFigure figure = getPrintSource(); setupPrinterGraphicsFor(graphics, figure); final Rectangle bounds = figure.getBounds(); int x = bounds.x, y = bounds.y; final Rectangle clipRect = new Rectangle(); while (y < bounds.y + bounds.height) { while (x < bounds.x + bounds.width) { graphics.pushState(); getPrinter().startPage(); graphics.translate(-x, -y); graphics.getClip(clipRect); clipRect.setLocation(x, y); graphics.clipRect(clipRect); figure.paint(graphics); getPrinter().endPage(); graphics.popState(); x += clipRect.width; } x = bounds.x; y += clipRect.height; } }
/** * {@inheritDoc} */ @Override public void paint(IFigure figure, Graphics graphics, Insets insets) { if (getColor() != null) { graphics.setForegroundColor(getColor()); } tempRect.setBounds(getPaintRectangle(figure, insets)); if (getWidth() % 2 == 1) { tempRect.width--; tempRect.height--; } tempRect.shrink(getWidth() / 2, getWidth() / 2); graphics.setLineWidth(1); int g = 9 * DELTA; int b = 9 * DELTA; for (int i = 0; i <= 5; i++) { Color color = Resources.getColor(new int[] { b, g, 255 }); this.paint1(i, color, tempRect, graphics); g -= DELTA; b -= DELTA; } }
private void drawShadowLayer(Rectangle rectangle, Graphics graphics, int offset, Color color) { // Save the state of the graphics object graphics.pushState(); graphics.setLineWidth(0); graphics.setBackgroundColor(color); Rectangle shadowLayer = new Rectangle(rectangle); shadowLayer.x += offset; shadowLayer.y += offset; Dimension cornerDimensions = getCornerDimensions(); graphics.fillRoundRectangle(shadowLayer, cornerDimensions.width, cornerDimensions.height); // Restore the start of the graphics object graphics.popState(); }
/** * {@inheritDoc} */ @Override public void paintFigure(Graphics graphics) { ERDiagramConnection connection = (ERDiagramConnection) this.getParent(); graphics.setAntialias(SWT.ON); Color color = connection.getColor(); if (color != null) { graphics.setForegroundColor(color); graphics.setBackgroundColor(color); } super.paintFigure(graphics); }
/** * {@inheritDoc} */ @Override protected void fillShape(Graphics graphics) { graphics.setAlpha(200); Rectangle bounds = this.getBounds(); Point topRight1 = bounds.getTopRight().translate(0, RETURN_WIDTH); Point topRight2 = bounds.getTopRight().translate(-RETURN_WIDTH, 0); PointList pointList = new PointList(); pointList.addPoint(bounds.getTopLeft()); pointList.addPoint(bounds.getBottomLeft()); pointList.addPoint(bounds.getBottomRight()); pointList.addPoint(topRight1); pointList.addPoint(topRight2); pointList.addPoint(bounds.getTopLeft()); graphics.fillPolygon(pointList); }
/** * {@inheritDoc} */ @Override protected void printPages() { Graphics graphics = getFreshPrinterGraphics(); IFigure figure = getPrintSource(); setupPrinterGraphicsFor(graphics, figure); Rectangle bounds = figure.getBounds(); int x = bounds.x, y = bounds.y; Rectangle clipRect = new Rectangle(); while (y < bounds.y + bounds.height) { while (x < bounds.x + bounds.width) { graphics.pushState(); getPrinter().startPage(); graphics.translate(-x, -y); graphics.getClip(clipRect); clipRect.setLocation(x, y); graphics.clipRect(clipRect); figure.paint(graphics); getPrinter().endPage(); graphics.popState(); x += clipRect.width; } x = bounds.x; y += clipRect.height; } }
@Override public void paint(IFigure figure, Graphics graphics, Insets insets) { Rectangle tempRect = figure.getBounds(); if (figure instanceof HandleBounds) tempRect = ((HandleBounds) figure).getHandleBounds(); Graphics2D g = ComponentFigure.getG2D(graphics); if (g != null) { Stroke oldStroke = g.getStroke(); g.setStroke(new BasicStroke(0.1f)); if (getColor() != null) g.setColor((J2DGraphics.toAWTColor(getColor()))); g.drawRect(tempRect.x, tempRect.y, tempRect.width - 1, tempRect.height - 1); g.setStroke(oldStroke); } }
private void drawMargins(Graphics graphics, Rectangle clippedBounds) { if (isOpaque()) { Rectangle t = transposer.t(clippedBounds); graphics.setAlpha(128); graphics.setBackgroundColor(ColorConstants.gray); if (isHorizontal()) { int swidth = getSize().width; graphics.fillRectangle(0 - swidth, 0, (int) (hoffset * zoomManager.getZoom()) + swidth, t.height); graphics.fillRectangle((int) ((hoffset + hend) * zoomManager.getZoom()), 0, swidth, t.height); } else { int sheight = getSize().height; graphics.fillRectangle(0, 0 - sheight, t.width, (int) (zoomManager.getZoom() * voffset) + sheight); graphics.fillRectangle(0, (int) ((vend + voffset) * zoomManager.getZoom()), t.width, sheight); } graphics.setAlpha(0); graphics.setBackgroundColor(ColorConstants.white); } }
protected void showGradient(Graphics graphics, PrecisionRectangle tempRect, float internalRadius) { Color backgroundColor = getBackgroundColor(); //top gradient Image gradientImage = Drawer.getGradientRectangle( tempRect, backgroundColor.getRGB(), ColorUtils.darker(ColorUtils.darker(ColorUtils.darker( backgroundColor.getRGB()))), internalRadius, 50, SWT.TOP); graphics.drawImage(gradientImage, tempRect.x, tempRect.y); gradientImage.dispose(); //bottom gradient gradientImage = Drawer.getGradientRectangle( tempRect, ColorUtils.darker(ColorUtils.darker(ColorUtils.darker( backgroundColor.getRGB()))), backgroundColor.getRGB(), internalRadius, 50, SWT.BOTTOM); graphics.drawImage(gradientImage, tempRect.x, tempRect.bottom() - gradientImage.getBounds().height); gradientImage.dispose(); }
@Override protected void paintFigure(Graphics graphics) { //this will draw main border getBorder().paintBackground(this, graphics, borderInsets); //now we need to draw border with another color //to imitate value Rectangle bounds = getBounds().getCopy().crop(borderInsets); bounds.width *= this.value; //bounds.shrink(0, borderInsets.top); int radius = Math.min(Math.min(bounds.height, bounds.width), (int)getBorder().getBorderRadius()*2); graphics.setBackgroundColor(valueColor); graphics.fillRoundRectangle(bounds, radius, radius); graphics.drawRoundRectangle(bounds, radius, radius); graphics.setBackgroundColor(getBorder().getBackgroundColor()); drawCircle(graphics, bounds); }
/** * @param graphics */ private void paingImage(Graphics graphics) { if (image != null){ PrecisionRectangle tempRect = new PrecisionRectangle(getBounds().crop(insets)); float r = getBorder().getActualBorderRadius(tempRect); // must use paths to process not integer values // the difference is visible with zoom graphics.setBackgroundColor(getBackgroundColor()); float borderWidth = Math.min(Math.min(tempRect.height, tempRect.width)/2, getBorder().getBorderWidth()); float internalRadius = Math.max(0, r - borderWidth); tempRect.shrink(borderWidth, borderWidth); Image roundedImage = getBorder().getRoundedImage(new Image(null, image.getImageData().scaledTo(tempRect.width, tempRect.height)), internalRadius); graphics.drawImage(roundedImage, tempRect.x, tempRect.y); roundedImage.dispose(); } }
@Override public void paint(IFigure figure, Graphics graphics, Insets insets) { if (getColor() != null) { graphics.setForegroundColor(getColor()); } tempRect.setBounds(getPaintRectangle(figure, insets)); if (getWidth() % 2 == 1) { tempRect.width--; tempRect.height--; } tempRect.shrink(getWidth() / 2, getWidth() / 2); graphics.setLineWidth(1); int g = 9 * DELTA; int b = 9 * DELTA; for (int i = 0; i <= 5; i++) { final Color color = DesignResources.getColor(new int[] { b, g, 255 }); paint1(i, color, tempRect, graphics); g -= DELTA; b -= DELTA; } }
public void paint(IFigure figure, Graphics graphics, Insets insets) { Rectangle rect = getPaintRectangle(figure, insets); graphics.setForegroundColor(ColorConstants.white); graphics.drawLine(rect.x, rect.y, rect.x, rect.bottom()); rect.x++; rect.width--; rect.resize(-1, -1); graphics.setForegroundColor(ColorConstants.black); graphics.drawLine(rect.x + 2, rect.bottom(), rect.right(), rect.bottom()); graphics.drawLine(rect.right(), rect.bottom(), rect.right(), rect.y + 2); rect.resize(-1, -1); graphics.setForegroundColor(BLUE); graphics.drawRectangle(rect); }
@Override public void paint(Graphics graphics) { Rectangle b = (this instanceof HandleBounds) ? ((HandleBounds) this).getHandleBounds() : this.getBounds(); try { graphics.translate(b.x, b.y); Graphics2D graphics2d = getG2D(graphics); if (graphics2d != null) { if (drawVisitor != null) { drawVisitor.setGraphics2D(graphics2d); draw(drawVisitor, jrElement); } else graphics2d.drawRect(b.x, b.y, b.width, b.height); } else { System.out.println("not a 2d"); } } catch (Exception e) { // when a font is missing exception is thrown by DrawVisitor // FIXME: maybe draw something, else? e.printStackTrace(); } finally { graphics.translate(-b.x, -b.y); } paintBorder(graphics); paintDecorators(graphics); }
/** * Draw polyline with the line style and line width of the trace. * * @param graphics * @param pl */ private void drawPolyline(Graphics graphics, PointList pl) { graphics.pushState(); graphics.setLineWidth(lineWidth); switch(traceType) { case SOLID_LINE: case STEP_HORIZONTALLY: case STEP_VERTICALLY: graphics.setLineStyle(SWTConstants.LINE_SOLID); graphics.drawPolyline(pl); break; case DASH_LINE: graphics.setLineStyle(SWTConstants.LINE_DASH); graphics.drawPolyline(pl); break; default: break; } graphics.popState(); }
public void paint(Graphics g) { /* * // draw the line g.setForegroundColor(this.getForegroundColor()); g.drawLine(currentBounds.x, currentBounds.y, * currentBounds.x + currentBounds.width, currentBounds.y); * * // Draw the label... * * * g.setAlpha(128); String text = bandHeight + " px"; //$NON-NLS-1$ Label label = new Label(text); * label.setFont(g.getFont()); Rectangle textBounds = label.getTextBounds(); * g.setBackgroundColor(ColorConstants.gray); g.fillRoundRectangle(new Rectangle(xLabelPos, currentBounds.y, * textBounds.width + 20, textBounds.height + 8), 10, 10); g.setForegroundColor(ColorConstants.white); * g.drawText(text, xLabelPos + 10, currentBounds.y); */ }
protected void paintPagingControl(Graphics graphics){ int diametr = ARCH_RADIUS * 2; int width = diametr * 2 * pagesCount - diametr; Point leftTop = new Point(getBounds().getCenter().x - width / 2, getBounds().bottom() - ARCH_RADIUS * 3); for (int i = 0; i < pagesCount; i++) { graphics.setBackgroundColor(currentPage == i ? ColorConstants.black : ColorConstants.lightGray); graphics.fillArc(leftTop.x, leftTop.y, diametr, diametr, 0, 360); leftTop.translate(diametr*2, 0); } }
/** * A J2DGraphics is built from a Control and a Graphics2DFactory. The Control object is cached so that it can be used * to create a GC that will give us access to the FontMetrics. The Graphics2DFactory is not cached because only an * initial Graphics2D object is needed. * * @param gc * the gc * @param g2d * the g2d */ public J2DScaledGraphics(Graphics graphics, GC gc, Graphics2D g2d) { super(graphics); if (gc != null) { _dpi = gc.getDevice().getDPI().x / 72.0; this.gc = gc; _fg = gc.getForeground(); _bg = gc.getBackground(); _font = gc.getFont(); } else { _fg = toSWTColor(g2d.getColor()); _bg = toSWTColor(g2d.getBackground()); } _g2d = g2d; g2d.setRenderingHints(hints); // J2DRegistry.initGraphics(_g2d); updateStroke(); updateColors(); updateFont(); }
@Override protected void fillShape(Graphics graphics) { super.fillShape(graphics); int h = graphics.getFontMetrics().getHeight(); Rectangle r = getBounds(); if (text != null) { graphics.setForegroundColor(getForegroundColor()); int y = r.y + 2; int x = r.x + 2; for (String txt : text) { graphics.drawText(txt, x, y); y += h + 3; } } }
protected void paintMessage(Graphics graphics, Rectangle parentRect) { String message = Utils.getString(this.message, ""); List<String> text = SWTWordWrap.wrap(message, resolution.width - 24, graphics.getFont()); if (text != null && text.size() > 0){ int oneLineHeight = getMargin() + FigureUtilities.getStringExtents("X", graphics.getFont()).height; graphics.pushState(); graphics.clipRect(parentRect); int y = parentRect.y; for (int i = 0; y < parentRect.bottom() && i < text.size(); i++) { Rectangle lineRect = new Rectangle(parentRect.x, y, parentRect.width, oneLineHeight + getMargin()); Drawer.drawString(graphics, text.get(i), lineRect, Alignments.left, Alignments.top, getMargin()); y += oneLineHeight; } graphics.popState(); } }
protected void drawFunctionButtons(Graphics graphics, int height, int width, int beginWindowX, int beginWindowY) { int iconsYLocation = beginWindowY + height + 20; int homeIconWidth = 18; int menuIconWidth = 20; int searchIcon = 17; int backIcon = 28; int distanceBetween = (width - (homeIconWidth + menuIconWidth + searchIcon + backIcon)) / 3; int iconsXLocation = beginWindowX; drawBackIcon(graphics, iconsXLocation, iconsYLocation); drawMenuIcon(graphics, iconsXLocation + backIcon + distanceBetween, iconsYLocation); drawHomeIcon(graphics, iconsXLocation + backIcon + menuIconWidth + distanceBetween + distanceBetween, iconsYLocation); drawSearchIcon(graphics, iconsXLocation + backIcon + menuIconWidth + homeIconWidth + distanceBetween + distanceBetween + distanceBetween, iconsYLocation); }