📄 xysteparearenderer.html
字号:
<FONT color="green">472</FONT> }<a name="line.472"></a><FONT color="green">473</FONT> <a name="line.473"></a><FONT color="green">474</FONT> // fill the polygon<a name="line.474"></a><FONT color="green">475</FONT> g2.fill(this.pArea);<a name="line.475"></a><FONT color="green">476</FONT> <a name="line.476"></a><FONT color="green">477</FONT> // draw an outline around the Area.<a name="line.477"></a><FONT color="green">478</FONT> if (isOutline()) {<a name="line.478"></a><FONT color="green">479</FONT> g2.setStroke(plot.getOutlineStroke());<a name="line.479"></a><FONT color="green">480</FONT> g2.setPaint(plot.getOutlinePaint());<a name="line.480"></a><FONT color="green">481</FONT> g2.draw(this.pArea);<a name="line.481"></a><FONT color="green">482</FONT> }<a name="line.482"></a><FONT color="green">483</FONT> <a name="line.483"></a><FONT color="green">484</FONT> // start new area when needed (see above)<a name="line.484"></a><FONT color="green">485</FONT> this.pArea = null;<a name="line.485"></a><FONT color="green">486</FONT> }<a name="line.486"></a><FONT color="green">487</FONT> <a name="line.487"></a><FONT color="green">488</FONT> // do we need to update the crosshair values?<a name="line.488"></a><FONT color="green">489</FONT> if (!Double.isNaN(y1)) {<a name="line.489"></a><FONT color="green">490</FONT> updateCrosshairValues(crosshairState, x1, y1, transX1, transY1, <a name="line.490"></a><FONT color="green">491</FONT> orientation);<a name="line.491"></a><FONT color="green">492</FONT> }<a name="line.492"></a><FONT color="green">493</FONT> <a name="line.493"></a><FONT color="green">494</FONT> // collect entity and tool tip information...<a name="line.494"></a><FONT color="green">495</FONT> if (state.getInfo() != null) {<a name="line.495"></a><FONT color="green">496</FONT> EntityCollection entities = state.getEntityCollection();<a name="line.496"></a><FONT color="green">497</FONT> if (entities != null && shape != null) {<a name="line.497"></a><FONT color="green">498</FONT> String tip = null;<a name="line.498"></a><FONT color="green">499</FONT> XYToolTipGenerator generator <a name="line.499"></a><FONT color="green">500</FONT> = getToolTipGenerator(series, item);<a name="line.500"></a><FONT color="green">501</FONT> if (generator != null) {<a name="line.501"></a><FONT color="green">502</FONT> tip = generator.generateToolTip(dataset, series, item);<a name="line.502"></a><FONT color="green">503</FONT> }<a name="line.503"></a><FONT color="green">504</FONT> String url = null;<a name="line.504"></a><FONT color="green">505</FONT> if (getURLGenerator() != null) {<a name="line.505"></a><FONT color="green">506</FONT> url = getURLGenerator().generateURL(dataset, series, item);<a name="line.506"></a><FONT color="green">507</FONT> }<a name="line.507"></a><FONT color="green">508</FONT> XYItemEntity entity = new XYItemEntity(shape, dataset, series, <a name="line.508"></a><FONT color="green">509</FONT> item, tip, url);<a name="line.509"></a><FONT color="green">510</FONT> entities.add(entity);<a name="line.510"></a><FONT color="green">511</FONT> }<a name="line.511"></a><FONT color="green">512</FONT> }<a name="line.512"></a><FONT color="green">513</FONT> }<a name="line.513"></a><FONT color="green">514</FONT> <a name="line.514"></a><FONT color="green">515</FONT> /**<a name="line.515"></a><FONT color="green">516</FONT> * Returns a clone of the renderer.<a name="line.516"></a><FONT color="green">517</FONT> * <a name="line.517"></a><FONT color="green">518</FONT> * @return A clone.<a name="line.518"></a><FONT color="green">519</FONT> * <a name="line.519"></a><FONT color="green">520</FONT> * @throws CloneNotSupportedException if the renderer cannot be cloned.<a name="line.520"></a><FONT color="green">521</FONT> */<a name="line.521"></a><FONT color="green">522</FONT> public Object clone() throws CloneNotSupportedException {<a name="line.522"></a><FONT color="green">523</FONT> return super.clone();<a name="line.523"></a><FONT color="green">524</FONT> }<a name="line.524"></a><FONT color="green">525</FONT> <a name="line.525"></a><FONT color="green">526</FONT> /**<a name="line.526"></a><FONT color="green">527</FONT> * Helper method which returns a value if it lies<a name="line.527"></a><FONT color="green">528</FONT> * inside the visible dataArea and otherwise the corresponding<a name="line.528"></a><FONT color="green">529</FONT> * coordinate on the border of the dataArea. The PlotOrientation<a name="line.529"></a><FONT color="green">530</FONT> * is taken into account. <a name="line.530"></a><FONT color="green">531</FONT> * Useful to avoid possible sun.dc.pr.PRException: endPath: bad path<a name="line.531"></a><FONT color="green">532</FONT> * which occurs when trying to draw lines/shapes which in large part<a name="line.532"></a><FONT color="green">533</FONT> * lie outside of the visible dataArea.<a name="line.533"></a><FONT color="green">534</FONT> * <a name="line.534"></a><FONT color="green">535</FONT> * @param value the value which shall be <a name="line.535"></a><FONT color="green">536</FONT> * @param dataArea the area within which the data is being drawn.<a name="line.536"></a><FONT color="green">537</FONT> * @param plot the plot (can be used to obtain standard color <a name="line.537"></a><FONT color="green">538</FONT> * information etc).<a name="line.538"></a><FONT color="green">539</FONT> * @return <code>double</code> value inside the data area.<a name="line.539"></a><FONT color="green">540</FONT> */<a name="line.540"></a><FONT color="green">541</FONT> protected static double restrictValueToDataArea(double value, <a name="line.541"></a><FONT color="green">542</FONT> XYPlot plot, <a name="line.542"></a><FONT color="green">543</FONT> Rectangle2D dataArea) {<a name="line.543"></a><FONT color="green">544</FONT> double min = 0;<a name="line.544"></a><FONT color="green">545</FONT> double max = 0;<a name="line.545"></a><FONT color="green">546</FONT> if (plot.getOrientation() == PlotOrientation.VERTICAL) {<a name="line.546"></a><FONT color="green">547</FONT> min = dataArea.getMinY();<a name="line.547"></a><FONT color="green">548</FONT> max = dataArea.getMaxY();<a name="line.548"></a><FONT color="green">549</FONT> } <a name="line.549"></a><FONT color="green">550</FONT> else if (plot.getOrientation() == PlotOrientation.HORIZONTAL) {<a name="line.550"></a><FONT color="green">551</FONT> min = dataArea.getMinX();<a name="line.551"></a><FONT color="green">552</FONT> max = dataArea.getMaxX();<a name="line.552"></a><FONT color="green">553</FONT> } <a name="line.553"></a><FONT color="green">554</FONT> if (value < min) {<a name="line.554"></a><FONT color="green">555</FONT> value = min;<a name="line.555"></a><FONT color="green">556</FONT> }<a name="line.556"></a><FONT color="green">557</FONT> else if (value > max) {<a name="line.557"></a><FONT color="green">558</FONT> value = max;<a name="line.558"></a><FONT color="green">559</FONT> }<a name="line.559"></a><FONT color="green">560</FONT> return value;<a name="line.560"></a><FONT color="green">561</FONT> }<a name="line.561"></a><FONT color="green">562</FONT> <a name="line.562"></a><FONT color="green">563</FONT> }<a name="line.563"></a></PRE></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -