@Override protected void drawText(java.awt.Graphics2D g) { if (getText() != null || isEditable()) { TextLayout layout = getTextLayout(); layout.draw(g, (float) origin.x, (float) (origin.y + layout.getAscent())); } }
void drawWidget(GC gc, RECT rect) { drawBackground(gc.handle, rect); int selStart = selection.x; int selEnd = selection.y; if (selStart > selEnd) { selStart = selection.y; selEnd = selection.x; } // temporary code to disable text selection selStart = selEnd = -1; if (!OS.IsWindowEnabled(handle)) gc.setForeground(disabledColor); layout.draw(gc, 0, 0, selStart, selEnd, null, null); if (hasFocus() && focusIndex != -1) { Rectangle[] rects = getRectangles(focusIndex); for (int i = 0; i < rects.length; i++) { Rectangle rectangle = rects[i]; gc.drawFocus(rectangle.x, rectangle.y, rectangle.width, rectangle.height); } } if (hooks(SWT.Paint) || filters(SWT.Paint)) { Event event = new Event(); event.gc = gc; event.x = rect.left; event.y = rect.top; event.width = rect.right - rect.left; event.height = rect.bottom - rect.top; sendEvent(SWT.Paint, event); event.gc = null; } }
/** * Render the View to the given graphic context. This implementation render the interior first, * then the outline. */ public void paint(Graphics2D g, Rectangle2D a) { if (!a.intersects(getBounds())) return; if (image != null) { // paint bitmap g.drawImage(image, text2ModelTr, null); // debug: g.setPaint(Color.red); g.draw(this.bounds); super.paint(g, a); // possibly paint framebox if non-null } else { // paint textlayout super.paint(g, a); // possibly paint framebox if non-null AffineTransform oldAT = g.getTransform(); // paint text in black g.setPaint(Color.black); // from now on, we work in Y-direct (<0) coordinates to avoid inextricable problems with font // being mirrored... g.transform(text2ModelTr); // also include rotation textLayout.draw(g, 0.0f, 0.0f); // [pending] ajouter un cadre si areDimensionsComputed (wysiwyg du pauvre) // get back to previous transform g.setTransform(oldAT); if (DEBUG) { g.setPaint(Color.red); g.draw(bounds); } } }
public void render(int w, int h, Graphics2D g2) { int w2 = w / 2; int h2 = h / 2; g2.setPaint(new GradientPaint(0, 0, outerC, w * .35f, h * .35f, innerC)); g2.fillRect(0, 0, w2, h2); g2.setPaint(new GradientPaint(w, 0, outerC, w * .65f, h * .35f, innerC)); g2.fillRect(w2, 0, w2, h2); g2.setPaint(new GradientPaint(0, h, outerC, w * .35f, h * .65f, innerC)); g2.fillRect(0, h2, w2, h2); g2.setPaint(new GradientPaint(w, h, outerC, w * .65f, h * .65f, innerC)); g2.fillRect(w2, h2, w2, h2); g2.setColor(Color.black); TextLayout tl = new TextLayout("GradientPaint", g2.getFont(), g2.getFontRenderContext()); tl.draw( g2, (int) (w / 2 - tl.getBounds().getWidth() / 2), (int) (h / 2 + tl.getBounds().getHeight() / 2)); }
@Override void drawWidget(GC gc) { int selStart = selection.x; int selEnd = selection.y; if (selStart > selEnd) { selStart = selection.y; selEnd = selection.x; } // temporary code to disable text selection selStart = selEnd = -1; if ((state & DISABLED) != 0) gc.setForeground(disabledColor); layout.draw(gc, 0, 0, selStart, selEnd, null, null); if (hasFocus() && focusIndex != -1) { Rectangle[] rects = getRectangles(focusIndex); for (int i = 0; i < rects.length; i++) { Rectangle rect = rects[i]; gc.drawFocus(rect.x, rect.y, rect.width, rect.height); } } }
/** * Overrides Step draw method. * * @param panel the drawing panel requesting the drawing * @param _g the graphics context on which to draw */ public void draw(DrawingPanel panel, Graphics _g) { if (track.trackerPanel == panel) { AutoTracker autoTracker = track.trackerPanel.getAutoTracker(); if (autoTracker.isInteracting(track)) return; } if (panel instanceof TrackerPanel) { TrackerPanel trackerPanel = (TrackerPanel) panel; super.draw(trackerPanel, _g); Graphics2D g = (Graphics2D) _g; if (isLabelVisible()) { TextLayout layout = textLayouts.get(trackerPanel); if (layout == null) return; Point p = getLayoutPosition(trackerPanel); Paint gpaint = g.getPaint(); Font gfont = g.getFont(); g.setPaint(footprint.getColor()); g.setFont(textLayoutFont); layout.draw(g, p.x, p.y); g.setPaint(gpaint); g.setFont(gfont); } } }