[Schmitzm-commits] r443 - branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Oct 5 17:59:17 CEST 2009
Author: mojays
Date: 2009-10-05 17:59:16 +0200 (Mon, 05 Oct 2009)
New Revision: 443
Modified:
branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/ChartPlotStyle.java
branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/ChartStyleXMLFactory.java
Log:
Charts: Crosshair lines and paint
Modified: branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/ChartPlotStyle.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/ChartPlotStyle.java 2009-10-05 15:47:48 UTC (rev 442)
+++ branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/ChartPlotStyle.java 2009-10-05 15:59:16 UTC (rev 443)
@@ -51,6 +51,8 @@
* {@link CategoryPlot})</li>
* <li>range grid line visibility and color (only applicable for {@link XYPlot} and
* {@link CategoryPlot})</li>
+ * <li>crosshair visibility (around 0/0) and color (only applicable for {@link XYPlot} and
+ * {@link CategoryPlot})</li>
* </ul>
* @author <a href="mailto:Martin.Schmitz at koeln.de">Martin Schmitz</a>
* @version 1.0
@@ -75,6 +77,10 @@
protected Boolean rangeGridlineVisible = null;
/** Holds the color of the range grid line. */
protected Color rangeGridlinePaint = null;
+ /** Holds whether crosshair lines are visible (on 0/0). */
+ protected Boolean crosshairVisible = null;
+ /** Holds the color of the range grid line. */
+ protected Color crosshairPaint = null;
/**
@@ -218,6 +224,40 @@
}
/**
+ * Returns whether the plot's crosshair lines are visible.
+ * @return {@code null} if property is not set for the plot
+ */
+ public Boolean isCrosshairVisible() {
+ return crosshairVisible;
+ }
+
+ /**
+ * Sets whether the plot's crosshair lines are visible.
+ * @param visible indicates the visibility of the crosshair lines (can be
+ * {@code null} to reset to a non-specific property)
+ */
+ public void setCrosshairVisible(Boolean visible) {
+ crosshairVisible = visible;
+ }
+
+ /**
+ * Returns the color of the plot's crosshair lines.
+ * @return {@code null} if no specific color is set
+ */
+ public Color getCrosshairPaint() {
+ return crosshairPaint;
+ }
+
+ /**
+ * Sets the color of the plot's crosshair lines.
+ * @param color color for the crosshair lines (can be {@code null} to reset
+ * to a non-specific color)
+ */
+ public void setCrosshairPaint(Color color) {
+ this.crosshairPaint = color;
+ }
+
+ /**
* Applies the style to a specific plot.<br>
* Note: Some style properties can only be applied to specific plot types.
* @param plot a plot
@@ -227,7 +267,7 @@
LOGGER.debug("No plot to be customised.");
return;
}
-
+
// Apply common attributes
if ( getForegroundAlpha() != null )
plot.setForegroundAlpha( getForegroundAlpha() );
@@ -242,7 +282,7 @@
if (plot instanceof CategoryPlot)
applyToCategoryPlot((CategoryPlot)plot);
if (plot instanceof XYPlot)
- applyToCategoryPlot((XYPlot)plot);
+ applyToXYPlot((XYPlot)plot);
// notify the listeners about style change
JFreeChartUtil.fireChangeEvent(plot);
@@ -264,6 +304,14 @@
plot.setRangeGridlinesVisible( isRangeGridlineVisible() );
if ( getRangeGridlinePaint() != null )
plot.setRangeGridlinePaint( getRangeGridlinePaint() );
+ if ( isCrosshairVisible() != null ) {
+ plot.setDomainCrosshairVisible( isCrosshairVisible() );
+ plot.setRangeCrosshairVisible( isCrosshairVisible() );
+ }
+ if ( getCrosshairPaint() != null ) {
+ plot.setDomainCrosshairPaint( getCrosshairPaint() );
+ plot.setRangeCrosshairPaint( getCrosshairPaint() );
+ }
}
/**
@@ -272,7 +320,7 @@
* Called by {@link #applyToPlot(Plot)}.
* @param plot a {@link XYPlot}
*/
- protected void applyToCategoryPlot(XYPlot plot) {
+ protected void applyToXYPlot(XYPlot plot) {
if ( isDomainGridlineVisible() != null )
plot.setDomainGridlinesVisible( isDomainGridlineVisible() );
if ( getDomainGridlinePaint() != null )
@@ -281,5 +329,16 @@
plot.setRangeGridlinesVisible( isRangeGridlineVisible() );
if ( getRangeGridlinePaint() != null )
plot.setRangeGridlinePaint( getRangeGridlinePaint() );
+ if ( isCrosshairVisible() != null ) {
+ plot.setDomainCrosshairVisible( isCrosshairVisible() );
+ plot.setRangeCrosshairVisible( isCrosshairVisible() );
+ }
+ if ( getCrosshairPaint() != null ) {
+ plot.setDomainCrosshairPaint( getCrosshairPaint() );
+ plot.setRangeCrosshairPaint( getCrosshairPaint() );
+ }
+
+// plot.zoomDomainAxes(0.5,0.5, null, null);
+// plot.zoomRangeAxes(0.5,0.5, null, null);
}
}
Modified: branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/ChartStyleXMLFactory.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/ChartStyleXMLFactory.java 2009-10-05 15:47:48 UTC (rev 442)
+++ branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/ChartStyleXMLFactory.java 2009-10-05 15:59:16 UTC (rev 443)
@@ -369,6 +369,17 @@
if ( color != null )
style.setRangeGridlinePaint(color);
}
+
+ // crosshair lines color and visiblilty
+ Element crosshairElem = element.getChild("crosshairLines");
+ if ( crosshairElem != null ) {
+ Boolean visible = XMLUtil.getBooleanAttribute(crosshairElem, "visible");
+ if ( visible != null )
+ style.setCrosshairVisible(visible);
+ Color color = XMLUtil.getColorAttribute(crosshairElem, "paint");
+ if ( color != null )
+ style.setCrosshairPaint(color);
+ }
return style;
}
@@ -466,6 +477,10 @@
"visible", plotStyle.isRangeGridlineVisible(),
"paint", plotStyle.getRangeGridlinePaint()
);
+ addChildToElement(plotElem, "crosshairLines", false,
+ "visible", plotStyle.isCrosshairVisible(),
+ "paint", plotStyle.getCrosshairPaint()
+ );
}
// Type specific style properties
More information about the Schmitzm-commits
mailing list