/** * Sets the text to draw * @param text the text to draw */ public void setText(String text) { String old = getText(); this.text = text == null ? "" : text; setDirty(true); firePropertyChange("text", old, getText()); }
/** * Set the font (and font size and style) to be used when drawing the text * @param f the new font */ public void setFont(Font f) { Font old = getFont(); this.font = f; setDirty(true); firePropertyChange("font", old, getFont()); }
Font f = calculateFont(component); if (f != null) { g.setFont(f); Paint paint = getForegroundPaint(getFillPaint(), component); String t = calculateText(component); Rectangle res = calculateLayout(tw, th, width, height); if(isPaintStretched()) { paint = calculateSnappedPaint(paint, res.width, res.height); if(getAreaEffects() != null) { Shape shape = provideShape(g, component, width, height); for(AreaEffect ef : getAreaEffects()) { ef.apply(g, shape, width, height);
/** * {@inheritDoc} */ @Override protected Shape provideShape(Graphics2D g2, Object comp, int width, int height) { Font f = calculateFont(comp); String t = calculateText(comp); FontMetrics metrics = g2.getFontMetrics(f); GlyphVector vect = f.createGlyphVector(g2.getFontRenderContext(),t); return vect.getOutline(0f,0f+ metrics.getAscent()); } }
private Font calculateFont(final Object component) { // prep the various text attributes Font f = getComponentFont(getFont(), component); if (f == null) { f = new Font("Dialog", Font.PLAIN, 18); } return f; }
private String calculateText(final Object component) { // prep the text String t = getText(); //make components take priority if(text == null || text.trim().equals("")) { if(t != null && !t.trim().equals("")) { return t; } if(component instanceof JTextComponent) { t = ((JTextComponent)component).getText(); } if(component instanceof JLabel) { t = ((JLabel)component).getText(); } if(component instanceof AbstractButton) { t = ((AbstractButton)component).getText(); } return t; }
@Override protected Rectangle calculateLayout(int contentWidth, int contentHeight, int width, int height) { if (rotation == 0) { Rectangle layout = super.calculateLayout(contentWidth, contentHeight, width, height); rotatedLayout = null; // support the Move tool layout.translate(translationX, translationY); return layout; } // first calculate a rotated rectangle starting at 0, 0... rotatedLayout = new RotatedRectangle(0, 0, contentWidth, contentHeight, rotation); Rectangle bb = rotatedLayout.getBoundingBox(); // ...then position it correctly and apply the corrections // and also support the Move tool Rectangle layout = super.calculateLayout(bb.width, bb.height, width, height); int dx = layout.x - bb.x; int dy = layout.y - bb.y; rotatedLayout.translate(dx + translationX, dy + translationY); layout.translate(translationX, translationY); return layout; }
Font f = calculateFont(component); if (f != null) { g.setFont(f); Paint paint = getForegroundPaint(getFillPaint(), component); String t = calculateText(component); Rectangle res = calculateLayout(tw, th, width, height); if(isPaintStretched()) { paint = calculateSnappedPaint(paint, res.width, res.height); if(getAreaEffects() != null) { Shape shape = provideShape(g, component, width, height); for(AreaEffect ef : getAreaEffects()) { ef.apply(g, shape, width, height);
/** * {@inheritDoc} */ @Override protected Shape provideShape(Graphics2D g2, Object comp, int width, int height) { Font font = calculateFont(comp); String text = calculateText(comp); FontMetrics metrics = g2.getFontMetrics(font); GlyphVector vect = font.createGlyphVector(g2.getFontRenderContext(),text); return vect.getOutline(0f,0f+ metrics.getAscent()); } }
private Font calculateFont(final Object component) { // prep the various text attributes Font f = getComponentFont(getFont(), component); if (f == null) { f = new Font("Dialog", Font.PLAIN, 18); } return f; }
private String calculateText(final Object component) { // prep the text String t = getText(); //make components take priority if(text == null || text.trim().equals("")) { if(t != null && !t.trim().equals("")) { return t; } if(component instanceof JTextComponent) { t = ((JTextComponent)component).getText(); } if(component instanceof JLabel) { t = ((JLabel)component).getText(); } if(component instanceof AbstractButton) { t = ((AbstractButton)component).getText(); } return t; }
Font f = calculateFont(component); if (f != null) { g.setFont(f); Paint paint = getForegroundPaint(getFillPaint(), component); String t = calculateText(component); Rectangle res = calculateLayout(tw, th, width, height); if(isPaintStretched()) { paint = calculateSnappedPaint(paint, res.width, res.height); if(getAreaEffects() != null) { Shape shape = provideShape(g, component, width, height); for(AreaEffect ef : getAreaEffects()) { ef.apply(g, shape, width, height);
/** * Sets the text to draw * @param text the text to draw */ public void setText(String text) { String old = getText(); this.text = text == null ? "" : text; setDirty(true); firePropertyChange("text", old, getText()); }
/** * Set the font (and font size and style) to be used when drawing the text * @param f the new font */ public void setFont(Font f) { Font old = getFont(); this.font = f; setDirty(true); firePropertyChange("font", old, getFont()); }
/** * {@inheritDoc} */ @Override protected Shape provideShape(Graphics2D g2, Object comp, int width, int height) { Font f = calculateFont(comp); String t = calculateText(comp); FontMetrics metrics = g2.getFontMetrics(f); GlyphVector vect = f.createGlyphVector(g2.getFontRenderContext(),t); return vect.getOutline(0f,0f+ metrics.getAscent()); } }
private Font calculateFont(final Object component) { // prep the various text attributes Font f = getComponentFont(getFont(), component); if (f == null) { f = new Font("Dialog", Font.PLAIN, 18); } return f; }
private String calculateText(final Object component) { // prep the text String t = getText(); //make components take priority if(text == null || text.trim().equals("")) { if(t != null && !t.trim().equals("")) { return t; } if(component instanceof JTextComponent) { t = ((JTextComponent)component).getText(); } if(component instanceof JLabel) { t = ((JLabel)component).getText(); } if(component instanceof AbstractButton) { t = ((AbstractButton)component).getText(); } return t; }
Font font = calculateFont(component); if (font != null) { g.setFont(font); Paint paint = getFillPaint(); if(paint == null) { if(component instanceof JComponent) { String text = calculateText(component); Rectangle res = calculateLayout(tw, th, width, height); if(isPaintStretched()) { paint = calculateSnappedPaint(paint, res.width, res.height); if(getAreaEffects() != null) { Shape shape = provideShape(g, component, width, height); for(AreaEffect ef : getAreaEffects()) { ef.apply(g, shape, width, height);
/** * Sets the text to draw * @param text the text to draw */ public void setText(String text) { String old = getText(); this.text = text == null ? "" : text; setDirty(true); firePropertyChange("text", old, getText()); }
/** * Set the font (and font size and style) to be used when drawing the text * @param f the new font */ public void setFont(Font f) { Font old = getFont(); this.font = f; setDirty(true); firePropertyChange("font", old, getFont()); }