comparison flys-artifacts/src/main/java/de/intevation/flys/jfree/StickyAxisAnnotation.java @ 1962:59622ba800c8

Cosmetics. flys-artifacts/trunk@3371 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 08 Dec 2011 13:09:04 +0000
parents c51089a84d13
children c68f4f227c09
comparison
equal deleted inserted replaced
1961:4781096f31f8 1962:59622ba800c8
98 public StickyAxisAnnotation(String text, float pos, SimpleAxis stickAxis) { 98 public StickyAxisAnnotation(String text, float pos, SimpleAxis stickAxis) {
99 super(text, pos, pos); 99 super(text, pos, pos);
100 setStickyAxis(stickAxis); 100 setStickyAxis(stickAxis);
101 this.pos = pos; 101 this.pos = pos;
102 } 102 }
103
103 104
104 /** 105 /**
105 * Legacy-Constructor. 106 * Legacy-Constructor.
106 * @deprecated 107 * @deprecated
107 */ 108 */
224 } 225 }
225 } 226 }
226 227
227 228
228 /** 229 /**
229 * Draw the Annotiation if it does not collide with other already drawn 230 * Draw the Annotation; the text only if it does not collide with other
230 * Annotations. 231 * already drawn Annotations- texts.
231 * 232 *
232 * @param g2 the graphics device. 233 * @param g2 the graphics device.
233 * @param plot the plot. 234 * @param plot the plot.
234 * @param dataArea the data area. 235 * @param dataArea the data area.
235 * @param domainAxis the domain axis. 236 * @param domainAxis the domain axis.
269 RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation( 270 RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
270 plot.getRangeAxisLocation(), orientation); 271 plot.getRangeAxisLocation(), orientation);
271 float anchorX = 0f; 272 float anchorX = 0f;
272 float anchorY = 0.0f; 273 float anchorY = 0.0f;
273 if (this.stickyAxis == SimpleAxis.X_AXIS) { 274 if (this.stickyAxis == SimpleAxis.X_AXIS) {
274 // Text starts at 1.5% of full distance. 275 // Text starts at 2% of full distance.
275 float rangeLow = (float) rangeAxis.getRange().getLowerBound(); 276 float rangeLow = (float) rangeAxis.getRange().getLowerBound();
276 float y = rangeLow + 0.02f * ((float) 277 float y = rangeLow + 0.02f * ((float)
277 rangeAxis.getRange().getUpperBound() - rangeLow); 278 rangeAxis.getRange().getUpperBound() - rangeLow);
278 setY(y); 279 setY(y);
279 280
280 anchorX = (float) domainAxis.valueToJava2D( 281 anchorX = (float) domainAxis.valueToJava2D(
281 getX(), dataArea, domainEdge); 282 getX(), dataArea, domainEdge);
282 anchorY = (float) rangeAxis.valueToJava2D( 283 anchorY = (float) rangeAxis.valueToJava2D(
283 getY(), dataArea, rangeEdge); 284 getY(), dataArea, rangeEdge);
284 } else { 285 } else {
285 float rangeLow = (float) domainAxis.getRange().getLowerBound(); 286 float rangeLow = (float) domainAxis.getRange().getLowerBound();
286 float x = rangeLow + 0.02f * ((float) 287 float x = rangeLow + 0.02f * ((float)
287 domainAxis.getRange().getUpperBound() - rangeLow); 288 domainAxis.getRange().getUpperBound() - rangeLow);
288 setX(x); 289 setX(x);
289 anchorX = (float) domainAxis.valueToJava2D( 290 anchorX = (float) domainAxis.valueToJava2D(
290 getX(), dataArea, domainEdge); 291 getX(), dataArea, domainEdge);
291 anchorY = (float) rangeAxis.valueToJava2D( 292 anchorY = (float) rangeAxis.valueToJava2D(
292 getY(), dataArea, rangeEdge); 293 getY(), dataArea, rangeEdge);
300 //Call to apply orientation. 301 //Call to apply orientation.
301 setStickyAxis(stickyAxis); 302 setStickyAxis(stickyAxis);
302 303
303 // Always draw the small line at axis. 304 // Always draw the small line at axis.
304 drawAxisMark(g2, dataArea, domainAxis, rangeAxis, domainEdge, 305 drawAxisMark(g2, dataArea, domainAxis, rangeAxis, domainEdge,
305 rangeEdge, orientation); 306 rangeEdge, orientation);
306 307
307 Shape hotspot = TextUtilities.calculateRotatedStringBounds( 308 Shape hotspot = TextUtilities.calculateRotatedStringBounds(
308 getText(), g2, anchorX, anchorY, getTextAnchor(), 309 getText(), g2, anchorX, anchorY, getTextAnchor(),
309 getRotationAngle(), getRotationAnchor()); 310 getRotationAngle(), getRotationAnchor());
310 Rectangle2D hotspotBox = hotspot.getBounds2D(); 311 Rectangle2D hotspotBox = hotspot.getBounds2D();
311 // Check for collisions with other XYAnnotations. 312 // Check for collisions with other XYAnnotations.
312 for (Iterator i = chartInfo.getEntityCollection().iterator(); 313 for (Iterator i = chartInfo.getEntityCollection().iterator();
313 i.hasNext(); ) { 314 i.hasNext(); ) {
314 Object next = i.next(); 315 Object next = i.next();
336 337
337 // Draw the text. 338 // Draw the text.
338 g2.setPaint(textColor); 339 g2.setPaint(textColor);
339 g2.setFont(font); 340 g2.setFont(font);
340 TextUtilities.drawRotatedString(getText(), g2, anchorX, anchorY, 341 TextUtilities.drawRotatedString(getText(), g2, anchorX, anchorY,
341 getTextAnchor(), getRotationAngle(), getRotationAnchor()); 342 getTextAnchor(), getRotationAngle(), getRotationAnchor());
342 343
343 // Add info that we have drawn this Annotation. 344 // Add info that we have drawn this Annotation.
344 addEntity(info, hotspot, rendererIndex, getToolTipText(), getURL()); 345 addEntity(info, hotspot, rendererIndex, getToolTipText(), getURL());
345 } 346 }
346 347

http://dive4elements.wald.intevation.org