Most of my application works great with the changes but I did find that custom
painting in charts is broken throughout the application.
Rendering artifacts occur in my custom charts and in JFreeChart charts as well.
The artifacts go away when I disable the new pipeline.
Here is the trace output:
[I] CheckAdaptersInfo
[I] ------------------
[I] Adapter Ordinal : 0
[I] Adapter Handle : 0x10001
[I] Description : NVIDIA Quadro NVS 110M
[I] GDI Name, Driver : \\.\DISPLAY1, nv4_disp.dll
[I] Vendor Id : 0x10de
[I] Device Id : 0x1d7
[I] SubSys Id : 0x1c21028
[I] Driver Version : 6.14.10.8313
[I] GUID : D7B71E3E-4297-11CF-E153C82100C2CB35
[I] ------------------
[I] InitD3D: successfully created Direct3D9 object
[I] D3DGD_getDeviceCapsNative
[I] D3DPPLM::CheckDeviceCaps: adapter 0: Passed
[I] D3DContext::InitContext device 0
[I] D3DContext::ConfigureContext device 0
[I] D3DContext::ConfigureContext: successfully created device: 0
[I] D3DContext::InitDevice: device 0
[I] D3DContext::InitDefice: successfully initialized device 0
[V] | CAPS_DEVICE_OK
[V] | CAPS_ALPHA_RT_PLAIN
[V] | CAPS_ALPHA_RTT
[V] | CAPS_OPAQUE_RTT
[V] | CAPS_LCD_SHADER | CAPS_BIOP_SHADER
[V] | CAPS_MULTITEXTURE
[V] | CAPS_TEXNONPOW2
[V] | CAPS_TEXNONSQUARE
Here is source for a pie chart component that exhibits the problem:
import java.awt.BasicStroke;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.geom.Arc2D;
import java.awt.geom.Ellipse2D;
import java.util.ArrayList;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.ToolTipManager;
import javax.swing.UIManager;
public class SimplePieChart extends JPanel {
private ArrayList<Slice> slices;
private Color lineColor;
private Color noDataColor;
public SimplePieChart() {
super();
lineColor = Color.black;
noDataColor = Color.gray;
slices = new ArrayList<Slice>();
setOpaque(false);
setPreferredSize(new Dimension(100, 100));
ToolTipManager.sharedInstance().registerComponent(this);
}
public void addSlice(String id, String tooltip, double value, Color color) {
insertSlice(new Slice(id, tooltip, value, color));
updateAngles();
}
public void paint(Graphics g) {
super.paint(g);
Graphics2D g2 = (Graphics2D) g;
Rectangle bounds = getBounds();
g2.setStroke(new BasicStroke(.5f));
g2.setRenderingHint(
RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
for(Slice s : slices) {
g2.setColor(s.color);
Arc2D.Double arc = new Arc2D.Double(
0, 0, bounds.width - 1, bounds.height - 1,
s.startAngle, s.extentAngle, Arc2D.PIE);
g2.fill(arc);
}
Ellipse2D circle = new Ellipse2D.Double(0, 0, bounds.width - 1,
bounds.height - 1);
if(slices.size() == 0) {
g2.setColor(noDataColor);
g2.fill(circle);
}
g2.setColor(lineColor);
g2.draw(circle);
}
private void insertSlice(Slice slice) {
boolean inserted = false;
for(int i = 0; i < slices.size(); i++) {
Slice s = slices.get(i);
if(slice.value > s.value) {
slices.add(i, slice);
inserted = true;
break;
}
}
if(!inserted) slices.add(slice);
}
private void updateAngles() {
double total = 0;
for(Slice s : slices) {
total += s.value;
}
double start = 0;
for(Slice s : slices) {
s.startAngle = start;
s.extentAngle = 360 * s.value / total;
start += s.extentAngle;
}
}
private class Slice {
public String id;
public String tooltip;
public double value;
public Color color;
public double startAngle;
public double extentAngle;
public Slice(String id, String tooltip, double value, Color color) {
this.id = id;
this.tooltip = tooltip;
this.value = value;
this.color = color;
}
}
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch(Exception e) {
}
JFrame frame = new JFrame();
frame.setLayout(new BorderLayout());
SimplePieChart chart = new SimplePieChart();
chart.addSlice("red", "red", 30, new Color(244, 130, 42));
chart.addSlice("yellow", "yellow", 20, new Color(243, 210, 90));
chart.addSlice("green", "green", 1, new Color(210, 13, 12));
chart.addSlice("blue", "blue", 1, new Color(143, 70, 149));
chart.repaint();
frame.add(chart, BorderLayout.CENTER);
frame.setSize(new Dimension(400, 400));
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
- Samuel Crank
[Message sent by forum member 'sjcrank' (sjcrank)]
http://forums.java.net/jive/thread.jspa?messageID=245439
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".