Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/jfree/EnhancedLineAndShapeRenderer.java @ 3395:2a8919e0ed28
Cosmetics, doc.
flys-artifacts/trunk@5025 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 17 Jul 2012 18:40:25 +0000 |
parents | 0f7abd95c6e2 |
children | 0b9b2a0c4e64 |
comparison
equal
deleted
inserted
replaced
3394:f091f2f55f88 | 3395:2a8919e0ed28 |
---|---|
121 public Shape getMinimumShape(int series, int column) { | 121 public Shape getMinimumShape(int series, int column) { |
122 return new Rectangle2D.Double(-5d, -5d, 10d, 10d); | 122 return new Rectangle2D.Double(-5d, -5d, 10d, 10d); |
123 } | 123 } |
124 | 124 |
125 | 125 |
126 /** Get fill paint for the maximum indicators. */ | |
126 public Paint getMaximumFillPaint(int series, int column) { | 127 public Paint getMaximumFillPaint(int series, int column) { |
127 Paint p = getItemPaint(series, column); | 128 Paint p = getItemPaint(series, column); |
128 | 129 |
129 if (p instanceof Color) { | 130 if (p instanceof Color) { |
130 Color c = (Color) p; | 131 Color c = (Color) p; |
140 logger.warn("Item paint is no instance of Color!"); | 141 logger.warn("Item paint is no instance of Color!"); |
141 return p; | 142 return p; |
142 } | 143 } |
143 | 144 |
144 | 145 |
146 /** Get fill paint for the minimum indicators. */ | |
145 public Paint getMinimumFillPaint(int series, int column) { | 147 public Paint getMinimumFillPaint(int series, int column) { |
146 Paint p = getItemPaint(series, column); | 148 Paint p = getItemPaint(series, column); |
147 | 149 |
148 if (p instanceof Color) { | 150 if (p instanceof Color) { |
149 Color c = (Color) p; | 151 Color c = (Color) p; |
272 if (orientation == PlotOrientation.HORIZONTAL) { | 274 if (orientation == PlotOrientation.HORIZONTAL) { |
273 xx = transY1; | 275 xx = transY1; |
274 yy = transX1; | 276 yy = transX1; |
275 } | 277 } |
276 | 278 |
277 // draw the item label if there is one... | 279 // Draw the item label if there is one... |
278 if (isItemLabelVisible(series, item)) { | 280 if (isItemLabelVisible(series, item)) { |
279 drawItemLabel(g2, orientation, dataset, series, item, xx, yy, | 281 drawItemLabel(g2, orientation, dataset, series, item, xx, yy, |
280 (y1 < 0.0)); | 282 (y1 < 0.0)); |
281 } | 283 } |
282 | 284 |
283 // Draw label of line. | 285 // Draw label of line. |
284 if (dataset instanceof XYSeriesCollection && isShowLineLabel(series) && isMinimumX (dataset, series, item)) { | 286 if (dataset instanceof XYSeriesCollection |
287 && isShowLineLabel(series) | |
288 && isMinimumX (dataset, series, item) | |
289 ) { | |
285 XYSeries xYSeries = ((XYSeriesCollection) dataset).getSeries(series); | 290 XYSeries xYSeries = ((XYSeriesCollection) dataset).getSeries(series); |
286 String waterlevelLabel = (xYSeries instanceof HasLabel) | 291 String waterlevelLabel = (xYSeries instanceof HasLabel) |
287 ? ((HasLabel)xYSeries).getLabel() | 292 ? ((HasLabel)xYSeries).getLabel() |
288 : xYSeries.getKey().toString(); | 293 : xYSeries.getKey().toString(); |
289 // TODO Force water of some German rivers to flow direction mountains. | 294 // TODO Force water of some German rivers to flow direction mountains. |
295 g2.setColor(this.getLineLabelTextColor(series)); | 300 g2.setColor(this.getLineLabelTextColor(series)); |
296 g2.setBackground(Color.black); | 301 g2.setBackground(Color.black); |
297 | 302 |
298 // Move to right until no collisions exist anymore | 303 // Move to right until no collisions exist anymore |
299 Shape hotspot = TextUtilities.calculateRotatedStringBounds( | 304 Shape hotspot = TextUtilities.calculateRotatedStringBounds( |
300 waterlevelLabel, g2, (float)xx, (float)yy-3f, TextAnchor.CENTER_LEFT, | 305 waterlevelLabel, g2, (float)xx, (float)yy-3f, |
306 TextAnchor.CENTER_LEFT, | |
301 0f, TextAnchor.CENTER_LEFT); | 307 0f, TextAnchor.CENTER_LEFT); |
302 while (JFreeUtil.collides(hotspot, entities, CollisionFreeLineLabelEntity.class)) { | 308 while (JFreeUtil.collides(hotspot, entities, |
309 CollisionFreeLineLabelEntity.class)) { | |
303 xx += 5f; | 310 xx += 5f; |
304 hotspot = TextUtilities.calculateRotatedStringBounds( | 311 hotspot = TextUtilities.calculateRotatedStringBounds( |
305 waterlevelLabel, g2, (float)xx, (float)yy-3f, TextAnchor.CENTER_LEFT, | 312 waterlevelLabel, g2, (float)xx, (float)yy-3f, TextAnchor.CENTER_LEFT, |
306 0f, TextAnchor.CENTER_LEFT); | 313 0f, TextAnchor.CENTER_LEFT); |
307 } | 314 } |
325 int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); | 332 int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); |
326 int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); | 333 int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); |
327 updateCrosshairValues(crosshairState, x1, y1, domainAxisIndex, | 334 updateCrosshairValues(crosshairState, x1, y1, domainAxisIndex, |
328 rangeAxisIndex, transX1, transY1, orientation); | 335 rangeAxisIndex, transX1, transY1, orientation); |
329 | 336 |
330 // add an entity for the item, but only if it falls within the data | 337 // Add an entity for the item, but only if it falls within the data |
331 // area... | 338 // area... |
332 if (entities != null && isPointInRect(dataArea, xx, yy)) { | 339 if (entities != null && isPointInRect(dataArea, xx, yy)) { |
333 addEntity(entities, entityArea, dataset, series, item, xx, yy); | 340 addEntity(entities, entityArea, dataset, series, item, xx, yy); |
334 } | 341 } |
335 } | 342 } |
341 public void setIsMinimumShapeVisisble(int series, boolean isVisible) { | 348 public void setIsMinimumShapeVisisble(int series, boolean isVisible) { |
342 this.isMinimumShapeVisible.setBoolean(series, isVisible); | 349 this.isMinimumShapeVisible.setBoolean(series, isVisible); |
343 } | 350 } |
344 | 351 |
345 | 352 |
353 /** | |
354 * Whether or not the minimum should be rendered with shape. | |
355 */ | |
346 public boolean isMinimumShapeVisible(int series) { | 356 public boolean isMinimumShapeVisible(int series) { |
347 if (this.isMinimumShapeVisible.size() <= series) { | 357 if (this.isMinimumShapeVisible.size() <= series) { |
348 return false; | 358 return false; |
349 } | 359 } |
350 | 360 |
351 return isMinimumShapeVisible.getBoolean(series); | 361 return isMinimumShapeVisible.getBoolean(series); |
352 } | 362 } |
353 | 363 |
354 | 364 |
365 /** | |
366 * Sets whether or not the maximum should be rendered with shape. | |
367 */ | |
355 public void setIsMaximumShapeVisible(int series, boolean isVisible) { | 368 public void setIsMaximumShapeVisible(int series, boolean isVisible) { |
356 this.isMaximumShapeVisible.setBoolean(series, isVisible); | 369 this.isMaximumShapeVisible.setBoolean(series, isVisible); |
357 } | 370 } |
358 | 371 |
359 | 372 |
373 /** | |
374 * Whether or not the maximum should be rendered with shape. | |
375 */ | |
360 public boolean isMaximumShapeVisible(int series) { | 376 public boolean isMaximumShapeVisible(int series) { |
361 if (this.isMaximumShapeVisible.size() <= series) { | 377 if (this.isMaximumShapeVisible.size() <= series) { |
362 return false; | 378 return false; |
363 } | 379 } |
364 | 380 |
378 /** Sets whether or not a label should be shown for series. */ | 394 /** Sets whether or not a label should be shown for series. */ |
379 public void setShowLineLabel(boolean showLineLabel, int series) { | 395 public void setShowLineLabel(boolean showLineLabel, int series) { |
380 this.showLineLabel.setBoolean(series, showLineLabel); | 396 this.showLineLabel.setBoolean(series, showLineLabel); |
381 } | 397 } |
382 | 398 |
399 | |
383 /** Whether or not a label should be shown for series. */ | 400 /** Whether or not a label should be shown for series. */ |
384 public boolean isShowLineLabelBG(int series) { | 401 public boolean isShowLineLabelBG(int series) { |
385 if (this.showLineLabelBG.size() <= series) { | 402 if (this.showLineLabelBG.size() <= series) { |
386 return false; | 403 return false; |
387 } | 404 } |
388 | 405 |
389 return showLineLabelBG.getBoolean(series); | 406 return showLineLabelBG.getBoolean(series); |
390 } | 407 } |
391 | 408 |
409 | |
392 public void setShowLineLabelBG(int series, boolean doShow) { | 410 public void setShowLineLabelBG(int series, boolean doShow) { |
393 this.showLineLabelBG.setBoolean(series, doShow); | 411 this.showLineLabelBG.setBoolean(series, doShow); |
394 } | 412 } |
395 | 413 |
396 public Color getLineLabelBGColor(int series) { | 414 public Color getLineLabelBGColor(int series) { |