📄 combinedrangexyplot.html
字号:
<FONT color="green">535</FONT> result = Range.combine(result, subplot.getDataRange(axis));<a name="line.535"></a><FONT color="green">536</FONT> }<a name="line.536"></a><FONT color="green">537</FONT> }<a name="line.537"></a><FONT color="green">538</FONT> return result;<a name="line.538"></a><FONT color="green">539</FONT> <a name="line.539"></a><FONT color="green">540</FONT> }<a name="line.540"></a><FONT color="green">541</FONT> <a name="line.541"></a><FONT color="green">542</FONT> /**<a name="line.542"></a><FONT color="green">543</FONT> * Sets the space (width or height, depending on the orientation of the <a name="line.543"></a><FONT color="green">544</FONT> * plot) for the domain axis of each subplot.<a name="line.544"></a><FONT color="green">545</FONT> *<a name="line.545"></a><FONT color="green">546</FONT> * @param space the space.<a name="line.546"></a><FONT color="green">547</FONT> */<a name="line.547"></a><FONT color="green">548</FONT> protected void setFixedDomainAxisSpaceForSubplots(AxisSpace space) {<a name="line.548"></a><FONT color="green">549</FONT> <a name="line.549"></a><FONT color="green">550</FONT> Iterator iterator = this.subplots.iterator();<a name="line.550"></a><FONT color="green">551</FONT> while (iterator.hasNext()) {<a name="line.551"></a><FONT color="green">552</FONT> XYPlot plot = (XYPlot) iterator.next();<a name="line.552"></a><FONT color="green">553</FONT> plot.setFixedDomainAxisSpace(space);<a name="line.553"></a><FONT color="green">554</FONT> }<a name="line.554"></a><FONT color="green">555</FONT> <a name="line.555"></a><FONT color="green">556</FONT> }<a name="line.556"></a><FONT color="green">557</FONT> <a name="line.557"></a><FONT color="green">558</FONT> /**<a name="line.558"></a><FONT color="green">559</FONT> * Handles a 'click' on the plot by updating the anchor values...<a name="line.559"></a><FONT color="green">560</FONT> *<a name="line.560"></a><FONT color="green">561</FONT> * @param x x-coordinate, where the click occured.<a name="line.561"></a><FONT color="green">562</FONT> * @param y y-coordinate, where the click occured.<a name="line.562"></a><FONT color="green">563</FONT> * @param info object containing information about the plot dimensions.<a name="line.563"></a><FONT color="green">564</FONT> */<a name="line.564"></a><FONT color="green">565</FONT> public void handleClick(int x, int y, PlotRenderingInfo info) {<a name="line.565"></a><FONT color="green">566</FONT> <a name="line.566"></a><FONT color="green">567</FONT> Rectangle2D dataArea = info.getDataArea();<a name="line.567"></a><FONT color="green">568</FONT> if (dataArea.contains(x, y)) {<a name="line.568"></a><FONT color="green">569</FONT> for (int i = 0; i < this.subplots.size(); i++) {<a name="line.569"></a><FONT color="green">570</FONT> XYPlot subplot = (XYPlot) this.subplots.get(i);<a name="line.570"></a><FONT color="green">571</FONT> PlotRenderingInfo subplotInfo = info.getSubplotInfo(i);<a name="line.571"></a><FONT color="green">572</FONT> subplot.handleClick(x, y, subplotInfo);<a name="line.572"></a><FONT color="green">573</FONT> }<a name="line.573"></a><FONT color="green">574</FONT> }<a name="line.574"></a><FONT color="green">575</FONT> <a name="line.575"></a><FONT color="green">576</FONT> }<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> * Receives a {@link PlotChangeEvent} and responds by notifying all <a name="line.579"></a><FONT color="green">580</FONT> * listeners.<a name="line.580"></a><FONT color="green">581</FONT> * <a name="line.581"></a><FONT color="green">582</FONT> * @param event the event.<a name="line.582"></a><FONT color="green">583</FONT> */<a name="line.583"></a><FONT color="green">584</FONT> public void plotChanged(PlotChangeEvent event) {<a name="line.584"></a><FONT color="green">585</FONT> notifyListeners(event);<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> /**<a name="line.588"></a><FONT color="green">589</FONT> * Tests this plot for equality with another object.<a name="line.589"></a><FONT color="green">590</FONT> *<a name="line.590"></a><FONT color="green">591</FONT> * @param obj the other object.<a name="line.591"></a><FONT color="green">592</FONT> *<a name="line.592"></a><FONT color="green">593</FONT> * @return <code>true</code> or <code>false</code>.<a name="line.593"></a><FONT color="green">594</FONT> */<a name="line.594"></a><FONT color="green">595</FONT> public boolean equals(Object obj) {<a name="line.595"></a><FONT color="green">596</FONT> <a name="line.596"></a><FONT color="green">597</FONT> if (obj == this) {<a name="line.597"></a><FONT color="green">598</FONT> return true;<a name="line.598"></a><FONT color="green">599</FONT> }<a name="line.599"></a><FONT color="green">600</FONT> <a name="line.600"></a><FONT color="green">601</FONT> if (!(obj instanceof CombinedRangeXYPlot)) {<a name="line.601"></a><FONT color="green">602</FONT> return false;<a name="line.602"></a><FONT color="green">603</FONT> }<a name="line.603"></a><FONT color="green">604</FONT> if (!super.equals(obj)) {<a name="line.604"></a><FONT color="green">605</FONT> return false;<a name="line.605"></a><FONT color="green">606</FONT> }<a name="line.606"></a><FONT color="green">607</FONT> CombinedRangeXYPlot that = (CombinedRangeXYPlot) obj;<a name="line.607"></a><FONT color="green">608</FONT> if (!ObjectUtilities.equal(this.subplots, that.subplots)) {<a name="line.608"></a><FONT color="green">609</FONT> return false;<a name="line.609"></a><FONT color="green">610</FONT> }<a name="line.610"></a><FONT color="green">611</FONT> if (this.totalWeight != that.totalWeight) {<a name="line.611"></a><FONT color="green">612</FONT> return false;<a name="line.612"></a><FONT color="green">613</FONT> }<a name="line.613"></a><FONT color="green">614</FONT> if (this.gap != that.gap) {<a name="line.614"></a><FONT color="green">615</FONT> return false;<a name="line.615"></a><FONT color="green">616</FONT> }<a name="line.616"></a><FONT color="green">617</FONT> return true;<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> /**<a name="line.620"></a><FONT color="green">621</FONT> * Returns a clone of the plot.<a name="line.621"></a><FONT color="green">622</FONT> * <a name="line.622"></a><FONT color="green">623</FONT> * @return A clone.<a name="line.623"></a><FONT color="green">624</FONT> * <a name="line.624"></a><FONT color="green">625</FONT> * @throws CloneNotSupportedException this class will not throw this <a name="line.625"></a><FONT color="green">626</FONT> * exception, but subclasses (if any) might.<a name="line.626"></a><FONT color="green">627</FONT> */<a name="line.627"></a><FONT color="green">628</FONT> public Object clone() throws CloneNotSupportedException {<a name="line.628"></a><FONT color="green">629</FONT> <a name="line.629"></a><FONT color="green">630</FONT> CombinedRangeXYPlot result = (CombinedRangeXYPlot) super.clone(); <a name="line.630"></a><FONT color="green">631</FONT> result.subplots = (List) ObjectUtilities.deepClone(this.subplots);<a name="line.631"></a><FONT color="green">632</FONT> for (Iterator it = result.subplots.iterator(); it.hasNext();) {<a name="line.632"></a><FONT color="green">633</FONT> Plot child = (Plot) it.next();<a name="line.633"></a><FONT color="green">634</FONT> child.setParent(result);<a name="line.634"></a><FONT color="green">635</FONT> }<a name="line.635"></a><FONT color="green">636</FONT> <a name="line.636"></a><FONT color="green">637</FONT> // after setting up all the subplots, the shared range axis may need <a name="line.637"></a><FONT color="green">638</FONT> // reconfiguring<a name="line.638"></a><FONT color="green">639</FONT> ValueAxis rangeAxis = result.getRangeAxis();<a name="line.639"></a><FONT color="green">640</FONT> if (rangeAxis != null) {<a name="line.640"></a><FONT color="green">641</FONT> rangeAxis.configure();<a name="line.641"></a><FONT color="green">642</FONT> }<a name="line.642"></a><FONT color="green">643</FONT> <a name="line.643"></a><FONT color="green">644</FONT> return result;<a name="line.644"></a><FONT color="green">645</FONT> }<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></PRE></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -