Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Tools for Java
 QCChart2D for Java
 Question about label placement...
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

javaman

22 Posts

Posted - 21 Apr 2009 :  18:39:10  Show Profile  Reply with Quote
Hi,

I'm using some of your example code to allow someone to add a label to a point on a plotted graph. The only difference in my code is that the plot is scrolling off to the left as more points come in. Thus, the added label will move as the plot adjusts - cool.

The problem I'm having is that when the label gets near the axis, it will cross the X-Axis and appear in the area where a legend would go - totally outside of the plot.

The question I have is how can I stop this? How can I tell the label (type Marker) that when it gets to the Axis to stop displaying.

Here's the code for the creation of the label (it's basically modified code from your own example):




                 if (found) {
                    // create marker object at place it at the nearest point
                    Marker amarker = new Marker(getChartObjScale(), MARKER_BOX,
                            nearestPoint.getX(), nearestPoint.getY(), 10.0,
                            PHYS_POS);
                    chartview.addChartObject(amarker);
                    rNumericLabelCntr += 1.0;
                    // Add a numeric label the identifies the marker
                    pointLabel = new StringLabel(getChartObjScale(),
                            textCoordsFont, name, nearestPoint
                                    .getX(), nearestPoint.getY(), PHYS_POS,
                            DECIMALFORMAT, 0, 0.0);
                    pointLabel.setTextBoxColor(Color.WHITE);
                    pointLabel.setTextBgColor(Color.WHITE);
                    pointLabel.setTextBgMode(true);
                    // Nudge text to the right and up so that it does not write over marker
                    pointLabel.setTextNudge(5, -5);
                    chartview.addChartObject(pointLabel);
                    chartview.repaint();
                }



Thanx - Joe!

quinncurtis

1164 Posts

Posted - 22 Apr 2009 :  09:04:06  Show Profile  Reply with Quote
A text object can be clipped to the entire graph area (the area inside and outside the axes), or to just the plotting area (the area bounded by the axes). The default is graph area clipping, ChartObj.GRAPH_AREA_CLIPPING.

You can change this to plot area clipping, ChartObj.PLOT_AREA_CLIPPING, using text objects setChartObjClipping method.

pointLabel.setChartObjClipping(ChartObj.PLOT_AREA_CLIPPING);
Go to Top of Page

javaman

22 Posts

Posted - 23 Apr 2009 :  13:52:27  Show Profile  Reply with Quote
That worked! Many thanx.

Thanx - Joe!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Quinn-Curtis Forums © 2000-07 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07