📄 categoryplot.java
字号:
Marker baseline = new ValueMarker( 0.0, new Color(0.8f, 0.8f, 0.8f, 0.5f), new BasicStroke(1.0f), new Color(0.85f, 0.85f, 0.95f, 0.5f), new BasicStroke(1.0f), 0.6f ); addRangeMarker(baseline, Layer.BACKGROUND); this.anchorValue = 0.0; } /** * Returns a string describing the type of plot. * * @return The type. */ public String getPlotType() { return localizationResources.getString("Category_Plot"); } /** * Returns the orientation of the plot. * * @return The orientation of the plot. */ public PlotOrientation getOrientation() { return this.orientation; } /** * Sets the orientation for the plot and sends a {@link PlotChangeEvent} to all registered * listeners. * * @param orientation the orientation (<code>null</code> not permitted). */ public void setOrientation(PlotOrientation orientation) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } this.orientation = orientation; notifyListeners(new PlotChangeEvent(this)); } /** * Returns the axis offset. * * @return the axis offset. */ public Spacer getAxisOffset() { return this.axisOffset; } /** * Sets the axis offsets (gap between the data area and the axes). * * @param offset the offset. */ public void setAxisOffset(Spacer offset) { this.axisOffset = offset; notifyListeners(new PlotChangeEvent(this)); } /** * Returns the domain axis for the plot. If the domain axis for this plot * is <code>null</code>, then the method will return the parent plot's domain axis (if * there is a parent plot). * * @return The domain axis (<code>null</code> permitted). */ public CategoryAxis getDomainAxis() { return getDomainAxis(0); } /** * Returns a domain axis. * * @param index the axis index. * * @return The axis (<code>null</code> possible). */ public CategoryAxis getDomainAxis(int index) { CategoryAxis result = null; if (index < this.domainAxes.size()) { result = (CategoryAxis) this.domainAxes.get(index); } if (result == null) { Plot parent = getParent(); if (parent instanceof CategoryPlot) { CategoryPlot cp = (CategoryPlot) parent; result = cp.getDomainAxis(index); } } return result; } /** * Sets the domain axis for the plot and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param axis the axis (<code>null</code> permitted). */ public void setDomainAxis(CategoryAxis axis) { setDomainAxis(0, axis); } /** * Sets a domain axis. * * @param index the axis index. * @param axis the axis. */ public void setDomainAxis(int index, CategoryAxis axis) { CategoryAxis existing = (CategoryAxis) this.domainAxes.get(index); if (existing != null) { existing.removeChangeListener(this); } if (axis != null) { axis.setPlot(this); } this.domainAxes.set(index, axis); if (axis != null) { axis.configure(); axis.addChangeListener(this); } notifyListeners(new PlotChangeEvent(this)); } /** * Returns the domain axis location. * * @return The location (never <code>null</code>). */ public AxisLocation getDomainAxisLocation() { return getDomainAxisLocation(0); } /** * Returns the location for a domain axis. * * @param index the axis index. * * @return The location. */ public AxisLocation getDomainAxisLocation(int index) { AxisLocation result = null; if (index < this.domainAxisLocations.size()) { result = (AxisLocation) this.domainAxisLocations.get(index); } if (result == null) { result = AxisLocation.getOpposite(getDomainAxisLocation(0)); } return result; } /** * Sets the location of the domain axis and sends a {@link PlotChangeEvent} to all registered * listeners. * * @param location the axis location (<code>null</code> not permitted). */ public void setDomainAxisLocation(AxisLocation location) { // defer argument checking... setDomainAxisLocation(location, true); } /** * Sets the location of the domain axis. * * @param location the axis location (<code>null</code> not permitted). * @param notify a flag that controls whether listeners are notified. */ public void setDomainAxisLocation(AxisLocation location, boolean notify) { if (location == null) { throw new IllegalArgumentException("Null 'location' argument."); } setDomainAxisLocation(0, location); } /** * Sets the location for a domain axis and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param index the axis index. * @param location the location. */ public void setDomainAxisLocation(int index, AxisLocation location) { // TODO: handle argument checking for primary axis location which // should not be null this.domainAxisLocations.set(index, location); notifyListeners(new PlotChangeEvent(this)); } /** * Returns the domain axis edge. This is derived from the axis location and the plot * orientation. * * @return the edge (never <code>null</code>). */ public RectangleEdge getDomainAxisEdge() { return getDomainAxisEdge(0); } /** * Returns the edge for a domain axis. * * @param index the axis index. * * @return The edge (never <code>null</code>). */ public RectangleEdge getDomainAxisEdge(int index) { RectangleEdge result = null; AxisLocation location = getDomainAxisLocation(index); if (location != null) { result = Plot.resolveDomainAxisLocation(location, this.orientation); } else { result = RectangleEdge.opposite(getDomainAxisEdge(0)); } return result; } /** * Clears the domain axes from the plot and sends a {@link PlotChangeEvent} to all * registered listeners. */ public void clearDomainAxes() { for (int i = 0; i < this.domainAxes.size(); i++) { CategoryAxis axis = (CategoryAxis) this.domainAxes.get(i); if (axis != null) { axis.removeChangeListener(this); } } this.domainAxes.clear(); notifyListeners(new PlotChangeEvent(this)); } /** * Configures the domain axes. */ public void configureDomainAxes() { for (int i = 0; i < this.domainAxes.size(); i++) { CategoryAxis axis = (CategoryAxis) this.domainAxes.get(i); if (axis != null) { axis.configure(); } } } /** * Returns the range axis for the plot. If the range axis for this plot is * null, then the method will return the parent plot's range axis (if there * is a parent plot). * * @return The range axis (possibly <code>null</code>). */ public ValueAxis getRangeAxis() { return getRangeAxis(0); } /** * Returns a range axis. * * @param index the axis index. * * @return The axis (<code>null</code> possible). */ public ValueAxis getRangeAxis(int index) { ValueAxis result = null; if (index < this.rangeAxes.size()) { result = (ValueAxis) this.rangeAxes.get(index); } if (result == null) { Plot parent = getParent(); if (parent instanceof CategoryPlot) { CategoryPlot cp = (CategoryPlot) parent; result = cp.getRangeAxis(index); } } return result; } /** * Sets the range axis for the plot and sends a {@link PlotChangeEvent} to all registered * listeners. * * @param axis the axis (<code>null</code> permitted). */ public void setRangeAxis(ValueAxis axis) { setRangeAxis(0, axis); } /** * Sets a range axis. * * @param index the axis index. * @param axis the axis. */ public void setRangeAxis(int index, ValueAxis axis) { ValueAxis existing = (ValueAxis) this.rangeAxes.get(index); if (existing != null) { existing.removeChangeListener(this); } if (axis != null) { axis.setPlot(this); } this.rangeAxes.set(index, axis); if (axis != null) { axis.configure(); axis.addChangeListener(this); } notifyListeners(new PlotChangeEvent(this)); } /** * Returns the range axis location. * * @return the location (never <code>null</code>). */ public AxisLocation getRangeAxisLocation() { return getRangeAxisLocation(0); } /** * Returns the location for a range axis. * * @param index the axis index. * * @return The location. */ public AxisLocation getRangeAxisLocation(int index) { AxisLocation result = null; if (index < this.rangeAxisLocations.size()) { result = (AxisLocation) this.rangeAxisLocations.get(index); } if (result == null) { result = AxisLocation.getOpposite(getRangeAxisLocation(0)); } return result; } /** * Sets the location of the range axis and sends a {@link PlotChangeEvent} to all registered * listeners. * * @param location the location (<code>null</code> not permitted). */ public void setRangeAxisLocation(AxisLocation location) { // defer argument checking... setRangeAxisLocation(location, true); } /** * Sets the location of the range axis and, if requested, sends a {@link PlotChangeEvent} to * all registered listeners. * * @param location the location (<code>null</code> not permitted). * @param notify notify listeners? */ public void setRangeAxisLocation(AxisLocation location, boolean notify) { setRangeAxisLocation(0, location, notify); } /** * Sets the location for a range axis and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param index the axis index. * @param location the location. */ public void setRangeAxisLocation(int index, AxisLocation location) { setRangeAxisLocation(index, location, true); } /** * Sets the location for a range axis and sends a {@link PlotChangeEvent} to all * registered listeners. *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -