From: <gh...@rh...> - 2009-05-27 15:45:01
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><style type="text/css"><!-- #msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : #fff; } #msg DT { float : left; width : 6em; font-weight : bold; } #msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; font-size : 10pt; } h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; font-weight : bold; } #msg PRE { overflow : auto; white-space : normal; background-color : #ffc; border : 1px #fc0 solid; padding : 6px; } #msg UL, PRE, .diff { overflow : auto; } #patch h4 { font-family : arial,helvetica,sans-serif; font-size : 10pt; } #patch h4 { padding: 8px; background : #369; color : #fff; margin : 0; } #patch .propset h4, #patch .binary h4 {margin: 0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {background:#eeeeee;padding: 0 0 10px 0;} #patch .propset .diff, #patch .binary .diff {padding: 10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch .add {background:#ddffdd;} #patch .rem {background:#ffdddd;} #patch .lines, .info {color:#888888;background:#ffffff;} .diff { width : 100%; } #msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : #fff; } #msg DT { float : left; width : 6em; font-weight : bold; } #msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; font-size : 10pt; } h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; font-weight : bold; } #msg PRE { overflow : auto; white-space : normal; background-color : #ffc; border : 1px #fc0 solid; padding : 6px; } #msg UL, PRE, .diff { overflow : auto; } #patch h4 { font-family : arial,helvetica,sans-serif; font-size : 10pt; } #patch h4 { padding: 8px; background : #369; color : #fff; margin : 0; } #patch .propset h4, #patch .binary h4 {margin: 0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {background:#eeeeee;padding: 0 0 10px 0;} #patch .propset .diff, #patch .binary .diff {padding: 10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch .add {background:#ddffdd;} #patch .rem {background:#ffdddd;} #patch .lines, .info {color:#888888;background:#ffffff;} .diff { width : 100%; } --></style> <title>[rhq-project.org rhq] [3989] Improvements to sparkline (handling no-data periods) and better style</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>3989</dd> <dt>Author</dt> <dd>ghinkle</dd> <dt>Date</dt> <dd>2009-05-27 10:44:58 -0500 (Wed, 27 May 2009)</dd> </dl> <h3>Log Message</h3> <pre>Improvements to sparkline (handling no-data periods) and better style</pre> <h3>Modified Paths</h3> <ul> <li><a href="#rhqtrunkmodulesenterpriseguiportalwarsrcmainjavaorgrhqenterpriseguicommongraphSparklineUIBeanjava">rhq/trunk/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/graph/SparklineUIBean.java</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="rhqtrunkmodulesenterpriseguiportalwarsrcmainjavaorgrhqenterpriseguicommongraphSparklineUIBeanjava"></a> <div class="modfile"><h4>Modified: rhq/trunk/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/graph/SparklineUIBean.java (3988 => 3989)</h4> <pre class="diff"> <span class="info">--- rhq/trunk/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/graph/SparklineUIBean.java 2009-05-27 05:55:31 UTC (rev 3988) +++ rhq/trunk/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/graph/SparklineUIBean.java 2009-05-27 15:44:58 UTC (rev 3989) </span><span class="lines">@@ -23,7 +23,13 @@ </span><span class="cx"> import java.awt.RenderingHints; import java.awt.Stroke; import java.awt.BasicStroke; </span><span class="add">+import java.awt.Point; +import java.awt.Polygon; +import java.awt.LinearGradientPaint; +import java.awt.GradientPaint; +import java.awt.geom.Point2D; </span><span class="cx"> import java.util.List; </span><span class="add">+import java.util.ArrayList; </span><span class="cx"> import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite; import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility; </span><span class="lines">@@ -38,8 +44,6 @@ </span><span class="cx"> public void paint(Graphics2D g2d, Object obj) { </span><span class="rem">-// this.scheduleId = (Integer) obj; - </span><span class="cx"> String[] keys = ((String)obj).split(":"); int resourceId = Integer.parseInt(keys[0]); </span><span class="lines">@@ -62,30 +66,26 @@ </span><span class="cx"> double heightScale = max-min != 0 ? (18d / (max - min)) : 0; </span><span class="rem">- g2d.setColor(Color.lightGray); </span><span class="cx"> int i = 1; </span><span class="rem">- for (MeasurementDataNumericHighLowComposite d : data) { - g2d.drawLine(i, 18 - (int)(heightScale * (d.getValue() - min)) - 1, i, 18); - i++; - } - - g2d.setColor(Color.gray); - i = 1; - double lastValue = 0; </span><span class="cx"> g2d.setStroke(new BasicStroke(0.6f)); </span><span class="add">+ Polygon p = new Polygon(); + p.addPoint(0,18); </span><span class="cx"> for (MeasurementDataNumericHighLowComposite d : data) { </span><span class="rem">- g2d.drawRect(i, 18 - (int)(heightScale * (d.getValue() - min)), 1, 1); - if (i > 1) { - g2d.drawLine(i-1, 18 - (int)(heightScale * (lastValue - min)), i, 18 - (int)(heightScale * (d.getValue() - min))); - } else { - g2d.drawRect(i, 18 - (int)(heightScale * (d.getValue() - min)), 1, 1); - </span><span class="add">+ if (!Double.isNaN(d.getValue())) { + p.addPoint(i,18 - (int)(heightScale * (d.getValue() - min))); </span><span class="cx"> } </span><span class="rem">- lastValue = d.getValue(); </span><span class="cx"> i++; } </span><span class="rem">- </span><span class="add">+ p.addPoint(60,18); + + g2d.setPaint(new GradientPaint(0,18, Color.lightGray , 0,0, Color.darkGray)); + g2d.fillPolygon(p); + + + g2d.setColor(Color.lightGray); + g2d.drawPolygon(p); + </span><span class="cx"> } private List<MeasurementDataNumericHighLowComposite> getData(int resourceId, int scheduleDefId) { </span> </pre> </div> </div> </body> </html> |