📄 xyboxandwhiskerrenderer.html
字号:
<FONT color="green">558</FONT> }<a name="line.558"></a><FONT color="green">559</FONT> g2.draw(box);<a name="line.559"></a><FONT color="green">560</FONT> <a name="line.560"></a><FONT color="green">561</FONT> // draw median<a name="line.561"></a><FONT color="green">562</FONT> g2.setPaint(getArtifactPaint());<a name="line.562"></a><FONT color="green">563</FONT> g2.draw(new Line2D.Double(xx - width / 2, yyMedian, xx + width / 2, <a name="line.563"></a><FONT color="green">564</FONT> yyMedian));<a name="line.564"></a><FONT color="green">565</FONT> <a name="line.565"></a><FONT color="green">566</FONT> double aRadius = 0; // average radius<a name="line.566"></a><FONT color="green">567</FONT> double oRadius = width / 3; // outlier radius<a name="line.567"></a><FONT color="green">568</FONT> <a name="line.568"></a><FONT color="green">569</FONT> // draw average - SPECIAL AIMS REQUIREMENT<a name="line.569"></a><FONT color="green">570</FONT> if (yAverage != null) {<a name="line.570"></a><FONT color="green">571</FONT> aRadius = width / 4;<a name="line.571"></a><FONT color="green">572</FONT> Ellipse2D.Double avgEllipse = new Ellipse2D.Double(<a name="line.572"></a><FONT color="green">573</FONT> xx - aRadius, yyAverage - aRadius, aRadius * 2, aRadius * 2<a name="line.573"></a><FONT color="green">574</FONT> );<a name="line.574"></a><FONT color="green">575</FONT> g2.fill(avgEllipse);<a name="line.575"></a><FONT color="green">576</FONT> g2.draw(avgEllipse);<a name="line.576"></a><FONT color="green">577</FONT> }<a name="line.577"></a><FONT color="green">578</FONT> <a name="line.578"></a><FONT color="green">579</FONT> List outliers = new ArrayList();<a name="line.579"></a><FONT color="green">580</FONT> OutlierListCollection outlierListCollection <a name="line.580"></a><FONT color="green">581</FONT> = new OutlierListCollection();<a name="line.581"></a><FONT color="green">582</FONT> <a name="line.582"></a><FONT color="green">583</FONT> /* From outlier array sort out which are outliers and put these into <a name="line.583"></a><FONT color="green">584</FONT> * an arraylist. If there are any farouts, set the flag on the <a name="line.584"></a><FONT color="green">585</FONT> * OutlierListCollection<a name="line.585"></a><FONT color="green">586</FONT> */<a name="line.586"></a><FONT color="green">587</FONT> <a name="line.587"></a><FONT color="green">588</FONT> for (int i = 0; i < yOutliers.size(); i++) {<a name="line.588"></a><FONT color="green">589</FONT> double outlier = ((Number) yOutliers.get(i)).doubleValue();<a name="line.589"></a><FONT color="green">590</FONT> if (outlier > boxAndWhiskerData.getMaxOutlier(series, <a name="line.590"></a><FONT color="green">591</FONT> item).doubleValue()) {<a name="line.591"></a><FONT color="green">592</FONT> outlierListCollection.setHighFarOut(true);<a name="line.592"></a><FONT color="green">593</FONT> } <a name="line.593"></a><FONT color="green">594</FONT> else if (outlier < boxAndWhiskerData.getMinOutlier(series, <a name="line.594"></a><FONT color="green">595</FONT> item).doubleValue()) {<a name="line.595"></a><FONT color="green">596</FONT> outlierListCollection.setLowFarOut(true);<a name="line.596"></a><FONT color="green">597</FONT> } <a name="line.597"></a><FONT color="green">598</FONT> else if (outlier > boxAndWhiskerData.getMaxRegularValue(series, <a name="line.598"></a><FONT color="green">599</FONT> item).doubleValue()) {<a name="line.599"></a><FONT color="green">600</FONT> yyOutlier = rangeAxis.valueToJava2D(outlier, dataArea, <a name="line.600"></a><FONT color="green">601</FONT> location);<a name="line.601"></a><FONT color="green">602</FONT> outliers.add(new Outlier(xx, yyOutlier, oRadius));<a name="line.602"></a><FONT color="green">603</FONT> }<a name="line.603"></a><FONT color="green">604</FONT> else if (outlier < boxAndWhiskerData.getMinRegularValue(series, <a name="line.604"></a><FONT color="green">605</FONT> item).doubleValue()) {<a name="line.605"></a><FONT color="green">606</FONT> yyOutlier = rangeAxis.valueToJava2D(outlier, dataArea, <a name="line.606"></a><FONT color="green">607</FONT> location);<a name="line.607"></a><FONT color="green">608</FONT> outliers.add(new Outlier(xx, yyOutlier, oRadius));<a name="line.608"></a><FONT color="green">609</FONT> }<a name="line.609"></a><FONT color="green">610</FONT> Collections.sort(outliers);<a name="line.610"></a><FONT color="green">611</FONT> }<a name="line.611"></a><FONT color="green">612</FONT> <a name="line.612"></a><FONT color="green">613</FONT> // Process outliers. Each outlier is either added to the appropriate <a name="line.613"></a><FONT color="green">614</FONT> // outlier list or a new outlier list is made<a name="line.614"></a><FONT color="green">615</FONT> for (Iterator iterator = outliers.iterator(); iterator.hasNext();) {<a name="line.615"></a><FONT color="green">616</FONT> Outlier outlier = (Outlier) iterator.next();<a name="line.616"></a><FONT color="green">617</FONT> outlierListCollection.add(outlier);<a name="line.617"></a><FONT color="green">618</FONT> }<a name="line.618"></a><FONT color="green">619</FONT> <a name="line.619"></a><FONT color="green">620</FONT> // draw yOutliers<a name="line.620"></a><FONT color="green">621</FONT> double maxAxisValue = rangeAxis.valueToJava2D(<a name="line.621"></a><FONT color="green">622</FONT> rangeAxis.getUpperBound(), dataArea, location<a name="line.622"></a><FONT color="green">623</FONT> ) + aRadius;<a name="line.623"></a><FONT color="green">624</FONT> double minAxisValue = rangeAxis.valueToJava2D(<a name="line.624"></a><FONT color="green">625</FONT> rangeAxis.getLowerBound(), dataArea, location<a name="line.625"></a><FONT color="green">626</FONT> ) - aRadius;<a name="line.626"></a><FONT color="green">627</FONT> <a name="line.627"></a><FONT color="green">628</FONT> // draw outliers<a name="line.628"></a><FONT color="green">629</FONT> for (Iterator iterator = outlierListCollection.iterator(); <a name="line.629"></a><FONT color="green">630</FONT> iterator.hasNext();) {<a name="line.630"></a><FONT color="green">631</FONT> OutlierList list = (OutlierList) iterator.next();<a name="line.631"></a><FONT color="green">632</FONT> Outlier outlier = list.getAveragedOutlier();<a name="line.632"></a><FONT color="green">633</FONT> Point2D point = outlier.getPoint();<a name="line.633"></a><FONT color="green">634</FONT> <a name="line.634"></a><FONT color="green">635</FONT> if (list.isMultiple()) {<a name="line.635"></a><FONT color="green">636</FONT> drawMultipleEllipse(point, width, oRadius, g2);<a name="line.636"></a><FONT color="green">637</FONT> } <a name="line.637"></a><FONT color="green">638</FONT> else {<a name="line.638"></a><FONT color="green">639</FONT> drawEllipse(point, oRadius, g2);<a name="line.639"></a><FONT color="green">640</FONT> }<a name="line.640"></a><FONT color="green">641</FONT> }<a name="line.641"></a><FONT color="green">642</FONT> <a name="line.642"></a><FONT color="green">643</FONT> // draw farout<a name="line.643"></a><FONT color="green">644</FONT> if (outlierListCollection.isHighFarOut()) {<a name="line.644"></a><FONT color="green">645</FONT> drawHighFarOut(aRadius, g2, xx, maxAxisValue);<a name="line.645"></a><FONT color="green">646</FONT> }<a name="line.646"></a><FONT color="green">647</FONT> <a name="line.647"></a><FONT color="green">648</FONT> if (outlierListCollection.isLowFarOut()) {<a name="line.648"></a><FONT color="green">649</FONT> drawLowFarOut(aRadius, g2, xx, minAxisValue);<a name="line.649"></a><FONT color="green">650</FONT> }<a name="line.650"></a><FONT color="green">651</FONT> <a name="line.651"></a><FONT color="green">652</FONT> // add an entity for the item...<a name="line.652"></a><FONT color="green">653</FONT> if (entities != null) {<a name="line.653"></a><FONT color="green">654</FONT> String tip = null;<a name="line.654"></a><FONT color="green">655</FONT> XYToolTipGenerator generator = getToolTipGenerator(series, item);<a name="line.655"></a><FONT color="green">656</FONT> if (generator != null) {<a name="line.656"></a><FONT color="green">657</FONT> tip = generator.generateToolTip(dataset, series, item);<a name="line.657"></a><FONT color="green">658</FONT> }<a name="line.658"></a><FONT color="green">659</FONT> String url = null;<a name="line.659"></a><FONT color="green">660</FONT> if (getURLGenerator() != null) {<a name="line.660"></a><FONT color="green">661</FONT> url = getURLGenerator().generateURL(dataset, series, item);<a name="line.661"></a><FONT color="green">662</FONT> }<a name="line.662"></a><FONT color="green">663</FONT> XYItemEntity entity = new XYItemEntity(box, dataset, series, item, <a name="line.663"></a><FONT color="green">664</FONT> tip, url);<a name="line.664"></a><FONT color="green">665</FONT> entities.add(entity);<a name="line.665"></a><FONT color="green">666</FONT> }<a name="line.666"></a><FONT color="green">667</FONT> <a name="line.667"></a><FONT color="green">668</FONT> }<a name="line.668"></a><FONT color="green">669</FONT> <a name="line.669"></a><FONT color="green">670</FONT> /**<a name="line.670"></a><FONT color="green">671</FONT> * Draws an ellipse to represent an outlier.<a name="line.671"></a><FONT color="green">672</FONT> * <a name="line.672"></a><FONT color="green">673</FONT> * @param point the location.<a name="line.673"></a><FONT color="green">674</FONT> * @param oRadius the radius.<a name="line.674"></a><FONT color="green">675</FONT> * @param g2 the graphics device.<a name="line.675"></a><FONT color="green">676</FONT> */<a name="line.676"></a><FONT color="green">677</FONT> protected void drawEllipse(Point2D point, double oRadius, Graphics2D g2) {<a name="line.677"></a><FONT color="green">678</FONT> Ellipse2D.Double dot = new Ellipse2D.Double(<a name="line.678"></a><FONT color="green">679</FONT> point.getX() + oRadius / 2, point.getY(), oRadius, oRadius<a name="line.679"></a><FONT color="green">680</FONT> );<a name="line.680"></a><FONT color="green">681</FONT> g2.draw(dot);<a name="line.681"></a><FONT color="green">682</FONT> }<a name="line.682"></a><FONT color="green">683</FONT> <a name="line.683"></a><FONT color="green">684</FONT> /**<a name="line.684"></a><FONT color="green">685</FONT> * Draws two ellipses to represent overlapping outliers.<a name="line.685"></a><FONT color="green">686</FONT> * <a name="line.686"></a><FONT color="green">687</FONT> * @param point the location.<a name="line.687"></a><FONT color="green">688</FONT> * @param boxWidth the box width.<a name="line.688"></a><FONT color="green">689</FONT> * @param oRadius the radius.<a name="line.689"></a><FONT color="green">690</FONT> * @param g2 the graphics device.<a name="line.690"></a><FONT color="green">691</FONT> */<a name="line.691"></a><FONT color="green">692</FONT> protected void drawMultipleEllipse(Point2D point, double boxWidth, <a name="line.692"></a><FONT color="green">693</FONT> double oRadius, Graphics2D g2) {<a name="line.693"></a><FONT color="green">694</FONT> <a name="line.694"></a><FONT color="green">695</FONT> Ellipse2D.Double dot1 = new Ellipse2D.Double(<a name="line.695"></a><FONT color="green">696</FONT> point.getX() - (boxWidth / 2) + oRadius, point.getY(), oRadius, <a name="line.696"></a><FONT color="green">697</FONT>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -