/** * Creates a new label block. * * @param text the text for the label (<code>null</code> not permitted). * @param font the font (<code>null</code> not permitted). * @param paint the paint (<code>null</code> not permitted). */ public LabelBlock(String text, Font font, Paint paint) { this.text = text; this.paint = paint; this.label = TextUtilities.createTextBlock(text, font, this.paint); this.font = font; this.toolTipText = null; this.urlText = null; this.contentAlignmentPoint = TextBlockAnchor.CENTER; this.textAnchor = RectangleAnchor.CENTER; }
/** * Creates a new text block from the given string, breaking the * text into lines so that the <code>maxWidth</code> value is * respected. * * @param text the text. * @param font the font. * @param paint the paint. * @param maxWidth the maximum width for each line. * @param measurer the text measurer. * * @return A text block. */ public static TextBlock createTextBlock(String text, Font font, Paint paint, float maxWidth, TextMeasurer measurer) { return createTextBlock(text, font, paint, maxWidth, Integer.MAX_VALUE, measurer); }
/** * Creates a new text block from the given string, breaking the * text into lines so that the <code>maxWidth</code> value is * respected. * * @param text the text. * @param font the font. * @param paint the paint. * @param maxWidth the maximum width for each line. * @param measurer the text measurer. * * @return A text block. */ public static TextBlock createTextBlock(final String text, final Font font, final Paint paint, final float maxWidth, final TextMeasurer measurer) { return createTextBlock(text, font, paint, maxWidth, Integer.MAX_VALUE, measurer); }
/** * Creates a new text block from the given string, breaking the * text into lines so that the <code>maxWidth</code> value is * respected. * * @param text the text. * @param font the font. * @param paint the paint. * @param maxWidth the maximum width for each line. * @param measurer the text measurer. * * @return A text block. */ public static TextBlock createTextBlock(final String text, final Font font, final Paint paint, final float maxWidth, final TextMeasurer measurer) { return createTextBlock(text, font, paint, maxWidth, Integer.MAX_VALUE, measurer); }
/** * Sets the font and regenerates the label. * * @param font the font (<code>null</code> not permitted). * * @see #getFont() */ public void setFont(Font font) { if (font == null) { throw new IllegalArgumentException("Null 'font' argument."); } this.font = font; this.label = TextUtilities.createTextBlock(this.text, font, this.paint); }
/** * Sets the paint and regenerates the label. * * @param paint the paint (<code>null</code> not permitted). * * @see #getPaint() */ public void setPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.paint = paint; this.label = TextUtilities.createTextBlock(this.text, this.font, this.paint); }
/** * Paints the panel. * * @param g the graphics device. */ public void paintComponent(final Graphics g) { super.paintComponent(g); final Graphics2D g2 = (Graphics2D) g; final Dimension size = getSize(); final Insets insets = getInsets(); final Rectangle2D available = new Rectangle2D.Double(insets.left, insets.top, size.getWidth() - insets.left - insets.right, size.getHeight() - insets.top - insets.bottom); final double x = available.getX(); final double y = available.getY(); final float width = (float) available.getWidth(); final TextBlock block = TextUtilities.createTextBlock( this.text, this.font, Color.black, width, new G2TextMeasurer(g2) ); g2.setPaint(Color.black); block.draw(g2, (float) x, (float) y, TextBlockAnchor.TOP_LEFT, 0.0f, 0.0f, 0.0); }
/** * Creates a label. * * @param category the category. * @param width the available width. * @param edge the edge on which the axis appears. * @param g2 the graphics device. * * @return A label. */ protected TextBlock createLabel(Comparable category, float width, RectangleEdge edge, Graphics2D g2) { TextBlock label = TextUtilities.createTextBlock(category.toString(), getTickLabelFont(category), getTickLabelPaint(category), width, this.maximumCategoryLabelLines, new G2TextMeasurer(g2)); return label; }
/** * Draws a message to state that there is no data to plot. * * @param g2 the graphics device. * @param area the area within which the plot should be drawn. */ protected void drawNoDataMessage(Graphics2D g2, Rectangle2D area) { Shape savedClip = g2.getClip(); g2.clip(area); String message = this.noDataMessage; if (message != null) { g2.setFont(this.noDataMessageFont); g2.setPaint(this.noDataMessagePaint); TextBlock block = TextUtilities.createTextBlock( this.noDataMessage, this.noDataMessageFont, this.noDataMessagePaint, 0.9f * (float) area.getWidth(), new G2TextMeasurer(g2)); block.draw(g2, (float) area.getCenterX(), (float) area.getCenterY(), TextBlockAnchor.CENTER); } g2.setClip(savedClip); }
float maxWidth = (float) w; g2.setFont(this.font); this.content = TextUtilities.createTextBlock(this.text, this.font, this.paint, maxWidth, this.maximumLinesToDisplay, new G2TextMeasurer(g2)); float maxWidth = Float.MAX_VALUE; g2.setFont(this.font); this.content = TextUtilities.createTextBlock(this.text, this.font, this.paint, maxWidth, this.maximumLinesToDisplay, new G2TextMeasurer(g2));
float maxWidth = (float) widthRange.getUpperBound(); g2.setFont(this.font); this.content = TextUtilities.createTextBlock(this.text, this.font, this.paint, maxWidth, this.maximumLinesToDisplay, new G2TextMeasurer(g2)); float maxWidth = (float) heightRange.getUpperBound(); g2.setFont(this.font); this.content = TextUtilities.createTextBlock(this.text, this.font, this.paint, maxWidth, this.maximumLinesToDisplay, new G2TextMeasurer(g2));
TextBlock label = TextUtilities.createTextBlock(text, getTickLabelFont(category), getTickLabelPaint(category), width, getMaximumCategoryLabelLines(), new G2TextMeasurer(g2));
this.dataset, leftKeys.getKey(i)); if (label != null) { TextBlock block = TextUtilities.createTextBlock(label, this.labelFont, this.labelPaint, maxLabelWidth, new G2TextMeasurer(g2));
TextBlock block = TextUtilities.createTextBlock(label, this.labelFont, this.labelPaint, maxLabelWidth, new G2TextMeasurer(g2));