/** {@inheritDoc} */ @Override protected synchronized void fillShape(final Graphics graphics) { Rectangle figureBounds = getClientArea(); if (!transparent) { if (isEnabled()) graphics.setBackgroundColor(getBackgroundColor()); if (gradient && useAdvancedGraphics) { graphics.setForegroundColor(backGradientStartColor); graphics.fillGradient(figureBounds, horizontalFill); } else graphics.fillRectangle(figureBounds); } if (getFill() > 0) { if (isEnabled()) graphics.setBackgroundColor(getForegroundColor()); Rectangle fillRectangle; if (horizontalFill) { int newW = (int) Math.round(figureBounds.width * (getFill() / 100)); fillRectangle = new Rectangle(figureBounds.x, figureBounds.y, newW, figureBounds.height); } else { int newH = (int) Math.round(figureBounds.height * (getFill() / 100)); fillRectangle = new Rectangle( figureBounds.x, figureBounds.y + figureBounds.height - newH, figureBounds.width, newH); } if (gradient && useAdvancedGraphics) { graphics.setForegroundColor(foreGradientStartColor); graphics.fillGradient(fillRectangle, horizontalFill); } else graphics.fillRectangle(fillRectangle); } }
/* * (non-Javadoc) * * @see org.eclipse.draw2d.IFigure#paint(org.eclipse.draw2d.Graphics) */ public void paint(Graphics graphics) { if (!isVisible()) return; if (uncheckedImage != null) { if (hilite) { if (state == false) graphics.drawImage(uncheckedHiliteImage, getLocation()); else graphics.drawImage(checkedHiliteImage, getLocation()); } else { if (state == false) graphics.drawImage(uncheckedImage, getLocation()); else graphics.drawImage(checkedImage, getLocation()); } } else { Iterator<Rectangle> iter = null; if (state == false) iter = uncheckedRects.iterator(); else iter = checkedRects.iterator(); while (iter.hasNext()) { Point p = getLocation(); Rectangle r = iter.next().getCopy(); r = r.translate(p.x, p.y); graphics.setForegroundColor(getForegroundColor()); if (hilite) graphics.setBackgroundColor(ColorConstants.lightBlue); else graphics.setBackgroundColor(ColorConstants.white); graphics.fillRectangle(r); graphics.drawRectangle(r); } } }
/** * The main drawing routine. * * @param gfx The {@link Graphics} to use */ @Override public synchronized void paintFigure(final Graphics gfx) { if (isLoadingImage()) return; Rectangle bounds = getBounds().getCopy(); ImageUtils.crop(bounds, this.getInsets()); IPath imagePath = booleanValue ? onImagePath : offImagePath; if (loadingError) { if (!imagePath.isEmpty()) { gfx.setBackgroundColor(getBackgroundColor()); gfx.setForegroundColor(getForegroundColor()); gfx.fillRectangle(bounds); gfx.translate(bounds.getLocation()); TextPainter.drawText( gfx, "ERROR in loading image\n" + imagePath, bounds.width / 2, bounds.height / 2, TextPainter.CENTER); } return; } Color currentcolor = null; if (useForegroundColor) currentcolor = getForegroundColor(); else currentcolor = booleanValue ? onColor : offColor; getCurrentImage().setCurrentColor(currentcolor); getCurrentImage().setBounds(bounds); getCurrentImage().setBorder(getBorder()); getCurrentImage().setAbsoluteScale(gfx.getAbsoluteScale()); getCurrentImage().paintFigure(gfx); if (!isEnabled()) { gfx.setAlpha(DISABLED_ALPHA); gfx.setBackgroundColor(DISABLE_COLOR); gfx.fillRectangle(bounds); } }
@Override public void paint(Graphics graphics) { graphics.setBackgroundColor(NodeUtil.BG_COLOR); if (node.getGraph().getRule() != null) { Rule rule = node.getGraph().getRule(); if (!NodeUtil.nodeIsMapped(node, rule.getMappings())) { if (node.getGraph().isLhs()) graphics.setBackgroundColor(NodeUtil.BG_COLOR_DELETED); if (node.getGraph().isRhs()) graphics.setBackgroundColor(NodeUtil.BG_COLOR_CREATED); } } super.paint(graphics); }
/** @see org.eclipse.draw2d.Figure#paintFigure(Graphics) */ protected void paintFigure(Graphics g) { IMapMode mm = MapModeUtil.getMapMode(this); Rectangle displayRectangle = new Rectangle(mm.DPtoLP(15), mm.DPtoLP(11), mm.DPtoLP(31), mm.DPtoLP(25)); Rectangle displayShadow = new Rectangle(mm.DPtoLP(14), mm.DPtoLP(10), mm.DPtoLP(32), mm.DPtoLP(26)); Rectangle displayHighlight = new Rectangle(mm.DPtoLP(15), mm.DPtoLP(11), mm.DPtoLP(32), mm.DPtoLP(26)); Point valuePoint = new Point(mm.DPtoLP(16), mm.DPtoLP(10)); int Y1 = mm.DPtoLP(0); int Y2 = mm.DPtoLP(44); Rectangle r = getBounds().getCopy(); g.translate(r.getLocation()); g.fillRectangle(mm.DPtoLP(0), mm.DPtoLP(0), r.width, r.height /*- MapMode.DPtoLP(4)*/); int right = r.width - 1; g.drawLine(mm.DPtoLP(0), Y1, right, Y1); g.drawLine(mm.DPtoLP(0), Y1, mm.DPtoLP(0), Y2); g.drawLine(mm.DPtoLP(0), Y2, right, Y2); g.drawLine(right, Y1, right, Y2); // Draw the display RGB whiteColor = ColorConstants.white.getRGB(); RGB backgroundColor = getBackgroundColor().getRGB(); RGB newHightlightRGB = new RGB( (whiteColor.red + backgroundColor.red) / 2, (whiteColor.green + backgroundColor.green) / 2, (whiteColor.blue + backgroundColor.blue) / 2); g.setBackgroundColor(DiagramColorRegistry.getInstance().getColor(newHightlightRGB)); g.fillRectangle(displayHighlight); RGB blackColor = ColorConstants.black.getRGB(); RGB newShadowRGB = new RGB( (blackColor.red + backgroundColor.red) / 2, (blackColor.green + backgroundColor.green) / 2, (blackColor.blue + backgroundColor.blue) / 2); g.setBackgroundColor(DiagramColorRegistry.getInstance().getColor(newShadowRGB)); g.fillRectangle(displayShadow); g.setBackgroundColor(ColorConstants.black); g.fillRectangle(displayRectangle); // Draw the value g.setForegroundColor(getFontColor()); g.drawText(value, valuePoint); }
@Override protected void paintFigure(Graphics graphics) { graphics.setAntialias(SWT.ON); Rectangle bounds = getBounds().getCopy(); graphics.setForegroundColor(getFillColor()); graphics.setBackgroundColor(ColorFactory.getLighterColor(getFillColor(), 0.9f)); graphics.fillGradient(bounds, false); // Border if (getBorderColor() != null) { graphics.setForegroundColor(ColorFactory.getLighterColor(getBorderColor(), 0.82f)); graphics.drawLine(bounds.x, bounds.y, bounds.x + bounds.width - 1, bounds.y); graphics.drawLine( bounds.x + bounds.width - 1, bounds.y, bounds.x + bounds.width - 1, bounds.y + bounds.height - 1); graphics.setForegroundColor(getBorderColor()); graphics.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + bounds.height - 1); graphics.drawLine( bounds.x, bounds.y + bounds.height - 1, bounds.x + bounds.width - 1, bounds.y + bounds.height - 1); } fIconicDelegate.drawIcon(graphics, bounds); }
/** * Fills the circle. * * @param graphics the graphics * @see org.eclipse.draw2d.Shape#fillShape(org.eclipse.draw2d.Graphics) */ protected void fillShape(Graphics graphics) { graphics.pushState(); graphics.setBackgroundColor(ColorConstants.white); graphics.fillOval(getBounds()); graphics.popState(); Dimension dim = new Dimension(20, 20); this.setMaximumSize(dim); }
@Override protected void fillShape(Graphics graphics) { if (shouldUseGradient()) { graphics.pushState(); graphics.setBackgroundColor(DiagramColorConstants.white); graphics.setForegroundColor(getBackgroundColor()); graphics.fillGradient(getBounds(), true); graphics.popState(); } else { super.fillShape(graphics); } }
/** * If the rendering is occuring on a separate thread, this method is a hook to draw a temporary * image onto the drawing surface. * * @param g the <code>Graphics</code> object to paint the temporary image to */ protected void paintFigureWhileRendering(Graphics g) { Rectangle area = getClientArea().getCopy(); g.pushState(); g.setBackgroundColor(ColorConstants.white); g.fillRectangle(area.x, area.y, area.width - 1, area.height - 1); g.setForegroundColor(ColorConstants.red); g.drawRectangle(area.x, area.y, area.width - 1, area.height - 1); g.setLineStyle(SWT.LINE_DOT); g.drawLine(area.x, area.y, area.x + area.width, area.y + area.height); g.drawLine(area.x + area.width, area.y, area.x, area.y + area.height); g.popState(); }
@Override protected void paintFigure(final org.eclipse.draw2d.Graphics graphics) { if (!getBackgroundColor().isDisposed()) { graphics.setBackgroundColor(getBackgroundColor()); } final int boxWidth = getBounds().height / HALF; final int laneYStart = getBounds().y; final int y = laneYStart + boxWidth / HALF; graphics.fillRectangle(3, y, boxWidth, boxWidth); graphics.drawRectangle(3, y, boxWidth, boxWidth); final int textXOffset = getBounds().height; graphics.drawString(user.getName(), textXOffset, laneYStart); }
@Override public void paintFigure(Graphics g) { Rectangle r = getBounds(); r.shrink(1, 1); try { g.setBackgroundColor(getFillColor()); g.fillOval(r); g.setForegroundColor(getLineColor()); g.drawOval(r); } finally { // We don't really own rect 'r', so fix it. r.expand(1, 1); } }
@Override public void paintFigure(Graphics graphics) { graphics.pushState(); graphics.setAntialias(SWT.ON); if (!isEnabled()) { setDisabledState(graphics); } graphics.setBackgroundColor(getFillColor()); graphics.fillOval(bounds.getCopy()); graphics.popState(); }
protected void paintFigure(Graphics g) { super.paintFigure(g); Rectangle bounds = getBounds(); Rectangle nameBounds = getContentPane(1).getBounds(); Rectangle r = Rectangle.SINGLETON; r.setLocation(nameBounds.x - 3, nameBounds.y); r.setSize(bounds.width - 4, nameBounds.height); g.setBackgroundColor(FigurePrefs.lightBlueColor); g.fillRectangle(r); int baseline = getLayoutManager().getBaseline(0) + 1; Rectangle ruleBounds = getContentPane(0).getClientArea(); g.setForegroundColor(FigurePrefs.relationsColor); g.drawLine(bounds.x, baseline, ruleBounds.x, baseline); g.drawLine(ruleBounds.right() - 1, baseline, bounds.right(), baseline); }
public void drawIcon(Graphics graphics, Point origin) { graphics.pushState(); graphics.setLineWidth(1); // fills graphics.setForegroundColor(blue3); graphics.setBackgroundColor(blue4); graphics.fillGradient(origin.x, origin.y, 5, 5, true); graphics.fillGradient(origin.x, origin.y + 9, 5, 5, true); graphics.setForegroundColor(blue1); // squares graphics.drawRectangle(origin.x, origin.y, 5, 5); graphics.drawRectangle(origin.x, origin.y + 9, 5, 5); graphics.drawRectangle(origin.x + 8, origin.y + 6, 2, 2); // little square // lines graphics.translate(7, 2); graphics.setForegroundColor(blue2); graphics.drawLine(origin.x, origin.y, origin.x + 6, origin.y); graphics.translate(0, 1); graphics.setForegroundColor(blue1); graphics.drawLine(origin.x, origin.y, origin.x + 6, origin.y); graphics.translate(0, 8); graphics.setForegroundColor(blue2); graphics.drawLine(origin.x, origin.y, origin.x + 6, origin.y); graphics.translate(0, 1); graphics.setForegroundColor(blue1); graphics.drawLine(origin.x, origin.y, origin.x + 6, origin.y); // small line graphics.translate(4, -5); graphics.setForegroundColor(blue1); graphics.drawLine(origin.x, origin.y, origin.x + 2, origin.y); graphics.popState(); }
@Override protected void fillShape(Graphics graphics) { graphics.setAntialias(SWT.ON); Pattern pattern = null; graphics.setBackgroundColor(GRAY_COLOR); boolean support3D = GraphicsUtil.testPatternSupported(graphics); if (effect3D && support3D) { // add this to eliminate the repaint bug on Mac graphics.fillOval(new Rectangle()); pattern = new Pattern( Display.getCurrent(), bounds.x, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height, WHITE_COLOR, BORDER_COLOR); graphics.setBackgroundPattern(pattern); } super.fillShape(graphics); if (effect3D && support3D) pattern.dispose(); }
/* * (non-Javadoc) * * @see org.eclipse.draw2d.Shape#paintFigure(org.eclipse.draw2d.Graphics) */ public void paintFigure(Graphics graphics) { graphics.setAntialias(SWT.LOW); super.paintFigure(graphics); graphics.pushState(); graphics.setBackgroundColor(ColorConstants.black); /* Creates the cross in the circle */ Rectangle rect1 = getBounds().getCopy(); int scaleFactor_horizontale = rect1.height / 2; int scaleFactor_verticale = rect1.width / 2; Rectangle rect = getBounds().getCopy(); graphics.drawLine( rect1.x, rect1.y + scaleFactor_horizontale, rect1.x + (int) Math.floor(rect1.width * (scaleFactor_horizontale)), rect1.y - (1 - scaleFactor_horizontale)); graphics.drawLine( rect1.x + scaleFactor_verticale, rect1.y, rect1.x - (1 - scaleFactor_verticale), rect1.y + (int) Math.floor(rect1.height * (scaleFactor_verticale))); graphics.popState(); }
/** Draw the icon */ protected void drawIcon(Graphics graphics) { graphics.setLineWidth(1); graphics.setForegroundColor(ColorConstants.black); graphics.setBackgroundColor(ColorConstants.black); Point pt = getIconOrigin(); Path path = new Path(null); graphics.setLineWidthFloat(1.2f); path.addArc(pt.x, pt.y, 13, 13, 0, 360); graphics.drawPath(path); path.dispose(); graphics.fillOval(pt.x + 5, pt.y + 5, 4, 4); graphics.setLineWidth(1); path = new Path(null); path.moveTo(pt.x - 2, pt.y + 6.5f); path.lineTo(pt.x + 15, pt.y + 6.5f); path.moveTo(pt.x + 6.5f, pt.y - 2); path.lineTo(pt.x + 6.5f, pt.y + 15); path.moveTo(pt.x + 0.5f, pt.y + 0.5f); path.lineTo(pt.x + 12.5f, pt.y + 12.5f); path.moveTo(pt.x + 0.5f, pt.y + 12.5f); path.lineTo(pt.x + 12.5f, pt.y + 0.5f); graphics.drawPath(path); path.dispose(); }
/** @see org.eclipse.draw2d.Figure#paintFigure(Graphics) */ protected void paintFigure(Graphics g) { g.setXORMode(true); g.setForegroundColor(ColorConstants.white); g.setBackgroundColor(LogicColorConstants.ghostFillColor); Rectangle r = getBounds().getCopy(); g.fillOval(r); r.height--; r.width--; g.drawOval(r); g.translate(r.getLocation()); // Draw the "V" g.drawLine(3, 4, 5, 9); g.drawLine(5, 9, 7, 4); g.drawLine(5, 8, 5, 9); // Draw the "+" g.drawLine(9, 7, 9, 11); g.drawLine(7, 9, 11, 9); g.drawPoint(9, 9); }
@Override protected void fillShape(Graphics graphics) { int fill_corner = DEFAULT_CORNER; // If this is more close to 1/2, more light the tank will be. double intersectFactor = 11d / 20d; if (bounds.width < 2 * DEFAULT_CORNER) intersectFactor = 12d / 20d; int rectWidth = (int) (bounds.width * intersectFactor); if (fill_corner > (2 * rectWidth - (bounds.width - 2 * getLineWidth()))) fill_corner = 2 * rectWidth - bounds.width; corner.height = fill_corner; corner.width = fill_corner; graphics.setAntialias(SWT.ON); int valuePosition = ((LinearScale) scale).getValuePosition(getCoercedValue(), false); if (support3d == null) support3d = GraphicsUtil.testPatternSupported(graphics); if (effect3D && support3d) { graphics.setBackgroundColor(WHITE_COLOR); super.fillShape(graphics); // fill background Rectangle leftRectangle = new Rectangle(bounds.x, bounds.y, rectWidth, bounds.height); Pattern leftGradientPattern = GraphicsUtil.createScaledPattern( graphics, Display.getCurrent(), leftRectangle.x, leftRectangle.y, leftRectangle.x + leftRectangle.width + 2, leftRectangle.y, fillBackgroundColor, 255, WHITE_COLOR, 0); graphics.setBackgroundPattern(leftGradientPattern); graphics.fillRoundRectangle(leftRectangle, corner.width, corner.height); Rectangle rightRectangle = new Rectangle(bounds.x + bounds.width - rectWidth, bounds.y, rectWidth, bounds.height); Pattern rightGradientPattern = GraphicsUtil.createScaledPattern( graphics, Display.getCurrent(), rightRectangle.x - 2, rightRectangle.y, rightRectangle.x + rightRectangle.width, rightRectangle.y, WHITE_COLOR, 0, fillBackgroundColor, 255); graphics.setBackgroundPattern(rightGradientPattern); graphics.fillRoundRectangle(rightRectangle, corner.width, corner.height); leftGradientPattern.dispose(); rightGradientPattern.dispose(); // fill value graphics.setBackgroundColor(WHITE_COLOR); int fillHeight = bounds.height - (valuePosition - bounds.y) - getLineWidth(); if (fillHeight > 0) { graphics.fillRoundRectangle( new Rectangle(bounds.x, valuePosition, bounds.width, fillHeight), fill_corner, fill_corner); leftRectangle = new Rectangle(bounds.x, valuePosition, rectWidth, fillHeight); leftGradientPattern = GraphicsUtil.createScaledPattern( graphics, Display.getCurrent(), leftRectangle.x, leftRectangle.y, leftRectangle.x + leftRectangle.width + 2, leftRectangle.y, fillColor, 255, WHITE_COLOR, 0); graphics.setBackgroundPattern(leftGradientPattern); graphics.fillRoundRectangle(leftRectangle, fill_corner, fill_corner); rightRectangle = new Rectangle( bounds.x + bounds.width - rectWidth, valuePosition, rectWidth, fillHeight); rightGradientPattern = GraphicsUtil.createScaledPattern( graphics, Display.getCurrent(), rightRectangle.x - 2, rightRectangle.y, rightRectangle.x + rightRectangle.width, rightRectangle.y, WHITE_COLOR, 0, fillColor, 255); graphics.setBackgroundPattern(rightGradientPattern); graphics.fillRoundRectangle(rightRectangle, fill_corner, fill_corner); leftGradientPattern.dispose(); rightGradientPattern.dispose(); } graphics.setForegroundColor(EFFECT3D_OUTLINE_COLOR); } else { graphics.setBackgroundColor(fillBackgroundColor); super.fillShape(graphics); graphics.setBackgroundColor(fillColor); graphics.fillRoundRectangle( new Rectangle( bounds.x + lineWidth, valuePosition, bounds.width - 2 * lineWidth, bounds.height - (valuePosition - bounds.y)), fill_corner, fill_corner); // graphics.setForegroundColor(outlineColor); } }
@Override protected void paintClientArea(Graphics graphics) { graphics.setAntialias(SWT.ON); Rectangle area = getClientArea(); area.width = Math.min(area.width, area.height); area.height = area.width; Pattern pattern = null; graphics.pushState(); graphics.setBackgroundColor(GRAY_COLOR); boolean support3D = GraphicsUtil.testPatternSupported(graphics); if (effect3D && support3D) { // add this to eliminate the repaint bug on Mac graphics.fillOval(new Rectangle()); pattern = new Pattern( Display.getCurrent(), area.x, area.y, area.x + area.width, area.y + area.height, BORDER_COLOR, WHITE_COLOR); graphics.setBackgroundPattern(pattern); } graphics.fillOval(area); graphics.popState(); if (effect3D && support3D) { pattern.dispose(); area.shrink(BORDER_WIDTH, BORDER_WIDTH); } else area.shrink(1, 1); graphics.fillOval(area); super.paintClientArea(graphics); // glossy effect if (effect3D && support3D) { graphics.pushState(); graphics.setAntialias(SWT.ON); final double R = area.width / 2.0d; final double UD_FILL_PART = 9.5d / 10d; final double UP_DOWN_RATIO = 1d / 2d; final double LR_FILL_PART = 8.5d / 10d; final double UP_ANGLE = 0d * Math.PI / 180d; final double DOWN_ANGLE = 35d * Math.PI / 180d; // add this to eliminate the repaint bug on Mac graphics.fillOval(new Rectangle()); Pattern glossyPattern = new Pattern( Display.getCurrent(), area.x + area.width / 2, (float) (area.y + area.height / 2 - R * UD_FILL_PART), area.x + area.width / 2, (float) (area.y + area.height / 2 + R * UP_DOWN_RATIO), WHITE_COLOR, 90, WHITE_COLOR, 0); graphics.setBackgroundPattern(glossyPattern); Rectangle rectangle = new Rectangle( (int) (area.x + area.width / 2 - R * LR_FILL_PART * Math.cos(UP_ANGLE)), (int) (area.y + area.height / 2 - R * UD_FILL_PART), (int) (2 * R * LR_FILL_PART * Math.cos(UP_ANGLE)), (int) (R * UD_FILL_PART + R * UP_DOWN_RATIO)); graphics.fillOval(rectangle); glossyPattern.dispose(); glossyPattern = new Pattern( Display.getCurrent(), area.x + area.width / 2, (float) (area.y + area.height / 2 + R * UP_DOWN_RATIO - 1), area.x + area.width / 2, (float) (area.y + area.height / 2 + R * UD_FILL_PART + 1), WHITE_COLOR, 0, WHITE_COLOR, 40); graphics.setBackgroundPattern(glossyPattern); rectangle = new Rectangle( (int) (area.x + area.width / 2 - R * LR_FILL_PART * Math.sin(DOWN_ANGLE)), (int) Math.ceil(area.y + area.height / 2 + R * UP_DOWN_RATIO), (int) (2 * R * LR_FILL_PART * Math.sin(DOWN_ANGLE)), (int) Math.ceil(R * UD_FILL_PART - R * UP_DOWN_RATIO)); graphics.fillOval(rectangle); glossyPattern.dispose(); graphics.popState(); } }
@Override protected void paintClientArea(Graphics graphics) { updateThresholdPosition(); graphics.setAntialias(SWT.ON); graphics.setLineWidth(rampWidth); graphics.pushState(); int overlap = 0; Pattern pattern = null; boolean support3D = GraphicsUtil.testPatternSupported(graphics); // draw lolo part if (lolo.visible) { graphics.setBackgroundColor(lolo.color); graphics.fillArc(bounds, lolo.absolutePosition, min.relativePosition - lolo.relativePosition); } // draw lo part if (lo.visible) { if (support3D && gradient && lolo.visible) { try { pattern = new Pattern( Display.getCurrent(), lolo.leftPoint.x, lolo.leftPoint.y, lo.rightPoint.x, lo.rightPoint.y, lolo.color, lo.color); graphics.setBackgroundPattern(pattern); overlap = OVERLAP_DEGREE / 2; } catch (Exception e) { support3D = false; pattern.dispose(); graphics.setBackgroundColor(lo.color); overlap = 0; } } else { graphics.setBackgroundColor(lo.color); overlap = 0; } if (lolo.visible) graphics.fillArc( bounds, lo.absolutePosition, lolo.relativePosition - lo.relativePosition + overlap); else graphics.fillArc(bounds, lo.absolutePosition, min.relativePosition - lo.relativePosition); if (gradient && lolo.visible && support3D) pattern.dispose(); } // draw left normal part // get the left marker boolean leftMarkerVisible = false; ThresholdMarker leftMarker = null; if (lo.visible) { leftMarkerVisible = true; leftMarker = lo; } else if (lolo.visible) { leftMarkerVisible = true; leftMarker = lolo; } else leftMarkerVisible = false; if (gradient && leftMarkerVisible && support3D) { pattern = new Pattern( Display.getCurrent(), leftMarker.leftPoint.x, leftMarker.leftPoint.y, normal.rightPoint.x, normal.rightPoint.y, leftMarker.color, normal.color); graphics.setBackgroundPattern(pattern); overlap = OVERLAP_DEGREE / 2; } else { graphics.setBackgroundColor(normal.color); overlap = 0; } if (leftMarkerVisible) graphics.fillArc( bounds, normal.absolutePosition, leftMarker.relativePosition - normal.relativePosition + overlap); else graphics.fillArc( bounds, normal.absolutePosition, min.relativePosition - normal.relativePosition); if (gradient && leftMarkerVisible && support3D) pattern.dispose(); // draw right normal part // get the right marker boolean rightMarkerVisible = false; ThresholdMarker rightMarker = null; if (hi.visible) { rightMarkerVisible = true; rightMarker = hi; } else if (hihi.visible) { rightMarkerVisible = true; rightMarker = hihi; } else rightMarkerVisible = false; if (gradient && rightMarkerVisible && support3D) { pattern = new Pattern( Display.getCurrent(), rightMarker.rightPoint.x, rightMarker.rightPoint.y, normal.leftPoint.x, normal.leftPoint.y, rightMarker.color, normal.color); graphics.setBackgroundPattern(pattern); overlap = OVERLAP_DEGREE / 2; } else { graphics.setBackgroundColor(normal.color); overlap = 0; } if (rightMarkerVisible) graphics.fillArc( bounds, rightMarker.absolutePosition, normal.relativePosition - rightMarker.relativePosition + overlap + 1); else graphics.fillArc( bounds, max.absolutePosition, normal.relativePosition - max.relativePosition + 1); if (gradient && rightMarkerVisible && support3D) pattern.dispose(); // draw hi part if (hi.visible) { if (hihi.visible) { rightMarkerVisible = true; rightMarker = hihi; } else rightMarkerVisible = false; if (gradient && rightMarkerVisible && support3D) { pattern = new Pattern( Display.getCurrent(), rightMarker.rightPoint.x, rightMarker.rightPoint.y, hi.leftPoint.x, hi.leftPoint.y, rightMarker.color, hi.color); graphics.setBackgroundPattern(pattern); overlap = OVERLAP_DEGREE / 2; } else { graphics.setBackgroundColor(hi.color); overlap = 0; } if (rightMarkerVisible) graphics.fillArc( bounds, rightMarker.absolutePosition, hi.relativePosition - rightMarker.relativePosition + overlap); else graphics.fillArc(bounds, max.absolutePosition, hi.relativePosition - max.relativePosition); if (gradient && rightMarkerVisible && support3D) pattern.dispose(); } // draw hihi part if (hihi.visible) { if (gradient && support3D) overlap = OVERLAP_DEGREE / 2; else overlap = 0; graphics.setBackgroundColor(hihi.color); graphics.fillArc( bounds, max.absolutePosition, hihi.relativePosition - max.relativePosition + overlap); } graphics.popState(); graphics.fillOval( bounds.x + rampWidth, bounds.y + rampWidth, bounds.width - 2 * rampWidth, bounds.height - 2 * rampWidth); super.paintClientArea(graphics); }
@Override protected void drawSymbol(Graphics g) { PointList points = null; super.drawSymbol(g); int centerPointX = (int) Math.ceil((H_EXTENT / 2.0f)); // Center point of odd #. switch (this.featureCategory) { case BUS_ACCESS: case DATA_ACCESS: // Configure GC. g.setForegroundColor(this.getForegroundColor()); g.setBackgroundColor(ColorConstants.white); g.setLineWidth(2); // Create point list that defines the symbol. points = new PointList(); /* Populate point list. */ points.addPoint(centerPointX, 0); points.addPoint(0, V_EXTENT - 8); points.addPoint(0, V_EXTENT); points.addPoint(centerPointX, V_EXTENT - 2); points.addPoint(H_EXTENT, V_EXTENT); points.addPoint(H_EXTENT, V_EXTENT - 8); // Fill symbol. g.fillPolygon(points); // Draw symbol. g.drawPolygon(points); break; case SUBPROGRAM_ACCESS: case SUBPROGRAM_GROUP_ACCESS: // Configure GC if (this.featureCategory == FeatureAdapterCategory.SUBPROGRAM_ACCESS) { g.setBackgroundColor(ColorConstants.white); g.setForegroundColor(ColorConstants.black); } else { g.setBackgroundColor(ColorConstants.black); g.setForegroundColor(ColorConstants.white); } g.setLineCap(SWT.CAP_ROUND); g.setLineWidth(2); int ovalWidth = H_EXTENT; int ovalHeight = V_EXTENT; // Draw oval. Rectangle ovalRect = new Rectangle( (int) (0.5f * (H_EXTENT - ovalWidth)), (int) (0.5f * (V_EXTENT - ovalHeight)), ovalWidth, ovalHeight); g.fillOval(ovalRect); if (this.featureCategory == FeatureAdapterCategory.SUBPROGRAM_ACCESS) g.drawOval(ovalRect); int triangleWidth = 7; int triangleHeight = 5; int triangleStartX = (int) Math.ceil((0.5f * (H_EXTENT - triangleWidth))); int triangleStartY = (int) Math.ceil((0.5f * (V_EXTENT - triangleHeight))); // Draw triangle. g.drawLine(triangleStartX, triangleStartY, centerPointX, triangleStartY + triangleHeight); g.drawLine( triangleStartX + triangleWidth, triangleStartY, centerPointX, triangleStartY + triangleHeight); break; } }