From: SourceForge.net <no...@so...> - 2006-12-14 06:21:39
|
Patches item #1615504, was opened at 2006-12-14 07:20 Message generated for change (Settings changed) made by johnmay666 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=315494&aid=1615504&group_id=15494 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None >Status: Pending Resolution: None Priority: 5 Private: No Submitted By: JohnMay (johnmay666) Assigned to: Nobody/Anonymous (nobody) Summary: DialImage (Extension for DialPlot) Initial Comment: Testcase: Take any example (remove background gradient definitions for testing) and add: ... ImageIcon image = new ImageIcon("wood.png"); DialImage di = new DialImage(image.getImage()); dialplot.addLayer(di); ... This should do the trick (any image will be okay, since it will be resized. The attached file is a good start for sizes and how much is lost because of the round shape) CLASS DialImage: import java.awt.*; import java.awt.geom.Rectangle2D; import org.jfree.experimental.chart.plot.dial.AbstractDialLayer; import org.jfree.experimental.chart.plot.dial.DialLayer; import org.jfree.experimental.chart.plot.dial.DialLayerChangeEvent; import org.jfree.experimental.chart.plot.dial.DialPlot; import org.jfree.ui.Align; public class DialImage extends AbstractDialLayer implements DialLayer { public DialImage() { this(null); } public DialImage(Image image) { imageAlpha = 0.5F; imageAlignment = 15; this.image = image; } public Image getBackgroundImage() { return image; } public int getBackgroundImageAlignment() { return imageAlignment; } public float getImageAlpha() { return imageAlpha; } public void setBackgroundImageAlignment(int alignment) { if (imageAlignment != alignment) { imageAlignment = alignment; notifyListeners(new DialLayerChangeEvent(this)); } } public void setImageAlpha(float alpha) { if (imageAlpha != alpha) { imageAlpha = alpha; notifyListeners(new DialLayerChangeEvent(this)); } } public void setBackgroundImage(Image image) { this.image = image; notifyListeners(new DialLayerChangeEvent(this)); } public boolean isClippedToWindow() { return true; } public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, Rectangle2D view) { Rectangle2D area = plot.rectangleByRadius(view, plot.getViewHeight(), plot.getViewWidth()); drawImage(g2, area); } public void drawImage(Graphics2D g2, Rectangle2D area) { if (image != null) { java.awt.Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance(3, imageAlpha)); Rectangle2D dest = new java.awt.geom.Rectangle2D.Double(0.0D, 0.0D, image.getWidth(null), image.getHeight(null)); Align.align(dest, area, imageAlignment); g2.drawImage(image, (int) dest.getX(), (int) dest.getY(), (int) dest.getWidth() + 1, (int) dest.getHeight() + 1, null); g2.setComposite(originalComposite); } } private transient Image image; private float imageAlpha; private int imageAlignment; } ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=315494&aid=1615504&group_id=15494 |