📄 chartpanel.html
字号:
<FONT color="green">554</FONT> this.rangeZoomable = z.isRangeZoomable();<a name="line.554"></a><FONT color="green">555</FONT> this.orientation = z.getOrientation();<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> this.info = new ChartRenderingInfo();<a name="line.558"></a><FONT color="green">559</FONT> setPreferredSize(new Dimension(width, height));<a name="line.559"></a><FONT color="green">560</FONT> this.useBuffer = useBuffer;<a name="line.560"></a><FONT color="green">561</FONT> this.refreshBuffer = false;<a name="line.561"></a><FONT color="green">562</FONT> this.minimumDrawWidth = minimumDrawWidth;<a name="line.562"></a><FONT color="green">563</FONT> this.minimumDrawHeight = minimumDrawHeight;<a name="line.563"></a><FONT color="green">564</FONT> this.maximumDrawWidth = maximumDrawWidth;<a name="line.564"></a><FONT color="green">565</FONT> this.maximumDrawHeight = maximumDrawHeight;<a name="line.565"></a><FONT color="green">566</FONT> this.zoomTriggerDistance = DEFAULT_ZOOM_TRIGGER_DISTANCE;<a name="line.566"></a><FONT color="green">567</FONT> <a name="line.567"></a><FONT color="green">568</FONT> // set up popup menu...<a name="line.568"></a><FONT color="green">569</FONT> this.popup = null;<a name="line.569"></a><FONT color="green">570</FONT> if (properties || save || print || zoom) {<a name="line.570"></a><FONT color="green">571</FONT> this.popup = createPopupMenu(properties, save, print, zoom);<a name="line.571"></a><FONT color="green">572</FONT> }<a name="line.572"></a><FONT color="green">573</FONT> <a name="line.573"></a><FONT color="green">574</FONT> enableEvents(AWTEvent.MOUSE_EVENT_MASK);<a name="line.574"></a><FONT color="green">575</FONT> enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK);<a name="line.575"></a><FONT color="green">576</FONT> setDisplayToolTips(tooltips);<a name="line.576"></a><FONT color="green">577</FONT> addMouseListener(this);<a name="line.577"></a><FONT color="green">578</FONT> addMouseMotionListener(this);<a name="line.578"></a><FONT color="green">579</FONT> <a name="line.579"></a><FONT color="green">580</FONT> this.enforceFileExtensions = true;<a name="line.580"></a><FONT color="green">581</FONT> <a name="line.581"></a><FONT color="green">582</FONT> // initialize ChartPanel-specific tool tip delays with<a name="line.582"></a><FONT color="green">583</FONT> // values the from ToolTipManager.sharedInstance()<a name="line.583"></a><FONT color="green">584</FONT> ToolTipManager ttm = ToolTipManager.sharedInstance(); <a name="line.584"></a><FONT color="green">585</FONT> this.ownToolTipInitialDelay = ttm.getInitialDelay();<a name="line.585"></a><FONT color="green">586</FONT> this.ownToolTipDismissDelay = ttm.getDismissDelay();<a name="line.586"></a><FONT color="green">587</FONT> this.ownToolTipReshowDelay = ttm.getReshowDelay();<a name="line.587"></a><FONT color="green">588</FONT> <a name="line.588"></a><FONT color="green">589</FONT> }<a name="line.589"></a><FONT color="green">590</FONT> <a name="line.590"></a><FONT color="green">591</FONT> /**<a name="line.591"></a><FONT color="green">592</FONT> * Returns the chart contained in the panel.<a name="line.592"></a><FONT color="green">593</FONT> *<a name="line.593"></a><FONT color="green">594</FONT> * @return The chart (possibly <code>null</code>).<a name="line.594"></a><FONT color="green">595</FONT> */<a name="line.595"></a><FONT color="green">596</FONT> public JFreeChart getChart() {<a name="line.596"></a><FONT color="green">597</FONT> return this.chart;<a name="line.597"></a><FONT color="green">598</FONT> }<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> * Sets the chart that is displayed in the panel.<a name="line.601"></a><FONT color="green">602</FONT> *<a name="line.602"></a><FONT color="green">603</FONT> * @param chart the chart (<code>null</code> permitted).<a name="line.603"></a><FONT color="green">604</FONT> */<a name="line.604"></a><FONT color="green">605</FONT> public void setChart(JFreeChart chart) {<a name="line.605"></a><FONT color="green">606</FONT> <a name="line.606"></a><FONT color="green">607</FONT> // stop listening for changes to the existing chart<a name="line.607"></a><FONT color="green">608</FONT> if (this.chart != null) {<a name="line.608"></a><FONT color="green">609</FONT> this.chart.removeChangeListener(this);<a name="line.609"></a><FONT color="green">610</FONT> this.chart.removeProgressListener(this);<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> // add the new chart<a name="line.613"></a><FONT color="green">614</FONT> this.chart = chart;<a name="line.614"></a><FONT color="green">615</FONT> if (chart != null) {<a name="line.615"></a><FONT color="green">616</FONT> this.chart.addChangeListener(this);<a name="line.616"></a><FONT color="green">617</FONT> this.chart.addProgressListener(this);<a name="line.617"></a><FONT color="green">618</FONT> Plot plot = chart.getPlot();<a name="line.618"></a><FONT color="green">619</FONT> this.domainZoomable = false;<a name="line.619"></a><FONT color="green">620</FONT> this.rangeZoomable = false;<a name="line.620"></a><FONT color="green">621</FONT> if (plot instanceof Zoomable) {<a name="line.621"></a><FONT color="green">622</FONT> Zoomable z = (Zoomable) plot;<a name="line.622"></a><FONT color="green">623</FONT> this.domainZoomable = z.isDomainZoomable();<a name="line.623"></a><FONT color="green">624</FONT> this.rangeZoomable = z.isRangeZoomable();<a name="line.624"></a><FONT color="green">625</FONT> this.orientation = z.getOrientation();<a name="line.625"></a><FONT color="green">626</FONT> }<a name="line.626"></a><FONT color="green">627</FONT> }<a name="line.627"></a><FONT color="green">628</FONT> else {<a name="line.628"></a><FONT color="green">629</FONT> this.domainZoomable = false;<a name="line.629"></a><FONT color="green">630</FONT> this.rangeZoomable = false;<a name="line.630"></a><FONT color="green">631</FONT> }<a name="line.631"></a><FONT color="green">632</FONT> if (this.useBuffer) {<a name="line.632"></a><FONT color="green">633</FONT> this.refreshBuffer = true;<a name="line.633"></a><FONT color="green">634</FONT> }<a name="line.634"></a><FONT color="green">635</FONT> repaint();<a name="line.635"></a><FONT color="green">636</FONT> <a name="line.636"></a><FONT color="green">637</FONT> }<a name="line.637"></a><FONT color="green">638</FONT> <a name="line.638"></a><FONT color="green">639</FONT> /**<a name="line.639"></a><FONT color="green">640</FONT> * Returns the minimum drawing width for charts.<a name="line.640"></a><FONT color="green">641</FONT> * <P><a name="line.641"></a><FONT color="green">642</FONT> * If the width available on the panel is less than this, then the chart is<a name="line.642"></a><FONT color="green">643</FONT> * drawn at the minimum width then scaled down to fit.<a name="line.643"></a><FONT color="green">644</FONT> *<a name="line.644"></a><FONT color="green">645</FONT> * @return The minimum drawing width.<a name="line.645"></a><FONT color="green">646</FONT> */<a name="line.646"></a><FONT color="green">647</FONT> public int getMinimumDrawWidth() {<a name="line.647"></a><FONT color="green">648</FONT> return this.minimumDrawWidth;<a name="line.648"></a><FONT color="green">649</FONT> }<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> * Sets the minimum drawing width for the chart on this panel.<a name="line.652"></a><FONT color="green">653</FONT> * <P><a name="line.653"></a><FONT color="green">654</FONT> * At the time the chart is drawn on the panel, if the available width is<a name="line.654"></a><FONT color="green">655</FONT> * less than this amount, the chart will be drawn using the minimum width<a name="line.655"></a><FONT color="green">656</FONT> * then scaled down to fit the available space.<a name="line.656"></a><FONT color="green">657</FONT> *<a name="line.657"></a><FONT color="green">658</FONT> * @param width The width.<a name="line.658"></a><FONT color="green">659</FONT> */<a name="line.659"></a><FONT color="green">660</FONT> public void setMinimumDrawWidth(int width) {<a name="line.660"></a><FONT color="green">661</FONT> this.minimumDrawWidth = width;<a name="line.661"></a><FONT color="green">662</FONT> }<a name="line.662"></a><FONT color="green">663</FONT> <a name="line.663"></a><FONT color="green">664</FONT> /**<a name="line.664"></a><FONT color="green">665</FONT> * Returns the maximum drawing width for charts.<a name="line.665"></a><FONT color="green">666</FONT> * <P><a name="line.666"></a><FONT color="green">667</FONT> * If the width available on the panel is greater than this, then the chart<a name="line.667"></a><FONT color="green">668</FONT> * is drawn at the maximum width then scaled up to fit.<a name="line.668"></a><FONT color="green">669</FONT> *<a name="line.669"></a><FONT color="green">670</FONT> * @return The maximum drawing width.<a name="line.670"></a><FONT color="green">671</FONT> */<a name="line.671"></a><FONT color="green">672</FONT> public int getMaximumDrawWidth() {<a name="line.672"></a><FONT color="green">673</FONT> return this.maximumDrawWidth;<a name="line.673"></a><FONT color="green">674</FONT> }<a name="line.674"></a><FONT color="green">675</FONT> <a name="line.675"></a><FONT color="green">676</FONT> /**<a name="line.676"></a><FONT color="green">677</FONT> * Sets the maximum drawing width for the chart on this panel.<a name="line.677"></a><FONT color="green">678</FONT> * <P><a name="line.678"></a><FONT color="green">679</FONT> * At the time the chart is drawn on the panel, if the available width is<a name="line.679"></a><FONT color="green">680</FONT> * greater than this amount, the chart will be drawn using the maximum<a name="line.680"></a><FONT color="green">681</FONT> * width then scaled up to fit the available space.<a name="line.681"></a><FONT color="green">682</FONT> *<a name="line.682"></a><FONT color="green">683</FONT> * @param width The width.<a name="line.683"></a><FONT color="green">684</FONT> */<a name="line.684"></a><FONT color="green">685</FONT> public void setMaximumDrawWidth(int width) {<a name="line.685"></a><FONT color="green">686</FONT> this.maximumDrawWidth = width;<a name="line.686"></a><FONT color="green">687</FONT> }<a name="line.687"></a><FONT color="green">688</FONT> <a name="line.688"></a><FONT color="green">68
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -