Paints text on the graph.
773016
def draw_text(data, obj):
    
    content = []
    properties = []
    style = []
    if isinstance(obj, mpl.text.Annotation):
        _annotation(obj, data, content)

    # 1: coordinates
    # 2: properties (shapes, rotation, etc)
    # 3: text style
    # 4: the text
    #                   -------1--------2---3--4--
    pos = obj.get_position()

    # from .util import transform_to_data_coordinates
    # pos = transform_to_data_coordinates(obj, *pos)

    text = obj.get_text()

    if text in ["", data["current axis title"]]:
        # Text nodes which are direct children of Axes are typically titles.  They are
        # already captured by the `title` property of pgfplots axes, so skip them here.
        return data, content

    size = obj.get_size()
    bbox = obj.get_bbox_patch()
    converter = mpl.colors.ColorConverter()
    # without the factor 0.5, the fonts are too big most of the time.
    # TODO fix this
    scaling = 0.5 * size / data["font size"]
    ff = data["float format"]
    if scaling != 1.0:
        properties.append(("scale=" + ff).format(scaling))

    if bbox is not None:
        _bbox(bbox, data, properties, scaling)

    ha = obj.get_ha()
    va = obj.get_va()
    anchor = _transform_positioning(ha, va)
    if anchor is not None:
        properties.append(anchor)
    data, col, _ = color.mpl_color2xcolor(data, converter.to_rgb(obj.get_color()))
    properties.append("text={}".format(col))
    properties.append("rotate={:.1f}".format(obj.get_rotation()))

    if obj.get_style() == "italic":
        style.append("\\itshape")
    else:
        assert obj.get_style() == "normal"

    # From matplotlib/font_manager.py:
    # weight_dict = {
    #     'ultralight' : 100,
    #     'light'      : 200,
    #     'normal'     : 400,
    #     'regular'    : 400,
    #     'book'       : 400,
    #     'medium'     : 500,
    #     'roman'      : 500,
    #     'semibold'   : 600,
    #     'demibold'   : 600,
    #     'demi'       : 600,
    #     'bold'       : 700,
    #     'heavy'      : 800,
    #     'extra bold' : 800,
    #     'black'      : 900}
    #
    # get_weights returns a numeric value in the range 0-1000 or one of
    # ‘light’, ‘normal’, ‘regular’, ‘book’, ‘medium’, ‘roman’, ‘semibold’,
    # ‘demibold’, ‘demi’, ‘bold’, ‘heavy’, ‘extra bold’, ‘black’
    weight = obj.get_weight()
    if weight in [
        "semibold",
        "demibold",
        "demi",
        "bold",
        "heavy",
        "extra bold",
        "black",
    ] or (isinstance(weight, int) and weight > 550):
        style.append("\\bfseries")

    # \lfseries isn't that common yet
    # elif weight == 'light' or (isinstance(weight, int) and weight < 300):
    #     style.append('\\lfseries')

    if obj.axes:
        # If the coordinates are relative to an axis, use `axis cs`.
        tikz_pos = ("(axis cs:" + ff + "," + ff + ")").format(*pos)
    else:
        # relative to the entire figure, it's a getting a littler harder. See
        # <http://tex.stackexchange.com/a/274902/13262> for a solution to the
        # problem:
        tikz_pos = (
            "({{$(current bounding box.south west)!" + ff + "!"
            "(current bounding box.south east)$}}"
            "|-"
            "{{$(current bounding box.south west)!" + ff + "!"
            "(current bounding box.north west)$}})"
        ).format(*pos)

    if "\n" in text:
        # http://tex.stackexchange.com/a/124114/13262
        properties.append("align={}".format(ha))
        # Manipulating the text here is actually against mpl2tikz's policy not
        # to do that. On the other hand, newlines should translate into
        # newlines.
        # We might want to remove this here in the future.
        text = text.replace("\n ", "\\\\")

    content.append(
        "\\node at {}[\n  {}\n]{{{}}};\n".format(
            tikz_pos, ",\n  ".join(properties), " ".join(style + [text])
        )
    )
    return data, content
1179589
public void paint (Graphics2D gfx)
    {
        gfx.setColor(Color.red);
        gfx.drawLine(_source.x, _source.y, _dest.x, _dest.y);
    }
186771
def paintEvent(self, event):
        
        super(XTextEdit, self).paintEvent(event)
        
        if self.document().isEmpty() and self.hint():
            text    = self.hint()
            rect    = self.rect()
            
            # modify the padding on the rect
            rect.setX(4)
            rect.setY(4)
            align = int(Qt.AlignLeft | Qt.AlignTop)
            
            # setup the coloring options
            clr = self.hintColor()
            
            # paint the hint
            with XPainter(self.viewport()) as painter:
                painter.setPen(clr)
                painter.drawText(rect, align | Qt.TextWordWrap, text)
1229980
public void drawString(String str, float x, float y) {
		predraw();
		font.drawString(x, y, str, currentColor);
		postdraw();
	}
330300
def paintEvent(self, event):
        
        super(XListWidget, self).paintEvent(event)
        
        if not self.visibleCount() and self.hint():
            text    = self.hint()
            rect    = self.rect()
            
            # modify the padding on the rect
            w = min(250, rect.width() - 30)
            x = (rect.width() - w) / 2
            
            rect.setX(x)
            rect.setY(rect.y() + 15)
            rect.setWidth(w)
            rect.setHeight(rect.height() - 30)
            
            align = int(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignTop)
            
            # setup the coloring options
            clr     = self.hintColor()
            
            # paint the hint
            with XPainter(self.viewport()) as painter:
                painter.setPen(clr)
                painter.drawText(rect, align | QtCore.Qt.TextWordWrap, text)
455922
public void paint(Graphics g, int p0, int p1, Shape bounds, JTextComponent c)
	{
		try
		{
			Rectangle r = c.modelToView(c.getCaretPosition());
			g.setColor( color );
			g.fillRect(0, r.y, c.getWidth(), r.height);

			if (lastView == null)
				lastView = r;
		}
		catch(BadLocationException ble) {System.out.println(ble);}
	}
934295
def _decorate(self):
        """"""
        self._set_view()
        self._make_graph()
        self._axes()
        self._legend()
        self._make_title()
        self._make_x_title()
        self._make_y_title()
1282554
def draw_plot(self, metrics, labels=None, ylabel=""):
        
        metrics = metrics if isinstance(metrics, list) else [metrics]
        # Loop through metrics
        title = ""
        for i, m in enumerate(metrics):
            label = labels[i] if labels else m.name
            # TODO: use a standard formating function for values
            title += ("   " if title else "") + "{}: {}".format(label, m.data[-1])
            self.ax.plot(m.formatted_steps, m.data, label=label)
        self.ax.set_title(title)
        self.ax.set_ylabel(ylabel)
        self.ax.legend()
        self.ax.set_xlabel("Steps")
        self.ax.xaxis.set_major_locator(plt.AutoLocator())
410840
public void paintValue(Graphics gfx, Rectangle box) {
    FontMetrics 	fm;
    int 					vpad;
    String 				val;

    fm   = gfx.getFontMetrics();
    vpad = (box.height - fm.getHeight()) / 2 ;
    val  = ((ClassOption) getValue()).getValueAsCLIString();
    gfx.drawString(val, 2, fm.getHeight() + vpad);
  }
776190
@Override
    public void drawText(Graphics2D graphics, int width, int height) {
        if(StringUtils.isBlank(text) || StringUtils.isBlank(domainName)) {
            return ;
        }
        
        int x = 0, y = 0; 
        int fontsize = ((int)(width * textWidthPercent)) / domainName.length();
        if (fontsize < minFontSize) {
            return;
        }
        
        float fsize = (float)fontsize;
        Font font = domainFont.deriveFont(fsize);
        graphics.setFont(font);
        FontRenderContext context = graphics.getFontRenderContext();
        int sw = (int) font.getStringBounds(domainName, context).getWidth();

        x = width - sw - fontsize;
        y = height - fontsize;
        if(x <= 0 || y <= 0) {
            return ;
        }

        if (fontShadowColor != null) {
            graphics.setColor(fontShadowColor);
            graphics.drawString(domainName, x + getShadowTranslation(fontsize), y + getShadowTranslation(fontsize));
        }
        graphics.setColor(fontColor);
        graphics.drawString(domainName, x, y);
        
        //draw company name
        fsize = (float)fontsize;
        font = defaultFont.deriveFont(fsize);
        graphics.setFont(font);
        context = graphics.getFontRenderContext();
        sw = (int) font.getStringBounds(text, context).getWidth();
        x = width - sw - fontsize;
        y = height - (int)(fontsize * 2.5);
        if(x <= 0 || y <= 0) {
            return ;
        }
        
        if (fontShadowColor != null) {
            graphics.setColor(fontShadowColor);
            graphics.drawString(text, x + getShadowTranslation(fontsize), y + getShadowTranslation(fontsize));
        }
        graphics.setColor(fontColor);
        graphics.drawString(text, x, y);
    }
1245116
def add_text(self, text, x, y, side='left', size=None,
                 rotation=None, ha='left', va='center',
                 family=None, **kws):
        """"""
        axes = self.axes
        if side == 'right':
            axes = self.get_right_axes()
        dynamic_size = False
        if size is None:
            size = self.conf.legendfont.get_size()
            dynamic_size = True
        t = axes.text(x, y, text, ha=ha, va=va, size=size,
                      rotation=rotation, family=family, **kws)
        self.conf.added_texts.append((dynamic_size, t))
        self.draw()
1238432
protected void paint (Graphics2D gfx, int x, int y, RadialMenu menu)
    {
        paint(gfx, x, y, UIManager.getColor("RadialLabelSausage.background"), menu);
    }
357488
def _draw_text(self, pos, text, font, **kw):
        
        self.drawables.append((pos, text, font, kw))
789615
protected void paint(SynthContext context, Graphics g) {
        JToolTip tip = (JToolTip) context.getComponent();

        Insets insets = tip.getInsets();
        View v = (View) tip.getClientProperty(BasicHTML.propertyKey);
        if (v != null) {
            Rectangle paintTextR = new Rectangle(insets.left, insets.top, tip.getWidth() - (insets.left + insets.right), tip.getHeight()
                    - (insets.top + insets.bottom));
            v.paint(g, paintTextR);
        } else {
            g.setColor(context.getStyle().getColor(context, ColorType.TEXT_FOREGROUND));
            g.setFont(style.getFont(context));
            context.getStyle().getGraphicsUtils(context).paintText(context, g, tip.getTipText(), insets.left, insets.top, -1);
        }
    }
213824
function () {
		var series = this,
			options = this.options,
			props = [['graph', options.lineColor || this.color]],
			lineWidth = options.lineWidth,
			dashStyle =  options.dashStyle,
			graphPath = this.getGraphPath(),
			negativeColor = options.negativeColor;
			
		if (negativeColor) {
			props.push(['graphNeg', negativeColor]);
		}
		
		// draw the graph
		each(props, function (prop, i) {
			var graphKey = prop[0],
				graph = series[graphKey],
				attribs;
			
			if (graph) {
				stop(graph); // cancel running animations, #459
				graph.animate({ d: graphPath });
	
			} else if (lineWidth && graphPath.length) { // #1487
				attribs = {
					stroke: prop[1],
					'stroke-width': lineWidth,
					zIndex: 1 // #1069
				};
				if (dashStyle) {
					attribs.dashstyle = dashStyle;
				} else {
					attribs['stroke-linecap'] = attribs['stroke-linejoin'] = 'round';
				}

				series[graphKey] = series.chart.renderer.path(graphPath)
					.attr(attribs)
					.add(series.group)
					.shadow(!i && options.shadow);
			}
		});
	}
837105
@Override
    protected void paintComponent(Graphics g) {
        if (!isInitialized()) {
            return;
        }

        final Graphics2D G2 = (Graphics2D) g.create();

        G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        G2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        G2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
        G2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

        G2.translate(getFramelessOffset().getX(), getFramelessOffset().getY());

        final AffineTransform OLD_TRANSFORM = G2.getTransform();

        // Draw combined background image
        G2.drawImage(bImage, 0, 0, null);

        // Highlight active area
        if (isHighlightArea()) {
            for(Section area : getAreas()) {
                if (area.contains(getValue())) {
                    G2.setColor(area.getHighlightColor());
                    G2.fill(area.getFilledArea());
                    break;
                }
            }
        }

        // Highlight active section
        if (isHighlightSection()) {
            for(Section section : getSections()) {
                if (section.contains(getValue())) {
                    G2.setColor(section.getHighlightColor());
                    G2.fill(section.getSectionArea());
                    break;
                }
            }
        }

        // Draw title
        final FontRenderContext RENDER_CONTEXT = new FontRenderContext(null, true, true);
        if (!getTitle().isEmpty()) {
            if (isLabelColorFromThemeEnabled()) {
                G2.setColor(getBackgroundColor().LABEL_COLOR);
            } else {
                G2.setColor(getLabelColor());
            }

            // Use custom font if selected
            if (isTitleAndUnitFontEnabled()) {
                G2.setFont(new Font(getTitleAndUnitFont().getFamily(), 0, (int) (0.04672897196261682 * getGaugeBounds().width)));
            } else {
                G2.setFont(new Font("Verdana", 0, (int) (0.04672897196261682 * getGaugeBounds().width)));
            }
            final TextLayout TITLE_LAYOUT = new TextLayout(getTitle(), G2.getFont(), RENDER_CONTEXT);
            final Rectangle2D TITLE_BOUNDARY = TITLE_LAYOUT.getBounds();
            G2.drawString(getTitle(), (float) ((getGaugeBounds().width - TITLE_BOUNDARY.getWidth()) / 2), titleOffsetYFactor * getGaugeBounds().height + TITLE_LAYOUT.getAscent() - TITLE_LAYOUT.getDescent());
        }

        // Draw unit string
        if (!getUnitString().isEmpty()) {
            if (isLabelColorFromThemeEnabled()) {
                G2.setColor(getBackgroundColor().LABEL_COLOR);
            } else {
                G2.setColor(getLabelColor());
            }

            // Use custom font if selected
            if (isTitleAndUnitFontEnabled()) {
                G2.setFont(new Font(getTitleAndUnitFont().getFamily(), 0, (int) (0.04672897196261682 * getGaugeBounds().width)));
            } else {
                G2.setFont(new Font("Verdana", 0, (int) (0.04672897196261682 * bImage.getWidth())));
            }

            final TextLayout UNIT_LAYOUT = new TextLayout(getUnitString(), G2.getFont(), RENDER_CONTEXT);
            final Rectangle2D UNIT_BOUNDARY = UNIT_LAYOUT.getBounds();
            G2.drawString(getUnitString(), (float) ((getGaugeBounds().width - UNIT_BOUNDARY.getWidth()) / 2), unitOffsetYFactor * getGaugeBounds().width + UNIT_LAYOUT.getAscent() - UNIT_LAYOUT.getDescent());
        }

        // Draw threshold indicator
        if (isThresholdVisible()) {
            G2.rotate(thresholdRotationOffset, ROTATION_CENTER.getX(), ROTATION_CENTER.getY());
            G2.drawImage(thresholdImage, (int) THRESHOLD_OFFSET.getX(), (int) THRESHOLD_OFFSET.getY(), null);
            G2.setTransform(OLD_TRANSFORM);
        }

        // Draw min measured value indicator
        if (isMinMeasuredValueVisible()) {
            switch (getOrientation()) {
                case NORTH_EAST:
                    if (!isLogScale()) {
                        G2.rotate(measuredRotationOffset + (getMaxValue() - getMinMeasuredValue() - getMinValue()) * getAngleStep(), ROTATION_CENTER.getX(), ROTATION_CENTER.getY());
                    } else {
                        G2.rotate(measuredRotationOffset + UTIL.logOfBase(BASE, getMaxValue() - getMinMeasuredValue() - getMinValue()) * getLogAngleStep(), ROTATION_CENTER.getX(), ROTATION_CENTER.getY());
                    }
                    break;
                case SOUTH_EAST:
                    if (!isLogScale()) {
                        G2.rotate(measuredRotationOffset + (getMaxValue() - getMinMeasuredValue() - getMinValue()) * getAngleStep(), ROTATION_CENTER.getX(), ROTATION_CENTER.getY());
                    } else {
                        G2.rotate(measuredRotationOffset + UTIL.logOfBase(BASE, getMaxValue() - getMinMeasuredValue() - getMinValue()) * getLogAngleStep(), ROTATION_CENTER.getX(), ROTATION_CENTER.getY());
                    }
                    break;
                case SOUTH_WEST:
                    if (!isLogScale()) {
                        G2.rotate(measuredRotationOffset + (getMinMeasuredValue() - getMinValue()) * getAngleStep(), ROTATION_CENTER.getX(), ROTATION_CENTER.getY());
                    } else {
                        G2.rotate(measuredRotationOffset + UTIL.logOfBase(BASE, getMinMeasuredValue() - getMinValue()) * getLogAngleStep(), ROTATION_CENTER.getX(), ROTATION_CENTER.getY());
                    }
                    break;
                case NORTH_WEST:
                    if (!isLogScale()) {
                        G2.rotate(measuredRotationOffset + (getMinMeasuredValue() - getMinValue()) * getAngleStep(), ROTATION_CENTER.getX(), ROTATION_CENTER.getY());
                    } else {
                        G2.rotate(measuredRotationOffset + UTIL.logOfBase(BASE, getMinMeasuredValue() - getMinValue()) * getLogAngleStep(), ROTATION_CENTER.getX(), ROTATION_CENTER.getY());
                    }
                    break;
            }
            G2.drawImage(minMeasuredImage, (int) MEASURED_OFFSET.getX(), (int) MEASURED_OFFSET.getY(), null);
            G2.setTransform(OLD_TRANSFORM);
        }

        // Draw max measured value indicator
        if (isMaxMeasuredValueVisible()) {
            switch (getOrientation()) {
                case NORTH_EAST:
                    if (!isLogScale()) {
                        G2.rotate(measuredRotationOffset + (getMaxValue() - getMaxMeasuredValue() - getMinValue()) * getAngleStep(), ROTATION_CENTER.getX(), ROTATION_CENTER.getY());
                    } else {
                        G2.rotate(measuredRotationOffset + UTIL.logOfBase(BASE, getMaxValue() - getMaxMeasuredValue() - getMinValue()) * getLogAngleStep(), ROTATION_CENTER.getX(), ROTATION_CENTER.getY());
                    }
                    break;
                case SOUTH_EAST:
                    if (!isLogScale()) {
                        G2.rotate(measuredRotationOffset + (getMaxValue() - getMaxMeasuredValue() - getMinValue()) * getAngleStep(), ROTATION_CENTER.getX(), ROTATION_CENTER.getY());
                    } else {
                        G2.rotate(measuredRotationOffset + UTIL.logOfBase(BASE, getMaxValue() - getMaxMeasuredValue() - getMinValue()) * getLogAngleStep(), ROTATION_CENTER.getX(), ROTATION_CENTER.getY());
                    }
                    break;
                case SOUTH_WEST:
                    if (!isLogScale()) {
                        G2.rotate(measuredRotationOffset + (getMaxMeasuredValue() - getMinValue()) * getAngleStep(), ROTATION_CENTER.getX(), ROTATION_CENTER.getY());
                    } else {
                        G2.rotate(measuredRotationOffset + UTIL.logOfBase(BASE, getMaxMeasuredValue() - getMinValue()) * getLogAngleStep(), ROTATION_CENTER.getX(), ROTATION_CENTER.getY());
                    }
                    break;
                case NORTH_WEST:
                    if (!isLogScale()) {
                        G2.rotate(measuredRotationOffset + (getMaxMeasuredValue() - getMinValue()) * getAngleStep(), ROTATION_CENTER.getX(), ROTATION_CENTER.getY());
                    } else {
                        G2.rotate(measuredRotationOffset + UTIL.logOfBase(BASE, getMaxMeasuredValue() - getMinValue()) * getLogAngleStep(), ROTATION_CENTER.getX(), ROTATION_CENTER.getY());
                    }
                    break;
            }
            G2.drawImage(maxMeasuredImage, (int) MEASURED_OFFSET.getX(), (int) MEASURED_OFFSET.getY(), null);
            G2.setTransform(OLD_TRANSFORM);
        }

        // Draw LED if enabled
        if (isLedVisible()) {
            G2.drawImage(getCurrentLedImage(), (int) (getGaugeBounds().width * getLedPosition().getX()), (int) (getGaugeBounds().width * getLedPosition().getY()), null);
        }

        // Draw user LED if enabled
        if (isUserLedVisible()) {
            G2.drawImage(getCurrentUserLedImage(), (int) (getGaugeBounds().width * getUserLedPosition().getX()), (int) (getGaugeBounds().width * getUserLedPosition().getY()), null);
        }

        // Draw the pointer
        switch (getOrientation()) {
            case SOUTH_EAST:
                if (!isLogScale()) {
                    angle = (getValue() - getMinValue() - getMaxValue()) * (-getAngleStep());
                } else {
                    angle = UTIL.logOfBase(BASE, getValue() - getMinValue() - getMaxValue()) * (-getLogAngleStep());
                }
                break;
            case SOUTH_WEST:
                if (!isLogScale()) {
                    angle = (getValue() - getMinValue() - getMaxValue()) * getAngleStep();
                } else {
                    angle = UTIL.logOfBase(BASE, getValue() - getMinValue() - getMaxValue()) * getLogAngleStep();
                }
                break;
            case NORTH_EAST:
                if (!isLogScale()) {
                    angle = (getValue() - getMinValue()) * (-getAngleStep());
                } else {
                    angle = UTIL.logOfBase(BASE, getValue() - getMinValue()) * (-getLogAngleStep());
                }
                break;
            case NORTH_WEST:

            default:
                if (!isLogScale()) {
                    angle = (getValue() - getMinValue()) * getAngleStep();
                } else {
                    angle = UTIL.logOfBase(BASE, getValue() - getMinValue()) * getLogAngleStep();
                }
                break;
        }

        //G2.rotate(ANGLE + (Math.cos(Math.toRadians(ANGLE - 91.0))), CENTER.getX(), CENTER.getY());
        G2.rotate(angle, ROTATION_CENTER.getX(), ROTATION_CENTER.getY() + 2);
        G2.drawImage(pointerShadowImage, 0, 0, null);
        G2.setTransform(OLD_TRANSFORM);
        G2.rotate(angle, ROTATION_CENTER.getX(), ROTATION_CENTER.getY());
        G2.drawImage(pointerImage, 0, 0, null);
        G2.setTransform(OLD_TRANSFORM);

        // Draw the foreground
        G2.drawImage(fImage, 0, 0, null);

        // Draw glow indicator
        if (isGlowVisible()) {
            if (isGlowing()) {
                G2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getGlowAlpha()));
                G2.drawImage(glowImageOn, 0, 0, null);
                G2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f));
            } else
            {
                G2.drawImage(glowImageOff, 0, 0, null);
            }
        }

        if (!isEnabled()) {
            G2.drawImage(disabledImage, 0, 0, null);
        }

        G2.translate(-getInnerBounds().x, -getInnerBounds().y);

        G2.dispose();
    }
816438
protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h,
                                  boolean isSelected) {
        //super.paintTabBorder(g, tabPlacement, tabIndex, x, y, w, h, isSelected);
        if (isSelected) {
            g.setColor(Color.GRAY);
        }
        else {
            g.setColor(Color.LIGHT_GRAY);
        }
        g.drawRect(x + 1, y + 1, w - 2, h - 2);
    }