-
March 1st, 2012, 04:55 PM
#1
bubble level
Hi, all
I need to do a small graph like a bubble level in my Applet.
Given 3 values, X, Y, Z Accelerations, the bubble should be drawn there in the target panel of the graph, Just like a bubble level, or inclination indicator.
I checked JFreeChart, as well as com.objectplanet.chart.ext.GaugeChart, neither seems to do this.
Any suggestions?
Thanks,
Jerry
-
March 5th, 2012, 04:00 PM
#2
Re: bubble level
got the solution:
just extend the JLabel and override the protected void paintComponent(Graphics g).
In this customized control, I can draw 2 circles (same center, different radius) in the paintComponent function.
and the position of the "bubble" can be determined by the x, y, z parameters, which can be set by a public function.
class BubbleLevel extends JLabel{
private int x,y,z;
public synchronized void SetBubblePosition(int a, int b, int c){...}
protected void paintComponent(Graphics g)
{ // draw 2 circles, and the bubble based on x, y, z }
}
Then in the code:
BubbleLevel bl = new BubbleLevel();
bl.SetBubblePosition(x, y , z);
bl.repaint();
-
March 5th, 2012, 05:21 PM
#3
Re: bubble level
Thanks for posting your solution.
If you aren't using any of the features of JLabel you may be better off extending JPanel.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|