Compare commits
24 Commits
patch/TPS-
...
release/8.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99da8e2286 | ||
|
|
239ece2966 | ||
|
|
ce4740ce83 | ||
|
|
7c795f724c | ||
|
|
67784188df | ||
|
|
248a7d74dc | ||
|
|
c09c406c32 | ||
|
|
bd5b8b0f51 | ||
|
|
eb7c195d3e | ||
|
|
33162c8be4 | ||
|
|
7169a3101a | ||
|
|
192e47b6a3 | ||
|
|
28eda4c880 | ||
|
|
309c2ac056 | ||
|
|
64c530b6b4 | ||
|
|
71f93b5165 | ||
|
|
41b50e16c1 | ||
|
|
b7711e1dd5 | ||
|
|
8ed759c0d8 | ||
|
|
3ff40da876 | ||
|
|
da6a983f29 | ||
|
|
2913c80aef | ||
|
|
fa2abaf8f3 | ||
|
|
81e63ecab0 |
@@ -145,7 +145,30 @@ public class DB2ForZosDataBaseMetadata extends PackageFakeDatabaseMetadata {
|
||||
*/
|
||||
@Override
|
||||
public ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException {
|
||||
return new DB2ForZosResultSet();
|
||||
ResultSet rs = super.getPrimaryKeys(catalog, schema, table);
|
||||
if (rs == null) {
|
||||
rs = new DB2ForZosResultSet();
|
||||
}
|
||||
return rs;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.commons.utils.database.FakeDatabaseMetaData#getExportedKeys(java.lang.String, java.lang.String,
|
||||
* java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public ResultSet getExportedKeys(String catalog, String schema, String table) throws SQLException {
|
||||
ResultSet rs = super.getExportedKeys(catalog, schema, table);
|
||||
if (rs == null) {
|
||||
if (this.metaData != null) {
|
||||
rs = this.metaData.getExportedKeys(catalog, schema, table);
|
||||
} else {
|
||||
rs = new DB2ForZosResultSet();
|
||||
}
|
||||
}
|
||||
return rs;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -174,17 +197,6 @@ public class DB2ForZosDataBaseMetadata extends PackageFakeDatabaseMetadata {
|
||||
return tableResultSet;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.commons.utils.database.FakeDatabaseMetaData#getExportedKeys(java.lang.String, java.lang.String,
|
||||
* java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public ResultSet getExportedKeys(String catalog, String schema, String table) throws SQLException {
|
||||
return new DB2ForZosResultSet();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
||||
@@ -18,7 +18,6 @@ import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.preference.PreferenceConverter;
|
||||
import org.eclipse.jface.resource.StringConverter;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
@@ -94,8 +93,6 @@ public class ColorManager {
|
||||
public static final String BOLD_SUFFIX = "Bold"; //$NON-NLS-1$
|
||||
|
||||
private Map<String, Color> colorMap;
|
||||
|
||||
private static Map<String, Color> THEME_COLOR_MAP = new HashMap<String, Color>();
|
||||
|
||||
private IPreferenceStore store;
|
||||
|
||||
@@ -119,12 +116,9 @@ public class ColorManager {
|
||||
}
|
||||
|
||||
private static Color getThemeColor(String colorName) {
|
||||
if (!THEME_COLOR_MAP.containsKey(colorName)) {
|
||||
Color c = ITalendThemeService.getColor(colorName)
|
||||
.orElse(Display.getDefault().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
|
||||
THEME_COLOR_MAP.put(colorName, c);
|
||||
}
|
||||
return THEME_COLOR_MAP.get(colorName);
|
||||
Color c = ITalendThemeService.getColor(colorName)
|
||||
.orElse(Display.getDefault().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
|
||||
return c;
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
@@ -135,7 +129,6 @@ public class ColorManager {
|
||||
color.dispose();
|
||||
}
|
||||
colorMap = null;
|
||||
THEME_COLOR_MAP.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -252,6 +252,8 @@ public class ConnParameterKeys {
|
||||
|
||||
public static final String CONN_PARA_KEY_EXECUTOR_MEMORY = "CONN_PARA_KEY_EXECUTOR_MEMORY"; //$NON-NLS-1$
|
||||
|
||||
public static final String CONN_PARA_KEY_EXECUTOR_CORES = "CONN_PARA_KEY_EXECUTOR_CORES";
|
||||
|
||||
public static final String CONN_PARA_KEY_TUNING_PROPERTIES = "CONN_PARA_KEY_TUNING_PROPERTIES"; //$NON-NLS-1$
|
||||
|
||||
/******************************************/
|
||||
|
||||
@@ -81,7 +81,7 @@ public enum EDatabaseVersion4Drivers {
|
||||
new String[] { "mssql-jdbc.jar", "slf4j-api-1.7.34.jar", "slf4j-reload4j-1.7.34.jar", "msal4j-1.11.0.jar", //$NON-NLS-1$
|
||||
"oauth2-oidc-sdk-9.7.jar", "reload4j-1.2.22.jar", "jackson-core-2.13.4.jar",
|
||||
"jackson-databind-2.13.4.2.jar", "jackson-annotations-2.13.4.jar", "jcip-annotations-1.0-1.jar",
|
||||
"json-smart-2.4.7.jar", "nimbus-jose-jwt-9.22.jar", "accessors-smart-2.4.7.jar", "asm-9.1.jar",
|
||||
"json-smart-2.4.9.jar", "nimbus-jose-jwt-9.22.jar", "accessors-smart-2.4.9.jar", "asm-9.5.jar",
|
||||
"content-type-2.1.jar", "lang-tag-1.5.jar" })),
|
||||
|
||||
VERTICA_9(new DbVersion4Drivers(EDatabaseTypeName.VERTICA, "VERTICA 9.X", "VERTICA_9_0", "vertica-jdbc-9.3.1-0.jar")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
|
||||
@@ -142,6 +142,8 @@ public enum EHadoopProperties {
|
||||
|
||||
SPARK_EXECUTOR_MEMORY,
|
||||
|
||||
SPARK_EXECUTOR_CORES,
|
||||
|
||||
DATABRICKS_ENDPOINT,
|
||||
|
||||
DATABRICKS_CLOUD_PROVIDER,
|
||||
|
||||
@@ -134,7 +134,7 @@ public final class TokenInforUtil {
|
||||
targetArray = new JSONArray();
|
||||
Map<String,List<JSONObject>> objectMap = new HashMap<String,List<JSONObject>>();
|
||||
for (Object obj : data) {
|
||||
if((obj instanceof JSONObject) && ((JSONObject)obj).get("component_name")!=null){//$NON-NLS-1$
|
||||
if((obj instanceof JSONObject) && ((JSONObject)obj).has("component_name") && ((JSONObject)obj).get("component_name")!=null){//$NON-NLS-1$
|
||||
List<JSONObject> dataList = new ArrayList<JSONObject>();
|
||||
String componentName = (String) ((JSONObject)obj).get("component_name");//$NON-NLS-1$
|
||||
if(objectMap.containsKey(componentName)){
|
||||
|
||||
@@ -1076,6 +1076,21 @@ public class ProcessorUtilities {
|
||||
}
|
||||
progressMonitor.subTask(Messages.getString("ProcessorUtilities.loadingJob") + currentJobName); //$NON-NLS-1$
|
||||
|
||||
//APPINT-35554 correct build type for child job of Route
|
||||
JobInfo parentJobInfo = jobInfo.getFatherJobInfo();
|
||||
if (selectedProcessItem != null && parentJobInfo != null
|
||||
&& parentJobInfo.getProcessor() != null && parentJobInfo.getProcessor().getProperty() != null ) {
|
||||
Property childProperty = selectedProcessItem.getProperty();
|
||||
String childBuildType = (String)childProperty.getAdditionalProperties().get(TalendProcessArgumentConstant.ARG_BUILD_TYPE);
|
||||
if (childBuildType == null) {
|
||||
Property parentProperty = parentJobInfo.getProcessor().getProperty();
|
||||
String parentBuildType = (String)parentProperty.getAdditionalProperties().get(TalendProcessArgumentConstant.ARG_BUILD_TYPE);
|
||||
if ("ROUTE".equalsIgnoreCase(parentBuildType)) {
|
||||
childProperty.getAdditionalProperties().put(TalendProcessArgumentConstant.ARG_BUILD_TYPE, "OSGI");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (jobInfo.getProcess() == null) {
|
||||
if (selectedProcessItem != null) {
|
||||
IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
|
||||
|
||||
@@ -22,7 +22,7 @@ _UI_Dependency_type=\u4F9D\u5B58\u9805\u76EE
|
||||
_UI_Expression_type=\u5F0F
|
||||
_UI_BooleanExpression_type=\u30D6\u30FC\u30EB\u5024\u306E\u5F0F
|
||||
_UI_ProcedureExpression_type=\u30D7\u30ED\u30B7\u30FC\u30B8\u30E3\u30FC\u30A8\u30AF\u30B9\u30D7\u30EC\u30C3\u30B7\u30E7\u30F3
|
||||
_UI_Multiplicity_type=\u591A\u69D8\u6027
|
||||
_UI_Multiplicity_type=\u591A\u91CD\u5EA6
|
||||
_UI_MultiplicityRange_type=\u591A\u69D8\u6027\u30EC\u30F3\u30B8
|
||||
_UI_Stereotype_type=\u30B9\u30C6\u30EC\u30AA\u30BF\u30A4\u30D7
|
||||
_UI_TaggedValue_type=\u30BF\u30B0\u4ED8\u3051\u3055\u308C\u305F\u5024
|
||||
@@ -367,7 +367,7 @@ _UI_Feature_featureNode_feature=\u6A5F\u80FD\u30CE\u30FC\u30C9
|
||||
_UI_Feature_featureMap_feature=\u6A5F\u80FD\u30DE\u30C3\u30D7
|
||||
_UI_Feature_cfMap_feature=Cf\u30DE\u30C3\u30D7
|
||||
_UI_StructuralFeature_changeability_feature=\u53EF\u5909\u6027
|
||||
_UI_StructuralFeature_multiplicity_feature=\u591A\u69D8\u6027
|
||||
_UI_StructuralFeature_multiplicity_feature=\u591A\u91CD\u5EA6
|
||||
_UI_StructuralFeature_ordering_feature=\u9806\u5E8F\u4ED8\u3051
|
||||
_UI_StructuralFeature_targetScope_feature=\u30BF\u30FC\u30B2\u30C3\u30C8\u30B9\u30B3\u30FC\u30D7
|
||||
_UI_StructuralFeature_type_feature=\u30BF\u30A4\u30D7
|
||||
@@ -390,7 +390,7 @@ _UI_Expression_language_feature=\u8A00\u8A9E
|
||||
_UI_Multiplicity_range_feature=\u7BC4\u56F2
|
||||
_UI_MultiplicityRange_lower_feature=\u4E0B\u65B9
|
||||
_UI_MultiplicityRange_upper_feature=\u4E0A\u65B9
|
||||
_UI_MultiplicityRange_multiplicity_feature=\u591A\u69D8\u6027
|
||||
_UI_MultiplicityRange_multiplicity_feature=\u591A\u91CD\u5EA6
|
||||
_UI_Stereotype_baseClass_feature=\u30D9\u30FC\u30B9\u30AF\u30E9\u30B9
|
||||
_UI_Stereotype_stereotypeConstraint_feature=\u30B9\u30C6\u30EC\u30AA\u30BF\u30A4\u30D7\u5236\u7D04
|
||||
_UI_Stereotype_extendedElement_feature=\u62E1\u5F35\u3055\u308C\u305F\u30A8\u30EC\u30E1\u30F3\u30C8
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<talend_releases>https://artifacts-oss.talend.com/nexus/content/repositories/TalendOpenSourceRelease/</talend_releases>
|
||||
<talend_snapshots_ee>https://artifacts-zl.talend.com/nexus/content/repositories/snapshots/</talend_snapshots_ee>
|
||||
<talend_releases_ee>https://artifacts-zl.talend.com/nexus/content/repositories/releases/</talend_releases_ee>
|
||||
<tycho.buildtimestamp.format>${timestamp}</tycho.buildtimestamp.format>
|
||||
<tycho.buildtimestamp.format>${timestamp}</tycho.buildtimestamp.format>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
@@ -72,15 +72,15 @@
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20140107</version>
|
||||
<version>20230227</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-cbor</artifactId>
|
||||
<version>${m2.fasterxml.jackson.version}</version>
|
||||
</dependency>
|
||||
<!-- It fixes provided dependency scope to compile, because maven-dependency-plugin is setup to include
|
||||
only compile and runtime scopes, but provided is also required. It's not possible to setup plugin to
|
||||
<!-- It fixes provided dependency scope to compile, because maven-dependency-plugin is setup to include
|
||||
only compile and runtime scopes, but provided is also required. It's not possible to setup plugin to
|
||||
include all: compile, runtime and provided dependencies -->
|
||||
<dependency>
|
||||
<groupId>biz.aQute.bnd</groupId>
|
||||
@@ -99,7 +99,7 @@
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<!-- Dependencies in provided scope should be explicitly added as dependency in this module,
|
||||
<!-- Dependencies in provided scope should be explicitly added as dependency in this module,
|
||||
because provided scope is not transitive -->
|
||||
<dependency>
|
||||
<groupId>org.osgi</groupId>
|
||||
|
||||
@@ -52,8 +52,17 @@
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity-engine-core</artifactId>
|
||||
<version>2.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
|
||||
@@ -59,8 +59,17 @@
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-compress</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity-engine-core</artifactId>
|
||||
<version>2.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-utils</artifactId>
|
||||
@@ -99,7 +108,7 @@
|
||||
<dependency>
|
||||
<groupId>com.thoughtworks.xstream</groupId>
|
||||
<artifactId>xstream</artifactId>
|
||||
<version>1.4.16</version>
|
||||
<version>1.4.20</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20140107</version>
|
||||
<version>20230227</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.2.6</version>
|
||||
<version>4.5.13</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.tycho</groupId>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<properties>
|
||||
<tcomp.version>1.55.2</tcomp.version>
|
||||
<tcomp.version>1.56.1</tcomp.version>
|
||||
<slf4j.version>1.7.34</slf4j.version>
|
||||
<reload4j.version>1.2.22</reload4j.version>
|
||||
</properties>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,223 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* ------------------------------
|
||||
* CombinedCategoryPlotDemo1.java
|
||||
* ------------------------------
|
||||
* (C) Copyright 2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): ;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 05-May-2008 : Version 1 (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.experimental.chart.demo;
|
||||
|
||||
import java.awt.Font;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.jfree.chart.ChartPanel;
|
||||
import org.jfree.chart.JFreeChart;
|
||||
import org.jfree.chart.axis.CategoryAxis;
|
||||
import org.jfree.chart.axis.NumberAxis;
|
||||
import org.jfree.chart.labels.StandardCategoryToolTipGenerator;
|
||||
import org.jfree.chart.plot.CategoryPlot;
|
||||
import org.jfree.chart.renderer.category.BarRenderer;
|
||||
import org.jfree.chart.renderer.category.LineAndShapeRenderer;
|
||||
import org.jfree.data.category.CategoryDataset;
|
||||
import org.jfree.data.category.DefaultCategoryDataset;
|
||||
import org.jfree.experimental.chart.plot.CombinedCategoryPlot;
|
||||
import org.jfree.ui.ApplicationFrame;
|
||||
import org.jfree.ui.RefineryUtilities;
|
||||
|
||||
/**
|
||||
* A demo for the {@link CombinedCategoryPlot} class.
|
||||
*/
|
||||
public class CombinedCategoryPlotDemo1 extends ApplicationFrame {
|
||||
|
||||
/**
|
||||
* Creates a new demo instance.
|
||||
*
|
||||
* @param title the frame title.
|
||||
*/
|
||||
public CombinedCategoryPlotDemo1(String title) {
|
||||
super(title);
|
||||
JPanel chartPanel = createDemoPanel();
|
||||
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
|
||||
setContentPane(chartPanel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a dataset.
|
||||
*
|
||||
* @return A dataset.
|
||||
*/
|
||||
public static CategoryDataset createDataset1() {
|
||||
DefaultCategoryDataset result = new DefaultCategoryDataset();
|
||||
String series1 = "First";
|
||||
String series2 = "Second";
|
||||
String type1 = "Type 1";
|
||||
String type2 = "Type 2";
|
||||
String type3 = "Type 3";
|
||||
String type4 = "Type 4";
|
||||
String type5 = "Type 5";
|
||||
String type6 = "Type 6";
|
||||
String type7 = "Type 7";
|
||||
String type8 = "Type 8";
|
||||
|
||||
result.addValue(1.0, series1, type1);
|
||||
result.addValue(4.0, series1, type2);
|
||||
result.addValue(3.0, series1, type3);
|
||||
result.addValue(5.0, series1, type4);
|
||||
result.addValue(5.0, series1, type5);
|
||||
result.addValue(7.0, series1, type6);
|
||||
result.addValue(7.0, series1, type7);
|
||||
result.addValue(8.0, series1, type8);
|
||||
|
||||
result.addValue(5.0, series2, type1);
|
||||
result.addValue(7.0, series2, type2);
|
||||
result.addValue(6.0, series2, type3);
|
||||
result.addValue(8.0, series2, type4);
|
||||
result.addValue(4.0, series2, type5);
|
||||
result.addValue(4.0, series2, type6);
|
||||
result.addValue(2.0, series2, type7);
|
||||
result.addValue(1.0, series2, type8);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a dataset.
|
||||
*
|
||||
* @return A dataset.
|
||||
*/
|
||||
public static CategoryDataset createDataset2() {
|
||||
|
||||
DefaultCategoryDataset result = new DefaultCategoryDataset();
|
||||
|
||||
String series1 = "Third";
|
||||
String series2 = "Fourth";
|
||||
|
||||
String type1 = "Type 1";
|
||||
String type2 = "Type 2";
|
||||
String type3 = "Type 3";
|
||||
String type4 = "Type 4";
|
||||
String type5 = "Type 5";
|
||||
String type6 = "Type 6";
|
||||
String type7 = "Type 7";
|
||||
String type8 = "Type 8";
|
||||
|
||||
result.addValue(11.0, series1, type1);
|
||||
result.addValue(14.0, series1, type2);
|
||||
result.addValue(13.0, series1, type3);
|
||||
result.addValue(15.0, series1, type4);
|
||||
result.addValue(15.0, series1, type5);
|
||||
result.addValue(17.0, series1, type6);
|
||||
result.addValue(17.0, series1, type7);
|
||||
result.addValue(18.0, series1, type8);
|
||||
|
||||
result.addValue(15.0, series2, type1);
|
||||
result.addValue(17.0, series2, type2);
|
||||
result.addValue(16.0, series2, type3);
|
||||
result.addValue(18.0, series2, type4);
|
||||
result.addValue(14.0, series2, type5);
|
||||
result.addValue(14.0, series2, type6);
|
||||
result.addValue(12.0, series2, type7);
|
||||
result.addValue(11.0, series2, type8);
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a chart.
|
||||
*
|
||||
* @return A chart.
|
||||
*/
|
||||
private static JFreeChart createChart() {
|
||||
|
||||
CategoryDataset dataset1 = createDataset1();
|
||||
NumberAxis rangeAxis1 = new NumberAxis("Value");
|
||||
rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
|
||||
LineAndShapeRenderer renderer1 = new LineAndShapeRenderer();
|
||||
renderer1.setBaseToolTipGenerator(
|
||||
new StandardCategoryToolTipGenerator());
|
||||
CategoryPlot subplot1 = new CategoryPlot(dataset1, null, rangeAxis1,
|
||||
renderer1);
|
||||
subplot1.setDomainGridlinesVisible(true);
|
||||
|
||||
CategoryDataset dataset2 = createDataset2();
|
||||
NumberAxis rangeAxis2 = new NumberAxis("Value");
|
||||
rangeAxis2.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
|
||||
BarRenderer renderer2 = new BarRenderer();
|
||||
renderer2.setBaseToolTipGenerator(
|
||||
new StandardCategoryToolTipGenerator());
|
||||
CategoryPlot subplot2 = new CategoryPlot(dataset2, null, rangeAxis2,
|
||||
renderer2);
|
||||
subplot2.setDomainGridlinesVisible(true);
|
||||
|
||||
CategoryAxis domainAxis = new CategoryAxis("Category");
|
||||
CombinedCategoryPlot plot = new CombinedCategoryPlot(
|
||||
domainAxis, new NumberAxis("Range"));
|
||||
plot.add(subplot1, 2);
|
||||
plot.add(subplot2, 1);
|
||||
|
||||
JFreeChart result = new JFreeChart(
|
||||
"Combined Domain Category Plot Demo",
|
||||
new Font("SansSerif", Font.BOLD, 12), plot, true);
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a panel for the demo (used by SuperDemo.java).
|
||||
*
|
||||
* @return A panel.
|
||||
*/
|
||||
public static JPanel createDemoPanel() {
|
||||
JFreeChart chart = createChart();
|
||||
return new ChartPanel(chart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starting point for the demonstration application.
|
||||
*
|
||||
* @param args ignored.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
String title = "Combined Category Plot Demo 1";
|
||||
CombinedCategoryPlotDemo1 demo = new CombinedCategoryPlotDemo1(title);
|
||||
demo.pack();
|
||||
RefineryUtilities.centerFrameOnScreen(demo);
|
||||
demo.setVisible(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,262 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* ------------------------
|
||||
* CombinedXYPlotDemo1.java
|
||||
* ------------------------
|
||||
* (C) Copyright 2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): ;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 05-May-2008 : Version 1 (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.experimental.chart.demo;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Paint;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.jfree.chart.ChartPanel;
|
||||
import org.jfree.chart.JFreeChart;
|
||||
import org.jfree.chart.axis.DateAxis;
|
||||
import org.jfree.chart.axis.NumberAxis;
|
||||
import org.jfree.chart.axis.ValueAxis;
|
||||
import org.jfree.chart.labels.StandardXYToolTipGenerator;
|
||||
import org.jfree.chart.plot.XYPlot;
|
||||
import org.jfree.chart.renderer.xy.XYBarRenderer;
|
||||
import org.jfree.chart.renderer.xy.XYItemRenderer;
|
||||
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
|
||||
import org.jfree.chart.title.LegendTitle;
|
||||
import org.jfree.data.time.Month;
|
||||
import org.jfree.data.time.TimeSeries;
|
||||
import org.jfree.data.time.TimeSeriesCollection;
|
||||
import org.jfree.data.xy.IntervalXYDataset;
|
||||
import org.jfree.data.xy.XYDataset;
|
||||
import org.jfree.experimental.chart.plot.CombinedXYPlot;
|
||||
import org.jfree.ui.ApplicationFrame;
|
||||
import org.jfree.ui.RefineryUtilities;
|
||||
|
||||
/**
|
||||
* A demonstration application showing a {@link CombinedXYPlot} with
|
||||
* two subplots.
|
||||
*/
|
||||
public class CombinedXYPlotDemo1 extends ApplicationFrame {
|
||||
|
||||
/**
|
||||
* Constructs a new demonstration application.
|
||||
*
|
||||
* @param title the frame title.
|
||||
*/
|
||||
public CombinedXYPlotDemo1(String title) {
|
||||
super(title);
|
||||
JPanel panel = createDemoPanel();
|
||||
panel.setPreferredSize(new java.awt.Dimension(500, 270));
|
||||
setContentPane(panel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an overlaid chart.
|
||||
*
|
||||
* @return The chart.
|
||||
*/
|
||||
private static JFreeChart createCombinedChart() {
|
||||
|
||||
// create plot ...
|
||||
IntervalXYDataset data1 = createDataset1();
|
||||
XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false);
|
||||
renderer1.setBaseToolTipGenerator(new StandardXYToolTipGenerator(
|
||||
StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
|
||||
new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")));
|
||||
renderer1.setSeriesStroke(0, new BasicStroke(4.0f,
|
||||
BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
|
||||
renderer1.setSeriesPaint(0, Color.blue);
|
||||
|
||||
DateAxis domainAxis = new DateAxis("Year");
|
||||
domainAxis.setLowerMargin(0.0);
|
||||
domainAxis.setUpperMargin(0.02);
|
||||
ValueAxis rangeAxis = new NumberAxis("$billion");
|
||||
XYPlot plot1 = new XYPlot(data1, null, rangeAxis, renderer1);
|
||||
plot1.setBackgroundPaint(Color.lightGray);
|
||||
plot1.setDomainGridlinePaint(Color.white);
|
||||
plot1.setRangeGridlinePaint(Color.white);
|
||||
|
||||
// add a second dataset and renderer...
|
||||
IntervalXYDataset data2 = createDataset2();
|
||||
XYBarRenderer renderer2 = new XYBarRenderer() {
|
||||
public Paint getItemPaint(int series, int item) {
|
||||
XYDataset dataset = getPlot().getDataset();
|
||||
if (dataset.getYValue(series, item) >= 0.0) {
|
||||
return Color.red;
|
||||
}
|
||||
else {
|
||||
return Color.green;
|
||||
}
|
||||
}
|
||||
};
|
||||
renderer2.setSeriesPaint(0, Color.red);
|
||||
renderer2.setDrawBarOutline(false);
|
||||
renderer2.setBaseToolTipGenerator(new StandardXYToolTipGenerator(
|
||||
StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
|
||||
new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")));
|
||||
|
||||
XYPlot plot2 = new XYPlot(data2, null, new NumberAxis("$billion"),
|
||||
renderer2);
|
||||
plot2.setBackgroundPaint(Color.lightGray);
|
||||
plot2.setDomainGridlinePaint(Color.white);
|
||||
plot2.setRangeGridlinePaint(Color.white);
|
||||
|
||||
CombinedXYPlot cplot = new CombinedXYPlot(domainAxis, rangeAxis);
|
||||
cplot.add(plot1, 3);
|
||||
cplot.add(plot2, 2);
|
||||
cplot.setGap(8.0);
|
||||
cplot.setDomainGridlinePaint(Color.white);
|
||||
cplot.setDomainGridlinesVisible(true);
|
||||
|
||||
// return a new chart containing the overlaid plot...
|
||||
JFreeChart chart = new JFreeChart("CombinedXYPlotDemo1",
|
||||
JFreeChart.DEFAULT_TITLE_FONT, cplot, false);
|
||||
chart.setBackgroundPaint(Color.white);
|
||||
LegendTitle legend = new LegendTitle(cplot);
|
||||
chart.addSubtitle(legend);
|
||||
return chart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a sample dataset. You wouldn't normally hard-code the
|
||||
* population of a dataset in this way (it would be better to read the
|
||||
* values from a file or a database query), but for a self-contained demo
|
||||
* this is the least complicated solution.
|
||||
*
|
||||
* @return The dataset.
|
||||
*/
|
||||
private static IntervalXYDataset createDataset1() {
|
||||
|
||||
// create dataset 1...
|
||||
TimeSeries series1 = new TimeSeries("Series 1", Month.class);
|
||||
series1.add(new Month(1, 2005), 7627.743);
|
||||
series1.add(new Month(2, 2005), 7713.138);
|
||||
series1.add(new Month(3, 2005), 6776.939);
|
||||
series1.add(new Month(4, 2005), 5764.537);
|
||||
series1.add(new Month(5, 2005), 4777.880);
|
||||
series1.add(new Month(6, 2005), 4836.496);
|
||||
series1.add(new Month(7, 2005), 3887.618);
|
||||
series1.add(new Month(8, 2005), 3926.933);
|
||||
series1.add(new Month(9, 2005), 4932.710);
|
||||
series1.add(new Month(10, 2005), 4027.123);
|
||||
series1.add(new Month(11, 2005), 8092.322);
|
||||
series1.add(new Month(12, 2005), 8170.414);
|
||||
series1.add(new Month(1, 2006), 8196.070);
|
||||
series1.add(new Month(2, 2006), 8269.886);
|
||||
series1.add(new Month(3, 2006), 5371.156);
|
||||
series1.add(new Month(4, 2006), 5355.718);
|
||||
series1.add(new Month(5, 2006), 5356.777);
|
||||
series1.add(new Month(6, 2006), 8420.042);
|
||||
series1.add(new Month(7, 2006), 8444.347);
|
||||
series1.add(new Month(8, 2006), 8515.034);
|
||||
series1.add(new Month(9, 2006), 8506.974);
|
||||
series1.add(new Month(10, 2006), 8584.329);
|
||||
series1.add(new Month(11, 2006), 8633.246);
|
||||
series1.add(new Month(12, 2006), 8680.224);
|
||||
series1.add(new Month(1, 2007), 8707.561);
|
||||
return new TimeSeriesCollection(series1);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a sample dataset. You wouldn't normally hard-code the
|
||||
* population of a dataset in this way (it would be better to read the
|
||||
* values from a file or a database query), but for a self-contained demo
|
||||
* this is the least complicated solution.
|
||||
*
|
||||
* @return A sample dataset.
|
||||
*/
|
||||
private static IntervalXYDataset createDataset2() {
|
||||
TimeSeriesCollection dataset = new TimeSeriesCollection();
|
||||
|
||||
TimeSeries series1 = new TimeSeries("Series 2", Month.class);
|
||||
series1.add(new Month(1, 2005), 1200);
|
||||
series1.add(new Month(2, 2005), 1400);
|
||||
series1.add(new Month(3, 2005), 1500);
|
||||
series1.add(new Month(4, 2005), 1700);
|
||||
series1.add(new Month(5, 2005), 1600);
|
||||
series1.add(new Month(6, 2005), 2400);
|
||||
series1.add(new Month(7, 2005), 2100);
|
||||
series1.add(new Month(8, 2005), 2200);
|
||||
series1.add(new Month(9, 2005), 800);
|
||||
series1.add(new Month(10, 2005), 2350);
|
||||
series1.add(new Month(11, 2005), 500);
|
||||
series1.add(new Month(12, 2005), 700);
|
||||
series1.add(new Month(1, 2006), 900);
|
||||
series1.add(new Month(2, 2006), 1500);
|
||||
series1.add(new Month(3, 2006), 2100);
|
||||
series1.add(new Month(4, 2006), 2200);
|
||||
series1.add(new Month(5, 2006), 1900);
|
||||
series1.add(new Month(6, 2006), 3000);
|
||||
series1.add(new Month(7, 2006), 3780);
|
||||
series1.add(new Month(8, 2006), 4000);
|
||||
series1.add(new Month(9, 2006), 4500);
|
||||
series1.add(new Month(10, 2006), 7000);
|
||||
series1.add(new Month(11, 2006), 5500);
|
||||
series1.add(new Month(12, 2006), 6000);
|
||||
series1.add(new Month(1, 2007), 6500);
|
||||
dataset.addSeries(series1);
|
||||
return dataset;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a panel for the demo (used by SuperDemo.java).
|
||||
*
|
||||
* @return A panel.
|
||||
*/
|
||||
public static JPanel createDemoPanel() {
|
||||
JFreeChart chart = createCombinedChart();
|
||||
return new ChartPanel(chart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starting point for the demonstration application.
|
||||
*
|
||||
* @param args ignored.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
CombinedXYPlotDemo1 demo = new CombinedXYPlotDemo1(
|
||||
"JFreeChart : CombinedXYPlotDemo1");
|
||||
demo.pack();
|
||||
RefineryUtilities.centerFrameOnScreen(demo);
|
||||
demo.setVisible(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,139 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -------------------------
|
||||
* CombinedCategoryPlot.java
|
||||
* -------------------------
|
||||
* (C) Copyright 2008, by Richard West and Contributors.
|
||||
*
|
||||
* Original Author: Richard West, Advanced Micro Devices, Inc.;
|
||||
* Contributor(s): David Gilbert (for Object Refinery Limited);
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 02-Feb-2007 : Version 1, contributed by Richard West - see
|
||||
* patch 1924543 (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.experimental.chart.plot;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.jfree.chart.axis.CategoryAxis;
|
||||
import org.jfree.chart.axis.ValueAxis;
|
||||
import org.jfree.chart.plot.CategoryPlot;
|
||||
import org.jfree.chart.plot.CombinedDomainCategoryPlot;
|
||||
import org.jfree.data.Range;
|
||||
|
||||
/**
|
||||
* A specialised form of {@link CombinedDomainCategoryPlot} where the
|
||||
* subplots share not only the same x-axis, but also the same y-axis.
|
||||
*/
|
||||
public class CombinedCategoryPlot extends CombinedDomainCategoryPlot {
|
||||
|
||||
/**
|
||||
* Creates a new instance with the specified axes.
|
||||
*
|
||||
* @param domainAxis the x-axis.
|
||||
* @param rangeAxis the y-axis.
|
||||
*/
|
||||
public CombinedCategoryPlot (CategoryAxis domainAxis, ValueAxis rangeAxis) {
|
||||
super(domainAxis);
|
||||
super.setGap(10.0);
|
||||
super.setRangeAxis(rangeAxis);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new subplot with weight <code>1</code>.
|
||||
*
|
||||
* @param subplot the subplot.
|
||||
*/
|
||||
public void add(CategoryPlot subplot) {
|
||||
this.add(subplot, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new subplot with the specified weight.
|
||||
*
|
||||
* @param subplot the subplot.
|
||||
* @param weight the weight for the subplot.
|
||||
*/
|
||||
public void add(CategoryPlot subplot, int weight) {
|
||||
super.add(subplot, weight);
|
||||
|
||||
ValueAxis l_range = super.getRangeAxis();
|
||||
subplot.setRangeAxis(0, l_range, false);
|
||||
|
||||
super.setRangeAxis(l_range);
|
||||
if (null == l_range) {
|
||||
return;
|
||||
}
|
||||
|
||||
l_range.configure();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bounds of the data values that will be plotted against
|
||||
* the specified axis.
|
||||
*
|
||||
* @param axis the axis.
|
||||
*
|
||||
* @return The bounds.
|
||||
*/
|
||||
public Range getDataRange(ValueAxis axis) {
|
||||
Range l_result = null;
|
||||
Iterator l_itr = getSubplots().iterator();
|
||||
while (l_itr.hasNext()) {
|
||||
CategoryPlot l_subplot = (CategoryPlot) l_itr.next();
|
||||
|
||||
l_result = Range.combine(l_result, l_subplot.getDataRange(axis));
|
||||
}
|
||||
return l_result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the range axis that is shared by all the subplots.
|
||||
*
|
||||
* @param axis the axis.
|
||||
*/
|
||||
public void setRangeAxis(ValueAxis axis) {
|
||||
Iterator l_itr = getSubplots().iterator();
|
||||
while (l_itr.hasNext()) {
|
||||
CategoryPlot l_subplot = (CategoryPlot) l_itr.next();
|
||||
l_subplot.setRangeAxis(0, axis, false);
|
||||
}
|
||||
|
||||
super.setRangeAxis(axis);
|
||||
if (null == axis) {
|
||||
return;
|
||||
}
|
||||
|
||||
axis.configure();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,139 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -------------------
|
||||
* CombinedXYPlot.java
|
||||
* -------------------
|
||||
* (C) Copyright 2008, by Richard West and Contributors.
|
||||
*
|
||||
* Original Author: Richard West, Advanced Micro Devices, Inc.;
|
||||
* Contributor(s): David Gilbert (for Object Refinery Limited);
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 05-May-2008 : Version 1, contributed by Richard West - see
|
||||
* patch 1924543 (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.experimental.chart.plot;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.jfree.chart.axis.ValueAxis;
|
||||
import org.jfree.chart.plot.CombinedDomainCategoryPlot;
|
||||
import org.jfree.chart.plot.CombinedDomainXYPlot;
|
||||
import org.jfree.chart.plot.XYPlot;
|
||||
import org.jfree.data.Range;
|
||||
|
||||
/**
|
||||
* A specialised form of {@link CombinedDomainCategoryPlot} where the
|
||||
* subplots share not only the same x-axis, but also the same y-axis.
|
||||
*/
|
||||
public class CombinedXYPlot extends CombinedDomainXYPlot {
|
||||
|
||||
/**
|
||||
* Creates a new instance with the specified axes.
|
||||
*
|
||||
* @param domainAxis the x-axis.
|
||||
* @param rangeAxis the y-axis.
|
||||
*/
|
||||
public CombinedXYPlot(ValueAxis domainAxis, ValueAxis rangeAxis) {
|
||||
super(domainAxis);
|
||||
super.setGap(10.0);
|
||||
super.setRangeAxis(rangeAxis);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new subplot with weight <code>1</code>.
|
||||
*
|
||||
* @param subplot the subplot.
|
||||
*/
|
||||
public void add(XYPlot subplot) {
|
||||
this.add(subplot, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new subplot with the specified weight.
|
||||
*
|
||||
* @param subplot the subplot.
|
||||
* @param weight the weight for the subplot.
|
||||
*/
|
||||
public void add(XYPlot subplot, int weight) {
|
||||
super.add(subplot, weight);
|
||||
|
||||
ValueAxis l_range = super.getRangeAxis();
|
||||
subplot.setRangeAxis(0, l_range, false);
|
||||
|
||||
super.setRangeAxis(l_range);
|
||||
if (null == l_range) {
|
||||
return;
|
||||
}
|
||||
|
||||
l_range.configure();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bounds of the data values that will be plotted against
|
||||
* the specified axis.
|
||||
*
|
||||
* @param axis the axis.
|
||||
*
|
||||
* @return The bounds.
|
||||
*/
|
||||
public Range getDataRange(ValueAxis axis) {
|
||||
Range l_result = null;
|
||||
Iterator l_itr = getSubplots().iterator();
|
||||
while (l_itr.hasNext()) {
|
||||
XYPlot l_subplot = (XYPlot) l_itr.next();
|
||||
|
||||
l_result = Range.combine(l_result, l_subplot.getDataRange(axis));
|
||||
}
|
||||
return l_result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the range axis that is shared by all the subplots.
|
||||
*
|
||||
* @param axis the axis.
|
||||
*/
|
||||
public void setRangeAxis(ValueAxis axis) {
|
||||
Iterator l_itr = getSubplots().iterator();
|
||||
while (l_itr.hasNext()) {
|
||||
XYPlot l_subplot = (XYPlot) l_itr.next();
|
||||
l_subplot.setRangeAxis(0, axis, false);
|
||||
}
|
||||
|
||||
super.setRangeAxis(axis);
|
||||
if (null == axis) {
|
||||
return;
|
||||
}
|
||||
|
||||
axis.configure();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,298 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2007, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* ---------------------------------
|
||||
* XYSmoothLineAndShapeRenderer.java
|
||||
* ---------------------------------
|
||||
* (C) Copyright 2007, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: -;
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 14-Jun-2007 : Version 1;
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.experimental.chart.renderer.xy;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import org.jfree.chart.axis.ValueAxis;
|
||||
import org.jfree.chart.entity.EntityCollection;
|
||||
import org.jfree.chart.plot.CrosshairState;
|
||||
import org.jfree.chart.plot.PlotOrientation;
|
||||
import org.jfree.chart.plot.XYPlot;
|
||||
import org.jfree.chart.renderer.xy.XYItemRendererState;
|
||||
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
|
||||
import org.jfree.data.xy.XYDataset;
|
||||
import org.jfree.ui.RectangleEdge;
|
||||
|
||||
/**
|
||||
* A line and shape renderer that performs line smoothing. See
|
||||
* http://www.jfree.org/phpBB2/viewtopic.php?t=20671
|
||||
*
|
||||
* WARNING: THIS CLASS IS NOT PART OF THE STANDARD JFREECHART API AND IS
|
||||
* SUBJECT TO ALTERATION OR REMOVAL. DO NOT RELY ON THIS CLASS FOR
|
||||
* PRODUCTION USE. Please experiment with this code and provide feedback.
|
||||
*/
|
||||
public class XYSmoothLineAndShapeRenderer extends XYLineAndShapeRenderer {
|
||||
|
||||
/**
|
||||
* Draws the item (first pass). This method draws the lines
|
||||
* connecting the items.
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
* @param state the renderer state.
|
||||
* @param dataArea the area within which the data is being drawn.
|
||||
* @param plot the plot (can be used to obtain standard color
|
||||
* information etc).
|
||||
* @param domainAxis the domain axis.
|
||||
* @param rangeAxis the range axis.
|
||||
* @param dataset the dataset.
|
||||
* @param pass the pass.
|
||||
* @param series the series index (zero-based).
|
||||
* @param item the item index (zero-based).
|
||||
*/
|
||||
protected void drawPrimaryLine(XYItemRendererState state, Graphics2D g2,
|
||||
XYPlot plot, XYDataset dataset, int pass, int series, int item,
|
||||
ValueAxis domainAxis, ValueAxis rangeAxis, Rectangle2D dataArea) {
|
||||
|
||||
if (item == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// get the data point...
|
||||
double x1 = dataset.getXValue(series, item);
|
||||
double y1 = dataset.getYValue(series, item);
|
||||
if (Double.isNaN(y1) || Double.isNaN(x1)) {
|
||||
return;
|
||||
}
|
||||
|
||||
double x0 = dataset.getXValue(series, item - 1);
|
||||
double y0 = dataset.getYValue(series, item - 1);
|
||||
if (Double.isNaN(y0) || Double.isNaN(x0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
|
||||
RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
|
||||
|
||||
double transX0 = domainAxis.valueToJava2D(x0, dataArea, xAxisLocation);
|
||||
double transY0 = rangeAxis.valueToJava2D(y0, dataArea, yAxisLocation);
|
||||
|
||||
double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation);
|
||||
double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation);
|
||||
|
||||
// only draw if we have good values
|
||||
if (Double.isNaN(transX0) || Double.isNaN(transY0)
|
||||
|| Double.isNaN(transX1) || Double.isNaN(transY1)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Point2D.Double point0 = new Point2D.Double();
|
||||
Point2D.Double point1 = new Point2D.Double();
|
||||
Point2D.Double point2 = new Point2D.Double();
|
||||
Point2D.Double point3 = new Point2D.Double();
|
||||
|
||||
if (item == 1) {
|
||||
point0 = null;
|
||||
}
|
||||
else {
|
||||
point0.x = domainAxis.valueToJava2D(dataset.getXValue(series,
|
||||
item - 2), dataArea, xAxisLocation);
|
||||
point0.y = rangeAxis.valueToJava2D(dataset.getYValue(series,
|
||||
item - 2), dataArea, yAxisLocation);
|
||||
}
|
||||
|
||||
point1.x = transX0;
|
||||
point1.y = transY0;
|
||||
|
||||
point2.x = transX1;
|
||||
point2.y = transY1;
|
||||
|
||||
if ((item + 1) == dataset.getItemCount(series)) {
|
||||
point3 = null;
|
||||
}
|
||||
else {
|
||||
point3.x = domainAxis.valueToJava2D(dataset.getXValue(series,
|
||||
item + 1), dataArea, xAxisLocation);
|
||||
point3.y = rangeAxis.valueToJava2D(dataset.getYValue(series,
|
||||
item + 1), dataArea, yAxisLocation);
|
||||
}
|
||||
|
||||
int steps = ((int) ((point2.x - point1.x) / 0.2) < 30)
|
||||
? (int) ((point2.x - point1.x) / 0.2) : 30;
|
||||
|
||||
Point2D.Double[] points = getBezierCurve(point0, point1, point2,
|
||||
point3, 1, steps);
|
||||
|
||||
for (int i = 1; i < points.length; i++) {
|
||||
transX0 = points[i - 1].x;
|
||||
transY0 = points[i - 1].y;
|
||||
transX1 = points[i].x;
|
||||
transY1 = points[i].y;
|
||||
|
||||
PlotOrientation orientation = plot.getOrientation();
|
||||
if (orientation == PlotOrientation.HORIZONTAL) {
|
||||
state.workingLine.setLine(transY0, transX0, transY1, transX1);
|
||||
}
|
||||
else if (orientation == PlotOrientation.VERTICAL) {
|
||||
state.workingLine.setLine(transX0, transY0, transX1, transY1);
|
||||
}
|
||||
|
||||
if (state.workingLine.intersects(dataArea)) {
|
||||
drawFirstPassShape(g2, pass, series, item, state.workingLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the item shapes and adds chart entities (second pass). This method
|
||||
* draws the shapes which mark the item positions. If <code>entities</code>
|
||||
* is not <code>null</code> it will be populated with entity information
|
||||
* for points that fall within the data area.
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
* @param plot the plot (can be used to obtain standard color
|
||||
* information etc).
|
||||
* @param domainAxis the domain axis.
|
||||
* @param dataArea the area within which the data is being drawn.
|
||||
* @param rangeAxis the range axis.
|
||||
* @param dataset the dataset.
|
||||
* @param pass the pass.
|
||||
* @param series the series index (zero-based).
|
||||
* @param item the item index (zero-based).
|
||||
* @param crosshairState the crosshair state.
|
||||
* @param entities the entity collection.
|
||||
*/
|
||||
protected void drawSecondaryPass(Graphics2D g2, XYPlot plot,
|
||||
XYDataset dataset, int pass, int series, int item,
|
||||
ValueAxis domainAxis, Rectangle2D dataArea,
|
||||
ValueAxis rangeAxis, CrosshairState crosshairState,
|
||||
EntityCollection entities) {
|
||||
// super.drawSecondaryPass(g2, plot, dataset, pass, series, item,
|
||||
// domainAxis, dataArea, rangeAxis, crosshairState, entities);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the control points.
|
||||
*
|
||||
* @param point0
|
||||
* @param point1
|
||||
* @param point2
|
||||
* @param point3
|
||||
* @param control1
|
||||
* @param control2
|
||||
* @param smooth
|
||||
*/
|
||||
public static void getControlPoints(Point2D.Double point0,
|
||||
Point2D.Double point1, Point2D.Double point2,
|
||||
Point2D.Double point3, Point2D.Double control1,
|
||||
Point2D.Double control2, double smooth) {
|
||||
|
||||
// Reference: http://www.antigrain.com/research/bezier_interpolation/
|
||||
|
||||
if (point0 == null) point0 = point1; //new Point2D.Double(0, 0);
|
||||
if (point3 == null) point3 = point2; //new Point2D.Double(0, 0);
|
||||
|
||||
Point2D.Double c1 = new Point2D.Double(
|
||||
(point0.x + point1.x) / 2.0, (point0.y + point1.y) / 2.0);
|
||||
Point2D.Double c2 = new Point2D.Double(
|
||||
(point1.x + point2.x) / 2.0, (point1.y + point2.y) / 2.0);
|
||||
Point2D.Double c3 = new Point2D.Double(
|
||||
(point2.x + point3.x) / 2.0, (point2.y + point3.y) / 2.0);
|
||||
|
||||
double len1 = point1.distance(point0);
|
||||
double len2 = point2.distance(point1);
|
||||
double len3 = point3.distance(point2);
|
||||
|
||||
double k1 = len1 / (len1 + len2);
|
||||
double k2 = len2 / (len2 + len3);
|
||||
|
||||
Point2D.Double m1 = new Point2D.Double(
|
||||
c1.x + (c2.x - c1.x) * k1, c1.y + (c2.y - c1.y) * k1);
|
||||
Point2D.Double m2 = new Point2D.Double(
|
||||
c2.x + (c3.x - c2.x) * k2, c2.y + (c3.y - c2.y) * k2);
|
||||
|
||||
control1.setLocation(new Point2D.Double(
|
||||
m1.x + (c2.x - m1.x) * smooth + point1.x - m1.x,
|
||||
m1.y + (c2.y - m1.y) * smooth + point1.y - m1.y));
|
||||
control2.setLocation(new Point2D.Double(
|
||||
m2.x + (c2.x - m2.x) * smooth + point2.x - m2.x,
|
||||
m2.y + (c2.y - m2.y) * smooth + point2.y - m2.y));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the points for a bezier curve.
|
||||
*
|
||||
* @param point0
|
||||
* @param point1
|
||||
* @param point2
|
||||
* @param point3
|
||||
* @param smooth
|
||||
* @param steps
|
||||
*
|
||||
* @return The curve points.
|
||||
*/
|
||||
public static Point2D.Double[] getBezierCurve(Point2D.Double point0,
|
||||
Point2D.Double point1, Point2D.Double point2,
|
||||
Point2D.Double point3, double smooth, int steps) {
|
||||
Point2D.Double control1 = new Point2D.Double();
|
||||
Point2D.Double control2 = new Point2D.Double();
|
||||
|
||||
getControlPoints(point0, point1, point2, point3, control1, control2,
|
||||
smooth);
|
||||
|
||||
Point2D.Double C = new Point2D.Double(
|
||||
3 * (control1.x - point1.x), 3 * (control1.y - point1.y));
|
||||
Point2D.Double B = new Point2D.Double(3 * (control2.x - control1.x)
|
||||
- C.x, 3 * (control2.y - control1.y) - C.y);
|
||||
Point2D.Double A = new Point2D.Double(point2.x - point1.x - C.x - B.x,
|
||||
point2.y - point1.y - C.y - B.y);
|
||||
|
||||
Point2D.Double[] res = new Point2D.Double[steps + 1];
|
||||
double stepSize = 1.0 / steps;
|
||||
double step = stepSize;
|
||||
|
||||
res[0] = point1;
|
||||
for (int i = 1; i < steps; i++) {
|
||||
res[i] = new Point2D.Double(A.x * Math.pow(step, 3) + B.x
|
||||
* Math.pow(step, 2) + C.x * step + point1.x, A.y
|
||||
* Math.pow(step, 3) + B.y * Math.pow(step, 2) + C.y * step
|
||||
+ point1.y);
|
||||
//System.out.println(step + " : " + res[i]);
|
||||
step += stepSize;
|
||||
}
|
||||
res[steps] = point2;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,189 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* ---------------
|
||||
* ChartColor.java
|
||||
* ---------------
|
||||
* (C) Copyright 2003-2008, by Cameron Riley and Contributors.
|
||||
*
|
||||
* Original Author: Cameron Riley;
|
||||
* Contributor(s): David Gilbert (for Object Refinery Limited);
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 23-Jan-2003 : Version 1, contributed by Cameron Riley (DG);
|
||||
* 25-Nov-2004 : Changed first 7 colors to softer shades (DG);
|
||||
* 03-Nov-2005 : Removed orange color, too close to yellow - see bug
|
||||
* report 1328408 (DG);
|
||||
* ------------- JFREECHART 1.0.x ---------------------------------------------
|
||||
* 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Paint;
|
||||
|
||||
/**
|
||||
* Class to extend the number of Colors available to the charts. This
|
||||
* extends the java.awt.Color object and extends the number of final
|
||||
* Colors publically accessible.
|
||||
*/
|
||||
public class ChartColor extends Color {
|
||||
|
||||
/** A very dark red color. */
|
||||
public static final Color VERY_DARK_RED = new Color(0x80, 0x00, 0x00);
|
||||
|
||||
/** A dark red color. */
|
||||
public static final Color DARK_RED = new Color(0xc0, 0x00, 0x00);
|
||||
|
||||
/** A light red color. */
|
||||
public static final Color LIGHT_RED = new Color(0xFF, 0x40, 0x40);
|
||||
|
||||
/** A very light red color. */
|
||||
public static final Color VERY_LIGHT_RED = new Color(0xFF, 0x80, 0x80);
|
||||
|
||||
/** A very dark yellow color. */
|
||||
public static final Color VERY_DARK_YELLOW = new Color(0x80, 0x80, 0x00);
|
||||
|
||||
/** A dark yellow color. */
|
||||
public static final Color DARK_YELLOW = new Color(0xC0, 0xC0, 0x00);
|
||||
|
||||
/** A light yellow color. */
|
||||
public static final Color LIGHT_YELLOW = new Color(0xFF, 0xFF, 0x40);
|
||||
|
||||
/** A very light yellow color. */
|
||||
public static final Color VERY_LIGHT_YELLOW = new Color(0xFF, 0xFF, 0x80);
|
||||
|
||||
/** A very dark green color. */
|
||||
public static final Color VERY_DARK_GREEN = new Color(0x00, 0x80, 0x00);
|
||||
|
||||
/** A dark green color. */
|
||||
public static final Color DARK_GREEN = new Color(0x00, 0xC0, 0x00);
|
||||
|
||||
/** A light green color. */
|
||||
public static final Color LIGHT_GREEN = new Color(0x40, 0xFF, 0x40);
|
||||
|
||||
/** A very light green color. */
|
||||
public static final Color VERY_LIGHT_GREEN = new Color(0x80, 0xFF, 0x80);
|
||||
|
||||
/** A very dark cyan color. */
|
||||
public static final Color VERY_DARK_CYAN = new Color(0x00, 0x80, 0x80);
|
||||
|
||||
/** A dark cyan color. */
|
||||
public static final Color DARK_CYAN = new Color(0x00, 0xC0, 0xC0);
|
||||
|
||||
/** A light cyan color. */
|
||||
public static final Color LIGHT_CYAN = new Color(0x40, 0xFF, 0xFF);
|
||||
|
||||
/** Aa very light cyan color. */
|
||||
public static final Color VERY_LIGHT_CYAN = new Color(0x80, 0xFF, 0xFF);
|
||||
|
||||
/** A very dark blue color. */
|
||||
public static final Color VERY_DARK_BLUE = new Color(0x00, 0x00, 0x80);
|
||||
|
||||
/** A dark blue color. */
|
||||
public static final Color DARK_BLUE = new Color(0x00, 0x00, 0xC0);
|
||||
|
||||
/** A light blue color. */
|
||||
public static final Color LIGHT_BLUE = new Color(0x40, 0x40, 0xFF);
|
||||
|
||||
/** A very light blue color. */
|
||||
public static final Color VERY_LIGHT_BLUE = new Color(0x80, 0x80, 0xFF);
|
||||
|
||||
/** A very dark magenta/purple color. */
|
||||
public static final Color VERY_DARK_MAGENTA = new Color(0x80, 0x00, 0x80);
|
||||
|
||||
/** A dark magenta color. */
|
||||
public static final Color DARK_MAGENTA = new Color(0xC0, 0x00, 0xC0);
|
||||
|
||||
/** A light magenta color. */
|
||||
public static final Color LIGHT_MAGENTA = new Color(0xFF, 0x40, 0xFF);
|
||||
|
||||
/** A very light magenta color. */
|
||||
public static final Color VERY_LIGHT_MAGENTA = new Color(0xFF, 0x80, 0xFF);
|
||||
|
||||
/**
|
||||
* Creates a Color with an opaque sRGB with red, green and blue values in
|
||||
* range 0-255.
|
||||
*
|
||||
* @param r the red component in range 0x00-0xFF.
|
||||
* @param g the green component in range 0x00-0xFF.
|
||||
* @param b the blue component in range 0x00-0xFF.
|
||||
*/
|
||||
public ChartColor(int r, int g, int b) {
|
||||
super(r, g, b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to return an array of <code>Paint</code> objects that
|
||||
* represent the pre-defined colors in the <code>Color<code> and
|
||||
* <code>ChartColor</code> objects.
|
||||
*
|
||||
* @return An array of objects with the <code>Paint</code> interface.
|
||||
*/
|
||||
public static Paint[] createDefaultPaintArray() {
|
||||
|
||||
return new Paint[] {
|
||||
new Color(0xFF, 0x55, 0x55),
|
||||
new Color(0x55, 0x55, 0xFF),
|
||||
new Color(0x55, 0xFF, 0x55),
|
||||
new Color(0xFF, 0xFF, 0x55),
|
||||
new Color(0xFF, 0x55, 0xFF),
|
||||
new Color(0x55, 0xFF, 0xFF),
|
||||
Color.pink,
|
||||
Color.gray,
|
||||
ChartColor.DARK_RED,
|
||||
ChartColor.DARK_BLUE,
|
||||
ChartColor.DARK_GREEN,
|
||||
ChartColor.DARK_YELLOW,
|
||||
ChartColor.DARK_MAGENTA,
|
||||
ChartColor.DARK_CYAN,
|
||||
Color.darkGray,
|
||||
ChartColor.LIGHT_RED,
|
||||
ChartColor.LIGHT_BLUE,
|
||||
ChartColor.LIGHT_GREEN,
|
||||
ChartColor.LIGHT_YELLOW,
|
||||
ChartColor.LIGHT_MAGENTA,
|
||||
ChartColor.LIGHT_CYAN,
|
||||
Color.lightGray,
|
||||
ChartColor.VERY_DARK_RED,
|
||||
ChartColor.VERY_DARK_BLUE,
|
||||
ChartColor.VERY_DARK_GREEN,
|
||||
ChartColor.VERY_DARK_YELLOW,
|
||||
ChartColor.VERY_DARK_MAGENTA,
|
||||
ChartColor.VERY_DARK_CYAN,
|
||||
ChartColor.VERY_LIGHT_RED,
|
||||
ChartColor.VERY_LIGHT_BLUE,
|
||||
ChartColor.VERY_LIGHT_GREEN,
|
||||
ChartColor.VERY_LIGHT_YELLOW,
|
||||
ChartColor.VERY_LIGHT_MAGENTA,
|
||||
ChartColor.VERY_LIGHT_CYAN
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,96 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* ---------------
|
||||
* ChartFrame.java
|
||||
* ---------------
|
||||
* (C) Copyright 2001-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 22-Nov-2001 : Version 1 (DG);
|
||||
* 08-Jan-2001 : Added chartPanel attribute (DG);
|
||||
* 24-May-2002 : Renamed JFreeChartFrame --> ChartFrame (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.WindowConstants;
|
||||
|
||||
/**
|
||||
* A frame for displaying a chart.
|
||||
*/
|
||||
public class ChartFrame extends JFrame {
|
||||
|
||||
/** The chart panel. */
|
||||
private ChartPanel chartPanel;
|
||||
|
||||
/**
|
||||
* Constructs a frame for a chart.
|
||||
*
|
||||
* @param title the frame title.
|
||||
* @param chart the chart.
|
||||
*/
|
||||
public ChartFrame(String title, JFreeChart chart) {
|
||||
this(title, chart, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a frame for a chart.
|
||||
*
|
||||
* @param title the frame title.
|
||||
* @param chart the chart.
|
||||
* @param scrollPane if <code>true</code>, put the Chart(Panel) into a
|
||||
* JScrollPane.
|
||||
*/
|
||||
public ChartFrame(String title, JFreeChart chart, boolean scrollPane) {
|
||||
super(title);
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
this.chartPanel = new ChartPanel(chart);
|
||||
if (scrollPane) {
|
||||
setContentPane(new JScrollPane(this.chartPanel));
|
||||
}
|
||||
else {
|
||||
setContentPane(this.chartPanel);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the chart panel for the frame.
|
||||
*
|
||||
* @return The chart panel.
|
||||
*/
|
||||
public ChartPanel getChartPanel() {
|
||||
return this.chartPanel;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* --------------------
|
||||
* ChartMouseEvent.java
|
||||
* --------------------
|
||||
* (C) Copyright 2002-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): Alex Weber;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 27-May-2002 : Version 1, incorporating code and ideas by Alex Weber (DG);
|
||||
* 13-Jun-2002 : Added Javadoc comments (DG);
|
||||
* 26-Sep-2002 : Fixed errors reported by Checkstyle (DG);
|
||||
* 05-Nov-2002 : Added a reference to the source chart (DG);
|
||||
* 13-Jul-2004 : Now extends EventObject and implements Serializable (DG);
|
||||
* ------------- JFREECHART 1.0.x ---------------------------------------------
|
||||
* 24-May-2007 : Updated API docs (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.Serializable;
|
||||
import java.util.EventObject;
|
||||
|
||||
import org.jfree.chart.entity.ChartEntity;
|
||||
|
||||
/**
|
||||
* A mouse event for a chart that is displayed in a {@link ChartPanel}.
|
||||
*
|
||||
* @see ChartMouseListener
|
||||
*/
|
||||
public class ChartMouseEvent extends EventObject implements Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
private static final long serialVersionUID = -682393837314562149L;
|
||||
|
||||
/** The chart that the mouse event relates to. */
|
||||
private JFreeChart chart;
|
||||
|
||||
/** The Java mouse event that triggered this event. */
|
||||
private MouseEvent trigger;
|
||||
|
||||
/** The chart entity (if any). */
|
||||
private ChartEntity entity;
|
||||
|
||||
/**
|
||||
* Constructs a new event.
|
||||
*
|
||||
* @param chart the source chart (<code>null</code> not permitted).
|
||||
* @param trigger the mouse event that triggered this event
|
||||
* (<code>null</code> not permitted).
|
||||
* @param entity the chart entity (if any) under the mouse point
|
||||
* (<code>null</code> permitted).
|
||||
*/
|
||||
public ChartMouseEvent(JFreeChart chart, MouseEvent trigger,
|
||||
ChartEntity entity) {
|
||||
super(chart);
|
||||
this.chart = chart;
|
||||
this.trigger = trigger;
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the chart that the mouse event relates to.
|
||||
*
|
||||
* @return The chart (never <code>null</code>).
|
||||
*/
|
||||
public JFreeChart getChart() {
|
||||
return this.chart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the mouse event that triggered this event.
|
||||
*
|
||||
* @return The event (never <code>null</code>).
|
||||
*/
|
||||
public MouseEvent getTrigger() {
|
||||
return this.trigger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the chart entity (if any) under the mouse point.
|
||||
*
|
||||
* @return The chart entity (possibly <code>null</code>).
|
||||
*/
|
||||
public ChartEntity getEntity() {
|
||||
return this.entity;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -----------------------
|
||||
* ChartMouseListener.java
|
||||
* -----------------------
|
||||
* (C) Copyright 2002-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): Alex Weber;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 27-May-2002 : Version 1, incorporating code and ideas by Alex Weber (DG);
|
||||
* 13-Jun-2002 : Added Javadocs (DG);
|
||||
* 26-Sep-2002 : Fixed errors reported by Checkstyle (DG);
|
||||
* 23-Nov-2005 : Now extends EventListener (DG);
|
||||
* ------------- JFREECHART 1.0.x ---------------------------------------------
|
||||
* 24-May-2007 : Updated API docs (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
/**
|
||||
* The interface that must be implemented by classes that wish to receive
|
||||
* {@link ChartMouseEvent} notifications from a {@link ChartPanel}.
|
||||
*
|
||||
* @see ChartPanel#addChartMouseListener(ChartMouseListener)
|
||||
*/
|
||||
public interface ChartMouseListener extends EventListener {
|
||||
|
||||
/**
|
||||
* Callback method for receiving notification of a mouse click on a chart.
|
||||
*
|
||||
* @param event information about the event.
|
||||
*/
|
||||
void chartMouseClicked(ChartMouseEvent event);
|
||||
|
||||
/**
|
||||
* Callback method for receiving notification of a mouse movement on a
|
||||
* chart.
|
||||
*
|
||||
* @param event information about the event.
|
||||
*/
|
||||
void chartMouseMoved(ChartMouseEvent event);
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,255 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -----------------------
|
||||
* ChartRenderingInfo.java
|
||||
* -----------------------
|
||||
* (C) Copyright 2002-2008, by Object Refinery Limited.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 22-Jan-2002 : Version 1 (DG);
|
||||
* 05-Feb-2002 : Added a new constructor, completed Javadoc comments (DG);
|
||||
* 05-Mar-2002 : Added a clear() method (DG);
|
||||
* 23-May-2002 : Renamed DrawInfo --> ChartRenderingInfo (DG);
|
||||
* 26-Sep-2002 : Fixed errors reported by Checkstyle (DG);
|
||||
* 17-Sep-2003 : Added PlotRenderingInfo (DG);
|
||||
* 01-Nov-2005 : Updated equals() method (DG);
|
||||
* 30-Nov-2005 : Removed get/setPlotArea() (DG);
|
||||
* ------------- JFREECHART 1.0.x ---------------------------------------------
|
||||
* 01-Dec-2006 : Fixed equals() and clone() (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.jfree.chart.entity.EntityCollection;
|
||||
import org.jfree.chart.entity.StandardEntityCollection;
|
||||
import org.jfree.chart.plot.PlotRenderingInfo;
|
||||
import org.jfree.io.SerialUtilities;
|
||||
import org.jfree.util.ObjectUtilities;
|
||||
import org.jfree.util.PublicCloneable;
|
||||
|
||||
/**
|
||||
* A structure for storing rendering information from one call to the
|
||||
* JFreeChart.draw() method.
|
||||
* <P>
|
||||
* An instance of the {@link JFreeChart} class can draw itself within an
|
||||
* arbitrary rectangle on any <code>Graphics2D</code>. It is assumed that
|
||||
* client code will sometimes render the same chart in more than one view, so
|
||||
* the {@link JFreeChart} instance does not retain any information about its
|
||||
* rendered dimensions. This information can be useful sometimes, so you have
|
||||
* the option to collect the information at each call to
|
||||
* <code>JFreeChart.draw()</code>, by passing an instance of this
|
||||
* <code>ChartRenderingInfo</code> class.
|
||||
*/
|
||||
public class ChartRenderingInfo implements Cloneable, Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
private static final long serialVersionUID = 2751952018173406822L;
|
||||
|
||||
/** The area in which the chart is drawn. */
|
||||
private transient Rectangle2D chartArea;
|
||||
|
||||
/** Rendering info for the chart's plot (and subplots, if any). */
|
||||
private PlotRenderingInfo plotInfo;
|
||||
|
||||
/**
|
||||
* Storage for the chart entities. Since retaining entity information for
|
||||
* charts with a large number of data points consumes a lot of memory, it
|
||||
* is intended that you can set this to <code>null</code> to prevent the
|
||||
* information being collected.
|
||||
*/
|
||||
private EntityCollection entities;
|
||||
|
||||
/**
|
||||
* Constructs a new ChartRenderingInfo structure that can be used to
|
||||
* collect information about the dimensions of a rendered chart.
|
||||
*/
|
||||
public ChartRenderingInfo() {
|
||||
this(new StandardEntityCollection());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new instance. If an entity collection is supplied, it will
|
||||
* be populated with information about the entities in a chart. If it is
|
||||
* <code>null</code>, no entity information (including tool tips) will
|
||||
* be collected.
|
||||
*
|
||||
* @param entities an entity collection (<code>null</code> permitted).
|
||||
*/
|
||||
public ChartRenderingInfo(EntityCollection entities) {
|
||||
this.chartArea = new Rectangle2D.Double();
|
||||
this.plotInfo = new PlotRenderingInfo(this);
|
||||
this.entities = entities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the area in which the chart was drawn.
|
||||
*
|
||||
* @return The area in which the chart was drawn.
|
||||
*
|
||||
* @see #setChartArea(Rectangle2D)
|
||||
*/
|
||||
public Rectangle2D getChartArea() {
|
||||
return this.chartArea;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the area in which the chart was drawn.
|
||||
*
|
||||
* @param area the chart area.
|
||||
*
|
||||
* @see #getChartArea()
|
||||
*/
|
||||
public void setChartArea(Rectangle2D area) {
|
||||
this.chartArea.setRect(area);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the collection of entities maintained by this instance.
|
||||
*
|
||||
* @return The entity collection (possibly <code>null</code>).
|
||||
*
|
||||
* @see #setEntityCollection(EntityCollection)
|
||||
*/
|
||||
public EntityCollection getEntityCollection() {
|
||||
return this.entities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the entity collection.
|
||||
*
|
||||
* @param entities the entity collection (<code>null</code> permitted).
|
||||
*
|
||||
* @see #getEntityCollection()
|
||||
*/
|
||||
public void setEntityCollection(EntityCollection entities) {
|
||||
this.entities = entities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the information recorded by this object.
|
||||
*/
|
||||
public void clear() {
|
||||
this.chartArea.setRect(0.0, 0.0, 0.0, 0.0);
|
||||
this.plotInfo = new PlotRenderingInfo(this);
|
||||
if (this.entities != null) {
|
||||
this.entities.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rendering info for the chart's plot.
|
||||
*
|
||||
* @return The rendering info for the plot.
|
||||
*/
|
||||
public PlotRenderingInfo getPlotInfo() {
|
||||
return this.plotInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this object for equality with an arbitrary object.
|
||||
*
|
||||
* @param obj the object to test against (<code>null</code> permitted).
|
||||
*
|
||||
* @return A boolean.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof ChartRenderingInfo)) {
|
||||
return false;
|
||||
}
|
||||
ChartRenderingInfo that = (ChartRenderingInfo) obj;
|
||||
if (!ObjectUtilities.equal(this.chartArea, that.chartArea)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtilities.equal(this.plotInfo, that.plotInfo)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtilities.equal(this.entities, that.entities)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone of this object.
|
||||
*
|
||||
* @return A clone.
|
||||
*
|
||||
* @throws CloneNotSupportedException if the object cannot be cloned.
|
||||
*/
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
ChartRenderingInfo clone = (ChartRenderingInfo) super.clone();
|
||||
if (this.chartArea != null) {
|
||||
clone.chartArea = (Rectangle2D) this.chartArea.clone();
|
||||
}
|
||||
if (this.entities instanceof PublicCloneable) {
|
||||
PublicCloneable pc = (PublicCloneable) this.entities;
|
||||
clone.entities = (EntityCollection) pc.clone();
|
||||
}
|
||||
return clone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the output stream.
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
*/
|
||||
private void writeObject(ObjectOutputStream stream) throws IOException {
|
||||
stream.defaultWriteObject();
|
||||
SerialUtilities.writeShape(this.chartArea, stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the input stream.
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
* @throws ClassNotFoundException if there is a classpath problem.
|
||||
*/
|
||||
private void readObject(ObjectInputStream stream)
|
||||
throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
this.chartArea = (Rectangle2D) SerialUtilities.readShape(stream);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* ---------------
|
||||
* ChartTheme.java
|
||||
* ---------------
|
||||
* (C) Copyright 2008, by Object Refinery Limited.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 14-Aug-2008 : Version 1 (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
import org.jfree.chart.JFreeChart;
|
||||
|
||||
/**
|
||||
* A {@link ChartTheme} a class that can apply a style or 'theme' to a chart.
|
||||
* It can be implemented in an arbitrary manner, with the styling applied to
|
||||
* the chart via the <code>apply(JFreeChart)</code> method. We provide one
|
||||
* implementation ({@link StandardChartTheme}) that just mimics the manual
|
||||
* process of calling methods to set various chart parameters.
|
||||
*
|
||||
* @since 1.0.11
|
||||
*/
|
||||
public interface ChartTheme {
|
||||
|
||||
/**
|
||||
* Applies this theme to the supplied chart.
|
||||
*
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
*/
|
||||
public void apply(JFreeChart chart);
|
||||
|
||||
}
|
||||
@@ -1,762 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -------------------
|
||||
* ChartUtilities.java
|
||||
* -------------------
|
||||
* (C) Copyright 2001-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): Wolfgang Irler;
|
||||
* Richard Atkinson;
|
||||
* Xavier Poinsard;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 11-Dec-2001 : Version 1. The JPEG method comes from Wolfgang Irler's
|
||||
* JFreeChartServletDemo class (DG);
|
||||
* 23-Jan-2002 : Changed saveChartAsXXX() methods to pass IOExceptions back to
|
||||
* caller (DG);
|
||||
* 26-Jun-2002 : Added image map methods (DG);
|
||||
* 05-Aug-2002 : Added writeBufferedImage methods
|
||||
* Modified writeImageMap method to support flexible image
|
||||
* maps (RA);
|
||||
* 26-Aug-2002 : Added saveChartAsJPEG and writeChartAsJPEG methods with info
|
||||
* objects (RA);
|
||||
* 05-Sep-2002 : Added writeImageMap() method to support OverLIB
|
||||
* - http://www.bosrup.com/web/overlib (RA);
|
||||
* 26-Sep-2002 : Fixed errors reported by Checkstyle (DG);
|
||||
* 17-Oct-2002 : Exposed JPEG quality setting and PNG compression level as
|
||||
* parameters (DG);
|
||||
* 25-Oct-2002 : Fixed writeChartAsJPEG() empty method bug (DG);
|
||||
* 13-Mar-2003 : Updated writeImageMap method as suggested by Xavier Poinsard
|
||||
* (see Feature Request 688079) (DG);
|
||||
* 12-Aug-2003 : Added support for custom image maps using
|
||||
* ToolTipTagFragmentGenerator and URLTagFragmentGenerator (RA);
|
||||
* 02-Sep-2003 : Separated PNG encoding from writing chart to an
|
||||
* OutputStream (RA);
|
||||
* 04-Dec-2003 : Chart draw() method modified to include anchor point (DG);
|
||||
* 20-Feb-2004 : Edited Javadocs and added argument checking (DG);
|
||||
* 05-Apr-2004 : Fixed problem with buffered image type (DG);
|
||||
* 01-Aug-2004 : Modified to use EncoderUtil for all image encoding (RA);
|
||||
* 02-Aug-2004 : Delegated image map related functionality to ImageMapUtil (RA);
|
||||
* 13-Jan-2005 : Renamed ImageMapUtil --> ImageMapUtilities, removed method
|
||||
* writeImageMap(PrintWriter, String, ChartRenderingInfo) which
|
||||
* exists in ImageMapUtilities (DG);
|
||||
* ------------- JFREECHART 1.0.x ---------------------------------------------
|
||||
* 06-Feb-2006 : API doc update (DG);
|
||||
* 19-Mar-2007 : Use try-finally to close output stream in saveChartAsXXX()
|
||||
* methods (DG);
|
||||
* 10-Jan-2008 : Fix bug 1868251 - don't create image with transparency when
|
||||
* saving to JPEG format (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.jfree.chart.encoders.EncoderUtil;
|
||||
import org.jfree.chart.encoders.ImageFormat;
|
||||
import org.jfree.chart.imagemap.ImageMapUtilities;
|
||||
import org.jfree.chart.imagemap.OverLIBToolTipTagFragmentGenerator;
|
||||
import org.jfree.chart.imagemap.StandardToolTipTagFragmentGenerator;
|
||||
import org.jfree.chart.imagemap.StandardURLTagFragmentGenerator;
|
||||
import org.jfree.chart.imagemap.ToolTipTagFragmentGenerator;
|
||||
import org.jfree.chart.imagemap.URLTagFragmentGenerator;
|
||||
|
||||
/**
|
||||
* A collection of utility methods for JFreeChart. Includes methods for
|
||||
* converting charts to image formats (PNG and JPEG) plus creating simple HTML
|
||||
* image maps.
|
||||
*
|
||||
* @see ImageMapUtilities
|
||||
*/
|
||||
public abstract class ChartUtilities {
|
||||
|
||||
/**
|
||||
* Applies the current theme to the specified chart. This method is
|
||||
* provided for convenience, the theme itself is stored in the
|
||||
* {@link ChartFactory} class.
|
||||
*
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
*
|
||||
* @since 1.0.11
|
||||
*/
|
||||
public static void applyCurrentTheme(JFreeChart chart) {
|
||||
ChartFactory.getChartTheme().apply(chart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a chart to an output stream in PNG format.
|
||||
*
|
||||
* @param out the output stream (<code>null</code> not permitted).
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the image width.
|
||||
* @param height the image height.
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void writeChartAsPNG(OutputStream out, JFreeChart chart,
|
||||
int width, int height) throws IOException {
|
||||
|
||||
// defer argument checking...
|
||||
writeChartAsPNG(out, chart, width, height, null);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a chart to an output stream in PNG format.
|
||||
*
|
||||
* @param out the output stream (<code>null</code> not permitted).
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the image width.
|
||||
* @param height the image height.
|
||||
* @param encodeAlpha encode alpha?
|
||||
* @param compression the compression level (0-9).
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void writeChartAsPNG(OutputStream out, JFreeChart chart,
|
||||
int width, int height, boolean encodeAlpha, int compression)
|
||||
throws IOException {
|
||||
|
||||
// defer argument checking...
|
||||
ChartUtilities.writeChartAsPNG(out, chart, width, height, null,
|
||||
encodeAlpha, compression);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a chart to an output stream in PNG format. This method allows
|
||||
* you to pass in a {@link ChartRenderingInfo} object, to collect
|
||||
* information about the chart dimensions/entities. You will need this
|
||||
* info if you want to create an HTML image map.
|
||||
*
|
||||
* @param out the output stream (<code>null</code> not permitted).
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the image width.
|
||||
* @param height the image height.
|
||||
* @param info the chart rendering info (<code>null</code> permitted).
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void writeChartAsPNG(OutputStream out, JFreeChart chart,
|
||||
int width, int height, ChartRenderingInfo info)
|
||||
throws IOException {
|
||||
|
||||
if (chart == null) {
|
||||
throw new IllegalArgumentException("Null 'chart' argument.");
|
||||
}
|
||||
BufferedImage bufferedImage
|
||||
= chart.createBufferedImage(width, height, info);
|
||||
EncoderUtil.writeBufferedImage(bufferedImage, ImageFormat.PNG, out);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a chart to an output stream in PNG format. This method allows
|
||||
* you to pass in a {@link ChartRenderingInfo} object, to collect
|
||||
* information about the chart dimensions/entities. You will need this
|
||||
* info if you want to create an HTML image map.
|
||||
*
|
||||
* @param out the output stream (<code>null</code> not permitted).
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the image width.
|
||||
* @param height the image height.
|
||||
* @param info carries back chart rendering info (<code>null</code>
|
||||
* permitted).
|
||||
* @param encodeAlpha encode alpha?
|
||||
* @param compression the PNG compression level (0-9).
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void writeChartAsPNG(OutputStream out, JFreeChart chart,
|
||||
int width, int height, ChartRenderingInfo info,
|
||||
boolean encodeAlpha, int compression) throws IOException {
|
||||
|
||||
if (out == null) {
|
||||
throw new IllegalArgumentException("Null 'out' argument.");
|
||||
}
|
||||
if (chart == null) {
|
||||
throw new IllegalArgumentException("Null 'chart' argument.");
|
||||
}
|
||||
BufferedImage chartImage = chart.createBufferedImage(width, height,
|
||||
BufferedImage.TYPE_INT_ARGB, info);
|
||||
ChartUtilities.writeBufferedImageAsPNG(out, chartImage, encodeAlpha,
|
||||
compression);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a scaled version of a chart to an output stream in PNG format.
|
||||
*
|
||||
* @param out the output stream (<code>null</code> not permitted).
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the unscaled chart width.
|
||||
* @param height the unscaled chart height.
|
||||
* @param widthScaleFactor the horizontal scale factor.
|
||||
* @param heightScaleFactor the vertical scale factor.
|
||||
*
|
||||
* @throws IOException if there are any I/O problems.
|
||||
*/
|
||||
public static void writeScaledChartAsPNG(OutputStream out,
|
||||
JFreeChart chart, int width, int height, int widthScaleFactor,
|
||||
int heightScaleFactor) throws IOException {
|
||||
|
||||
if (out == null) {
|
||||
throw new IllegalArgumentException("Null 'out' argument.");
|
||||
}
|
||||
if (chart == null) {
|
||||
throw new IllegalArgumentException("Null 'chart' argument.");
|
||||
}
|
||||
|
||||
double desiredWidth = width * widthScaleFactor;
|
||||
double desiredHeight = height * heightScaleFactor;
|
||||
double defaultWidth = width;
|
||||
double defaultHeight = height;
|
||||
boolean scale = false;
|
||||
|
||||
// get desired width and height from somewhere then...
|
||||
if ((widthScaleFactor != 1) || (heightScaleFactor != 1)) {
|
||||
scale = true;
|
||||
}
|
||||
|
||||
double scaleX = desiredWidth / defaultWidth;
|
||||
double scaleY = desiredHeight / defaultHeight;
|
||||
|
||||
BufferedImage image = new BufferedImage((int) desiredWidth,
|
||||
(int) desiredHeight, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D g2 = image.createGraphics();
|
||||
|
||||
if (scale) {
|
||||
AffineTransform saved = g2.getTransform();
|
||||
g2.transform(AffineTransform.getScaleInstance(scaleX, scaleY));
|
||||
chart.draw(g2, new Rectangle2D.Double(0, 0, defaultWidth,
|
||||
defaultHeight), null, null);
|
||||
g2.setTransform(saved);
|
||||
g2.dispose();
|
||||
}
|
||||
else {
|
||||
chart.draw(g2, new Rectangle2D.Double(0, 0, defaultWidth,
|
||||
defaultHeight), null, null);
|
||||
}
|
||||
out.write(encodeAsPNG(image));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a chart to the specified file in PNG format.
|
||||
*
|
||||
* @param file the file name (<code>null</code> not permitted).
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the image width.
|
||||
* @param height the image height.
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void saveChartAsPNG(File file, JFreeChart chart,
|
||||
int width, int height) throws IOException {
|
||||
|
||||
// defer argument checking...
|
||||
saveChartAsPNG(file, chart, width, height, null);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a chart to a file in PNG format. This method allows you to pass
|
||||
* in a {@link ChartRenderingInfo} object, to collect information about the
|
||||
* chart dimensions/entities. You will need this info if you want to
|
||||
* create an HTML image map.
|
||||
*
|
||||
* @param file the file (<code>null</code> not permitted).
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the image width.
|
||||
* @param height the image height.
|
||||
* @param info the chart rendering info (<code>null</code> permitted).
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void saveChartAsPNG(File file, JFreeChart chart,
|
||||
int width, int height, ChartRenderingInfo info)
|
||||
throws IOException {
|
||||
|
||||
if (file == null) {
|
||||
throw new IllegalArgumentException("Null 'file' argument.");
|
||||
}
|
||||
OutputStream out = new BufferedOutputStream(new FileOutputStream(file));
|
||||
try {
|
||||
ChartUtilities.writeChartAsPNG(out, chart, width, height, info);
|
||||
}
|
||||
finally {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a chart to a file in PNG format. This method allows you to pass
|
||||
* in a {@link ChartRenderingInfo} object, to collect information about the
|
||||
* chart dimensions/entities. You will need this info if you want to
|
||||
* create an HTML image map.
|
||||
*
|
||||
* @param file the file (<code>null</code> not permitted).
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the image width.
|
||||
* @param height the image height.
|
||||
* @param info the chart rendering info (<code>null</code> permitted).
|
||||
* @param encodeAlpha encode alpha?
|
||||
* @param compression the PNG compression level (0-9).
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void saveChartAsPNG(File file, JFreeChart chart,
|
||||
int width, int height, ChartRenderingInfo info, boolean encodeAlpha,
|
||||
int compression) throws IOException {
|
||||
|
||||
if (file == null) {
|
||||
throw new IllegalArgumentException("Null 'file' argument.");
|
||||
}
|
||||
if (chart == null) {
|
||||
throw new IllegalArgumentException("Null 'chart' argument.");
|
||||
}
|
||||
|
||||
OutputStream out = new BufferedOutputStream(new FileOutputStream(file));
|
||||
try {
|
||||
writeChartAsPNG(out, chart, width, height, info, encodeAlpha,
|
||||
compression);
|
||||
}
|
||||
finally {
|
||||
out.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a chart to an output stream in JPEG format. Please note that
|
||||
* JPEG is a poor format for chart images, use PNG if possible.
|
||||
*
|
||||
* @param out the output stream (<code>null</code> not permitted).
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the image width.
|
||||
* @param height the image height.
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void writeChartAsJPEG(OutputStream out,
|
||||
JFreeChart chart, int width, int height) throws IOException {
|
||||
|
||||
// defer argument checking...
|
||||
writeChartAsJPEG(out, chart, width, height, null);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a chart to an output stream in JPEG format. Please note that
|
||||
* JPEG is a poor format for chart images, use PNG if possible.
|
||||
*
|
||||
* @param out the output stream (<code>null</code> not permitted).
|
||||
* @param quality the quality setting.
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the image width.
|
||||
* @param height the image height.
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void writeChartAsJPEG(OutputStream out, float quality,
|
||||
JFreeChart chart, int width, int height) throws IOException {
|
||||
|
||||
// defer argument checking...
|
||||
ChartUtilities.writeChartAsJPEG(out, quality, chart, width, height,
|
||||
null);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a chart to an output stream in JPEG format. This method allows
|
||||
* you to pass in a {@link ChartRenderingInfo} object, to collect
|
||||
* information about the chart dimensions/entities. You will need this
|
||||
* info if you want to create an HTML image map.
|
||||
*
|
||||
* @param out the output stream (<code>null</code> not permitted).
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the image width.
|
||||
* @param height the image height.
|
||||
* @param info the chart rendering info (<code>null</code> permitted).
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void writeChartAsJPEG(OutputStream out, JFreeChart chart,
|
||||
int width, int height, ChartRenderingInfo info)
|
||||
throws IOException {
|
||||
|
||||
if (chart == null) {
|
||||
throw new IllegalArgumentException("Null 'chart' argument.");
|
||||
}
|
||||
BufferedImage image = chart.createBufferedImage(width, height,
|
||||
BufferedImage.TYPE_INT_RGB, info);
|
||||
EncoderUtil.writeBufferedImage(image, ImageFormat.JPEG, out);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a chart to an output stream in JPEG format. This method allows
|
||||
* you to pass in a {@link ChartRenderingInfo} object, to collect
|
||||
* information about the chart dimensions/entities. You will need this
|
||||
* info if you want to create an HTML image map.
|
||||
*
|
||||
* @param out the output stream (<code>null</code> not permitted).
|
||||
* @param quality the output quality (0.0f to 1.0f).
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the image width.
|
||||
* @param height the image height.
|
||||
* @param info the chart rendering info (<code>null</code> permitted).
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void writeChartAsJPEG(OutputStream out, float quality,
|
||||
JFreeChart chart, int width, int height, ChartRenderingInfo info)
|
||||
throws IOException {
|
||||
|
||||
if (chart == null) {
|
||||
throw new IllegalArgumentException("Null 'chart' argument.");
|
||||
}
|
||||
BufferedImage image = chart.createBufferedImage(width, height,
|
||||
BufferedImage.TYPE_INT_RGB, info);
|
||||
EncoderUtil.writeBufferedImage(image, ImageFormat.JPEG, out, quality);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a chart to a file in JPEG format.
|
||||
*
|
||||
* @param file the file (<code>null</code> not permitted).
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the image width.
|
||||
* @param height the image height.
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void saveChartAsJPEG(File file, JFreeChart chart,
|
||||
int width, int height) throws IOException {
|
||||
|
||||
// defer argument checking...
|
||||
saveChartAsJPEG(file, chart, width, height, null);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a chart to a file in JPEG format.
|
||||
*
|
||||
* @param file the file (<code>null</code> not permitted).
|
||||
* @param quality the JPEG quality setting.
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the image width.
|
||||
* @param height the image height.
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void saveChartAsJPEG(File file, float quality,
|
||||
JFreeChart chart, int width, int height) throws IOException {
|
||||
|
||||
// defer argument checking...
|
||||
saveChartAsJPEG(file, quality, chart, width, height, null);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a chart to a file in JPEG format. This method allows you to pass
|
||||
* in a {@link ChartRenderingInfo} object, to collect information about the
|
||||
* chart dimensions/entities. You will need this info if you want to
|
||||
* create an HTML image map.
|
||||
*
|
||||
* @param file the file name (<code>null</code> not permitted).
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the image width.
|
||||
* @param height the image height.
|
||||
* @param info the chart rendering info (<code>null</code> permitted).
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void saveChartAsJPEG(File file, JFreeChart chart,
|
||||
int width, int height, ChartRenderingInfo info) throws IOException {
|
||||
|
||||
if (file == null) {
|
||||
throw new IllegalArgumentException("Null 'file' argument.");
|
||||
}
|
||||
if (chart == null) {
|
||||
throw new IllegalArgumentException("Null 'chart' argument.");
|
||||
}
|
||||
OutputStream out = new BufferedOutputStream(new FileOutputStream(file));
|
||||
try {
|
||||
writeChartAsJPEG(out, chart, width, height, info);
|
||||
}
|
||||
finally {
|
||||
out.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a chart to a file in JPEG format. This method allows you to pass
|
||||
* in a {@link ChartRenderingInfo} object, to collect information about the
|
||||
* chart dimensions/entities. You will need this info if you want to
|
||||
* create an HTML image map.
|
||||
*
|
||||
* @param file the file name (<code>null</code> not permitted).
|
||||
* @param quality the quality setting.
|
||||
* @param chart the chart (<code>null</code> not permitted).
|
||||
* @param width the image width.
|
||||
* @param height the image height.
|
||||
* @param info the chart rendering info (<code>null</code> permitted).
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void saveChartAsJPEG(File file, float quality,
|
||||
JFreeChart chart, int width, int height,
|
||||
ChartRenderingInfo info) throws IOException {
|
||||
|
||||
if (file == null) {
|
||||
throw new IllegalArgumentException("Null 'file' argument.");
|
||||
}
|
||||
if (chart == null) {
|
||||
throw new IllegalArgumentException("Null 'chart' argument.");
|
||||
}
|
||||
|
||||
OutputStream out = new BufferedOutputStream(new FileOutputStream(
|
||||
file));
|
||||
try {
|
||||
writeChartAsJPEG(out, quality, chart, width, height, info);
|
||||
}
|
||||
finally {
|
||||
out.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a {@link BufferedImage} to an output stream in JPEG format.
|
||||
*
|
||||
* @param out the output stream (<code>null</code> not permitted).
|
||||
* @param image the image (<code>null</code> not permitted).
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void writeBufferedImageAsJPEG(OutputStream out,
|
||||
BufferedImage image) throws IOException {
|
||||
|
||||
// defer argument checking...
|
||||
writeBufferedImageAsJPEG(out, 0.75f, image);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a {@link BufferedImage} to an output stream in JPEG format.
|
||||
*
|
||||
* @param out the output stream (<code>null</code> not permitted).
|
||||
* @param quality the image quality (0.0f to 1.0f).
|
||||
* @param image the image (<code>null</code> not permitted).
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void writeBufferedImageAsJPEG(OutputStream out, float quality,
|
||||
BufferedImage image) throws IOException {
|
||||
|
||||
EncoderUtil.writeBufferedImage(image, ImageFormat.JPEG, out, quality);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a {@link BufferedImage} to an output stream in PNG format.
|
||||
*
|
||||
* @param out the output stream (<code>null</code> not permitted).
|
||||
* @param image the image (<code>null</code> not permitted).
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void writeBufferedImageAsPNG(OutputStream out,
|
||||
BufferedImage image) throws IOException {
|
||||
|
||||
EncoderUtil.writeBufferedImage(image, ImageFormat.PNG, out);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a {@link BufferedImage} to an output stream in PNG format.
|
||||
*
|
||||
* @param out the output stream (<code>null</code> not permitted).
|
||||
* @param image the image (<code>null</code> not permitted).
|
||||
* @param encodeAlpha encode alpha?
|
||||
* @param compression the compression level (0-9).
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void writeBufferedImageAsPNG(OutputStream out,
|
||||
BufferedImage image, boolean encodeAlpha, int compression)
|
||||
throws IOException {
|
||||
|
||||
EncoderUtil.writeBufferedImage(image, ImageFormat.PNG, out,
|
||||
compression, encodeAlpha);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes a {@link BufferedImage} to PNG format.
|
||||
*
|
||||
* @param image the image (<code>null</code> not permitted).
|
||||
*
|
||||
* @return A byte array in PNG format.
|
||||
*
|
||||
* @throws IOException if there is an I/O problem.
|
||||
*/
|
||||
public static byte[] encodeAsPNG(BufferedImage image) throws IOException {
|
||||
return EncoderUtil.encode(image, ImageFormat.PNG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes a {@link BufferedImage} to PNG format.
|
||||
*
|
||||
* @param image the image (<code>null</code> not permitted).
|
||||
* @param encodeAlpha encode alpha?
|
||||
* @param compression the PNG compression level (0-9).
|
||||
*
|
||||
* @return The byte array in PNG format.
|
||||
*
|
||||
* @throws IOException if there is an I/O problem.
|
||||
*/
|
||||
public static byte[] encodeAsPNG(BufferedImage image, boolean encodeAlpha,
|
||||
int compression)
|
||||
throws IOException {
|
||||
return EncoderUtil.encode(image, ImageFormat.PNG, compression,
|
||||
encodeAlpha);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an image map to an output stream.
|
||||
*
|
||||
* @param writer the writer (<code>null</code> not permitted).
|
||||
* @param name the map name (<code>null</code> not permitted).
|
||||
* @param info the chart rendering info (<code>null</code> not permitted).
|
||||
* @param useOverLibForToolTips whether to use OverLIB for tooltips
|
||||
* (http://www.bosrup.com/web/overlib/).
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void writeImageMap(PrintWriter writer,
|
||||
String name,
|
||||
ChartRenderingInfo info,
|
||||
boolean useOverLibForToolTips)
|
||||
throws IOException {
|
||||
|
||||
ToolTipTagFragmentGenerator toolTipTagFragmentGenerator = null;
|
||||
if (useOverLibForToolTips) {
|
||||
toolTipTagFragmentGenerator
|
||||
= new OverLIBToolTipTagFragmentGenerator();
|
||||
}
|
||||
else {
|
||||
toolTipTagFragmentGenerator
|
||||
= new StandardToolTipTagFragmentGenerator();
|
||||
}
|
||||
ImageMapUtilities.writeImageMap(writer, name, info,
|
||||
toolTipTagFragmentGenerator,
|
||||
new StandardURLTagFragmentGenerator());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an image map to the specified writer.
|
||||
*
|
||||
* @param writer the writer (<code>null</code> not permitted).
|
||||
* @param name the map name (<code>null</code> not permitted).
|
||||
* @param info the chart rendering info (<code>null</code> not permitted).
|
||||
* @param toolTipTagFragmentGenerator a generator for the HTML fragment
|
||||
* that will contain the tooltip text (<code>null</code> not permitted
|
||||
* if <code>info</code> contains tooltip information).
|
||||
* @param urlTagFragmentGenerator a generator for the HTML fragment that
|
||||
* will contain the URL reference (<code>null</code> not permitted if
|
||||
* <code>info</code> contains URLs).
|
||||
*
|
||||
* @throws IOException if there are any I/O errors.
|
||||
*/
|
||||
public static void writeImageMap(PrintWriter writer, String name,
|
||||
ChartRenderingInfo info,
|
||||
ToolTipTagFragmentGenerator toolTipTagFragmentGenerator,
|
||||
URLTagFragmentGenerator urlTagFragmentGenerator)
|
||||
throws IOException {
|
||||
|
||||
writer.println(ImageMapUtilities.getImageMap(name, info,
|
||||
toolTipTagFragmentGenerator, urlTagFragmentGenerator));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an HTML image map. This method maps to
|
||||
* {@link ImageMapUtilities#getImageMap(String, ChartRenderingInfo,
|
||||
* ToolTipTagFragmentGenerator, URLTagFragmentGenerator)}, using default
|
||||
* generators.
|
||||
*
|
||||
* @param name the map name (<code>null</code> not permitted).
|
||||
* @param info the chart rendering info (<code>null</code> not permitted).
|
||||
*
|
||||
* @return The map tag.
|
||||
*/
|
||||
public static String getImageMap(String name, ChartRenderingInfo info) {
|
||||
return ImageMapUtilities.getImageMap(name, info,
|
||||
new StandardToolTipTagFragmentGenerator(),
|
||||
new StandardURLTagFragmentGenerator());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an HTML image map. This method maps directly to
|
||||
* {@link ImageMapUtilities#getImageMap(String, ChartRenderingInfo,
|
||||
* ToolTipTagFragmentGenerator, URLTagFragmentGenerator)}.
|
||||
*
|
||||
* @param name the map name (<code>null</code> not permitted).
|
||||
* @param info the chart rendering info (<code>null</code> not permitted).
|
||||
* @param toolTipTagFragmentGenerator a generator for the HTML fragment
|
||||
* that will contain the tooltip text (<code>null</code> not permitted
|
||||
* if <code>info</code> contains tooltip information).
|
||||
* @param urlTagFragmentGenerator a generator for the HTML fragment that
|
||||
* will contain the URL reference (<code>null</code> not permitted if
|
||||
* <code>info</code> contains URLs).
|
||||
*
|
||||
* @return The map tag.
|
||||
*/
|
||||
public static String getImageMap(String name, ChartRenderingInfo info,
|
||||
ToolTipTagFragmentGenerator toolTipTagFragmentGenerator,
|
||||
URLTagFragmentGenerator urlTagFragmentGenerator) {
|
||||
|
||||
return ImageMapUtilities.getImageMap(name, info,
|
||||
toolTipTagFragmentGenerator, urlTagFragmentGenerator);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,439 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -------------
|
||||
* ClipPath.java
|
||||
* -------------
|
||||
* (C) Copyright 2003-2008, by David M. O'Donnell and Contributors.
|
||||
*
|
||||
* Original Author: David M. O'Donnell;
|
||||
* Contributor(s): David Gilbert (for Object Refinery Limited);
|
||||
* Nicolas Brodu;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 22-Apr-2003 : Added standard header (DG);
|
||||
* 09-May-2003 : Added AxisLocation (DG);
|
||||
* 11-Sep-2003 : Implemented Cloneable (NB);
|
||||
* 21-Jan-2004 : Update for renamed method in ValueAxis (DG);
|
||||
* ------------- JFREECHART 1.0.x ---------------------------------------------
|
||||
* 31-Jan-2007 : Deprecated (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Paint;
|
||||
import java.awt.Stroke;
|
||||
import java.awt.geom.GeneralPath;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import org.jfree.chart.axis.ValueAxis;
|
||||
import org.jfree.chart.plot.XYPlot;
|
||||
import org.jfree.chart.renderer.xy.XYBlockRenderer;
|
||||
import org.jfree.ui.RectangleEdge;
|
||||
|
||||
/**
|
||||
* This class would typically be used with a
|
||||
* {@link org.jfree.chart.plot.ContourPlot}. It allows the user to define a
|
||||
* <code>GeneralPath</code> curve in plot coordinates. This curve can then be
|
||||
* used mask off or define regions within the contour plot. The data must be
|
||||
* sorted.
|
||||
*
|
||||
* @deprecated This class is no longer supported (as of version 1.0.4). If
|
||||
* you are creating contour plots, please try to use {@link XYPlot} and
|
||||
* {@link XYBlockRenderer}.
|
||||
*/
|
||||
public class ClipPath implements Cloneable {
|
||||
|
||||
/** The x values. */
|
||||
private double[] xValue = null;
|
||||
|
||||
/** The y values. */
|
||||
private double[] yValue = null;
|
||||
|
||||
/** Controls whether drawing will be clipped (
|
||||
* false would still allow the drawing or filling of path */
|
||||
private boolean clip = true;
|
||||
|
||||
/** Controls whether the path is drawn as an outline. */
|
||||
private boolean drawPath = false;
|
||||
|
||||
/** Controls whether the path is filled. */
|
||||
private boolean fillPath = false;
|
||||
|
||||
/** The fill paint. */
|
||||
private Paint fillPaint = null;
|
||||
|
||||
/** The draw paint. */
|
||||
private Paint drawPaint = null;
|
||||
|
||||
/** The draw stroke. */
|
||||
private Stroke drawStroke = null;
|
||||
|
||||
/** The composite. */
|
||||
private Composite composite = null;
|
||||
|
||||
/**
|
||||
* Constructor for ClipPath.
|
||||
*/
|
||||
public ClipPath() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for ClipPath.
|
||||
* Default values are assumed for the fillPath and drawPath options as
|
||||
* false and true respectively. The fillPaint is set to Color.GRAY, the
|
||||
* drawColor is Color.BLUE, the stroke is BasicStroke(1)
|
||||
* and the composite is AlphaComposite.Src.
|
||||
*
|
||||
* @param xValue x coordinates of curved to be created
|
||||
* @param yValue y coordinates of curved to be created
|
||||
*/
|
||||
public ClipPath(double[] xValue, double[] yValue) {
|
||||
this(xValue, yValue, true, false, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for ClipPath.
|
||||
* The fillPaint is set to Color.GRAY, the drawColor is Color.BLUE, the
|
||||
* stroke is BasicStroke(1) and the composite is AlphaComposite.Src.
|
||||
*
|
||||
* @param xValue x coordinates of curved to be created
|
||||
* @param yValue y coordinates of curved to be created
|
||||
* @param clip clip?
|
||||
* @param fillPath whether the path is to filled
|
||||
* @param drawPath whether the path is to drawn as an outline
|
||||
*/
|
||||
public ClipPath(double[] xValue, double[] yValue,
|
||||
boolean clip, boolean fillPath, boolean drawPath) {
|
||||
this.xValue = xValue;
|
||||
this.yValue = yValue;
|
||||
|
||||
this.clip = clip;
|
||||
this.fillPath = fillPath;
|
||||
this.drawPath = drawPath;
|
||||
|
||||
this.fillPaint = java.awt.Color.gray;
|
||||
this.drawPaint = java.awt.Color.blue;
|
||||
this.drawStroke = new BasicStroke(1);
|
||||
this.composite = java.awt.AlphaComposite.Src;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for ClipPath.
|
||||
*
|
||||
* @param xValue x coordinates of curved to be created
|
||||
* @param yValue y coordinates of curved to be created
|
||||
* @param fillPath whether the path is to filled
|
||||
* @param drawPath whether the path is to drawn as an outline
|
||||
* @param fillPaint the fill paint
|
||||
* @param drawPaint the outline stroke color
|
||||
* @param drawStroke the stroke style
|
||||
* @param composite the composite rule
|
||||
*/
|
||||
public ClipPath(double[] xValue, double[] yValue, boolean fillPath,
|
||||
boolean drawPath, Paint fillPaint, Paint drawPaint,
|
||||
Stroke drawStroke, Composite composite) {
|
||||
|
||||
this.xValue = xValue;
|
||||
this.yValue = yValue;
|
||||
|
||||
this.fillPath = fillPath;
|
||||
this.drawPath = drawPath;
|
||||
|
||||
this.fillPaint = fillPaint;
|
||||
this.drawPaint = drawPaint;
|
||||
this.drawStroke = drawStroke;
|
||||
this.composite = composite;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the clip path.
|
||||
*
|
||||
* @param g2 current graphics2D.
|
||||
* @param dataArea the dataArea that the plot is being draw in.
|
||||
* @param horizontalAxis the horizontal axis.
|
||||
* @param verticalAxis the vertical axis.
|
||||
*
|
||||
* @return The GeneralPath defining the outline
|
||||
*/
|
||||
public GeneralPath draw(Graphics2D g2,
|
||||
Rectangle2D dataArea,
|
||||
ValueAxis horizontalAxis, ValueAxis verticalAxis) {
|
||||
|
||||
GeneralPath generalPath = generateClipPath(
|
||||
dataArea, horizontalAxis, verticalAxis
|
||||
);
|
||||
if (this.fillPath || this.drawPath) {
|
||||
Composite saveComposite = g2.getComposite();
|
||||
Paint savePaint = g2.getPaint();
|
||||
Stroke saveStroke = g2.getStroke();
|
||||
|
||||
if (this.fillPaint != null) {
|
||||
g2.setPaint(this.fillPaint);
|
||||
}
|
||||
if (this.composite != null) {
|
||||
g2.setComposite(this.composite);
|
||||
}
|
||||
if (this.fillPath) {
|
||||
g2.fill(generalPath);
|
||||
}
|
||||
|
||||
if (this.drawStroke != null) {
|
||||
g2.setStroke(this.drawStroke);
|
||||
}
|
||||
if (this.drawPath) {
|
||||
g2.draw(generalPath);
|
||||
}
|
||||
g2.setPaint(savePaint);
|
||||
g2.setComposite(saveComposite);
|
||||
g2.setStroke(saveStroke);
|
||||
}
|
||||
return generalPath;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the clip path.
|
||||
*
|
||||
* @param dataArea the dataArea that the plot is being draw in.
|
||||
* @param horizontalAxis the horizontal axis.
|
||||
* @param verticalAxis the vertical axis.
|
||||
*
|
||||
* @return The GeneralPath defining the outline
|
||||
*/
|
||||
public GeneralPath generateClipPath(Rectangle2D dataArea,
|
||||
ValueAxis horizontalAxis,
|
||||
ValueAxis verticalAxis) {
|
||||
|
||||
GeneralPath generalPath = new GeneralPath();
|
||||
double transX = horizontalAxis.valueToJava2D(
|
||||
this.xValue[0], dataArea, RectangleEdge.BOTTOM
|
||||
);
|
||||
double transY = verticalAxis.valueToJava2D(
|
||||
this.yValue[0], dataArea, RectangleEdge.LEFT
|
||||
);
|
||||
generalPath.moveTo((float) transX, (float) transY);
|
||||
for (int k = 0; k < this.yValue.length; k++) {
|
||||
transX = horizontalAxis.valueToJava2D(
|
||||
this.xValue[k], dataArea, RectangleEdge.BOTTOM
|
||||
);
|
||||
transY = verticalAxis.valueToJava2D(
|
||||
this.yValue[k], dataArea, RectangleEdge.LEFT
|
||||
);
|
||||
generalPath.lineTo((float) transX, (float) transY);
|
||||
}
|
||||
generalPath.closePath();
|
||||
|
||||
return generalPath;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the composite.
|
||||
*
|
||||
* @return Composite
|
||||
*/
|
||||
public Composite getComposite() {
|
||||
return this.composite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the drawPaint.
|
||||
*
|
||||
* @return Paint
|
||||
*/
|
||||
public Paint getDrawPaint() {
|
||||
return this.drawPaint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the drawPath.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isDrawPath() {
|
||||
return this.drawPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the drawStroke.
|
||||
*
|
||||
* @return Stroke
|
||||
*/
|
||||
public Stroke getDrawStroke() {
|
||||
return this.drawStroke;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the fillPaint.
|
||||
*
|
||||
* @return Paint
|
||||
*/
|
||||
public Paint getFillPaint() {
|
||||
return this.fillPaint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the fillPath.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isFillPath() {
|
||||
return this.fillPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the xValue.
|
||||
*
|
||||
* @return double[]
|
||||
*/
|
||||
public double[] getXValue() {
|
||||
return this.xValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the yValue.
|
||||
*
|
||||
* @return double[]
|
||||
*/
|
||||
public double[] getYValue() {
|
||||
return this.yValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the composite.
|
||||
*
|
||||
* @param composite The composite to set
|
||||
*/
|
||||
public void setComposite(Composite composite) {
|
||||
this.composite = composite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the drawPaint.
|
||||
*
|
||||
* @param drawPaint The drawPaint to set
|
||||
*/
|
||||
public void setDrawPaint(Paint drawPaint) {
|
||||
this.drawPaint = drawPaint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the drawPath.
|
||||
*
|
||||
* @param drawPath The drawPath to set
|
||||
*/
|
||||
public void setDrawPath(boolean drawPath) {
|
||||
this.drawPath = drawPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the drawStroke.
|
||||
*
|
||||
* @param drawStroke The drawStroke to set
|
||||
*/
|
||||
public void setDrawStroke(Stroke drawStroke) {
|
||||
this.drawStroke = drawStroke;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the fillPaint.
|
||||
*
|
||||
* @param fillPaint The fillPaint to set
|
||||
*/
|
||||
public void setFillPaint(Paint fillPaint) {
|
||||
this.fillPaint = fillPaint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the fillPath.
|
||||
*
|
||||
* @param fillPath The fillPath to set
|
||||
*/
|
||||
public void setFillPath(boolean fillPath) {
|
||||
this.fillPath = fillPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the xValue.
|
||||
*
|
||||
* @param xValue The xValue to set
|
||||
*/
|
||||
public void setXValue(double[] xValue) {
|
||||
this.xValue = xValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the yValue.
|
||||
*
|
||||
* @param yValue The yValue to set
|
||||
*/
|
||||
public void setYValue(double[] yValue) {
|
||||
this.yValue = yValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the clip.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isClip() {
|
||||
return this.clip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the clip.
|
||||
*
|
||||
* @param clip The clip to set
|
||||
*/
|
||||
public void setClip(boolean clip) {
|
||||
this.clip = clip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone of the object (a deeper clone than default to avoid bugs
|
||||
* when setting values in cloned object).
|
||||
*
|
||||
* @return The clone.
|
||||
*
|
||||
* @throws CloneNotSupportedException if cloning is not supported.
|
||||
*/
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
ClipPath clone = (ClipPath) super.clone();
|
||||
clone.xValue = (double[]) this.xValue.clone();
|
||||
clone.yValue = (double[]) this.yValue.clone();
|
||||
return clone;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,253 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -----------------------
|
||||
* DrawableLegendItem.java
|
||||
* -----------------------
|
||||
* (C) Copyright 2002-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): Luke Quinane;
|
||||
* Barak Naveh;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 07-Feb-2002 : Version 1 (DG);
|
||||
* 23-Sep-2002 : Renamed LegendItem --> DrawableLegendItem (DG);
|
||||
* 02-Oct-2002 : Fixed errors reported by Checkstyle (DG);
|
||||
* 08-Oct-2003 : Applied patch for displaying series line style, contributed by
|
||||
* Luke Quinane (DG);
|
||||
* 27-Mar-2004 : Added getMaxX() and getMaxY() methods (BN);
|
||||
* 27-Jan-2005 : Cleared out code that belongs in the LegendItem class (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.Line2D;
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
/**
|
||||
* This class contains a single legend item along with position details for
|
||||
* drawing the item on a particular chart.
|
||||
*
|
||||
* @deprecated This class is not used by JFreeChart.
|
||||
*/
|
||||
public class DrawableLegendItem {
|
||||
|
||||
/**
|
||||
* The legend item (encapsulates information about the label, color and
|
||||
* shape).
|
||||
*/
|
||||
private LegendItem item;
|
||||
|
||||
/** The x-coordinate for the item's location. */
|
||||
private double x;
|
||||
|
||||
/** The y-coordinate for the item's location. */
|
||||
private double y;
|
||||
|
||||
/** The width of the item. */
|
||||
private double width;
|
||||
|
||||
/** The height of the item. */
|
||||
private double height;
|
||||
|
||||
/** A shape used to indicate color on the legend. */
|
||||
private Shape marker;
|
||||
|
||||
/** A line used to indicate the series stroke on the legend */
|
||||
private Line2D line;
|
||||
|
||||
/** The label position within the item. */
|
||||
private Point2D labelPosition;
|
||||
|
||||
/**
|
||||
* Create a legend item.
|
||||
*
|
||||
* @param item the legend item for display.
|
||||
*/
|
||||
public DrawableLegendItem(LegendItem item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the legend item.
|
||||
*
|
||||
* @return The legend item.
|
||||
*/
|
||||
public LegendItem getItem() {
|
||||
return this.item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the x-coordinate for the item's location.
|
||||
*
|
||||
* @return The x-coordinate for the item's location.
|
||||
*/
|
||||
public double getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the x-coordinate for the item's location.
|
||||
*
|
||||
* @param x the x-coordinate.
|
||||
*/
|
||||
public void setX(double x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the y-coordinate for the item's location.
|
||||
*
|
||||
* @return The y-coordinate for the item's location.
|
||||
*/
|
||||
public double getY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the y-coordinate for the item's location.
|
||||
*
|
||||
* @param y the y-coordinate.
|
||||
*/
|
||||
public void setY(double y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the width of this item.
|
||||
*
|
||||
* @return The width.
|
||||
*/
|
||||
public double getWidth() {
|
||||
return this.width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the height of this item.
|
||||
*
|
||||
* @return The height.
|
||||
*/
|
||||
public double getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the largest X coordinate of the framing rectangle of this legend
|
||||
* item.
|
||||
*
|
||||
* @return The largest x coordinate of the framing rectangle of this legend
|
||||
* item.
|
||||
*/
|
||||
public double getMaxX() {
|
||||
return getX() + getWidth();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the largest Y coordinate of the framing rectangle of this legend
|
||||
* item.
|
||||
*
|
||||
* @return The largest Y coordinate of the framing rectangle of this legend
|
||||
* item.
|
||||
*/
|
||||
public double getMaxY() {
|
||||
return getY() + getHeight();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the marker.
|
||||
*
|
||||
* @return The shape used to indicate color on the legend for this item.
|
||||
*/
|
||||
public Shape getMarker() {
|
||||
return this.marker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the marker.
|
||||
*
|
||||
* @param marker a shape used to indicate color on the legend for this
|
||||
* item.
|
||||
*/
|
||||
public void setMarker(Shape marker) {
|
||||
this.marker = marker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the line used to label this series.
|
||||
*
|
||||
* @param l the new line to use.
|
||||
*/
|
||||
public void setLine(Line2D l) {
|
||||
this.line = l;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list.
|
||||
*
|
||||
* @return The line.
|
||||
*/
|
||||
public Line2D getLine() {
|
||||
return this.line;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the label position.
|
||||
*
|
||||
* @return The label position.
|
||||
*/
|
||||
public Point2D getLabelPosition() {
|
||||
return this.labelPosition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the label position.
|
||||
*
|
||||
* @param position the label position.
|
||||
*/
|
||||
public void setLabelPosition(Point2D position) {
|
||||
this.labelPosition = position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the bounds of this item.
|
||||
*
|
||||
* @param x x-coordinate for the item's location.
|
||||
* @param y y-coordinate for the item's location.
|
||||
* @param width the width of this item.
|
||||
* @param height the height of this item.
|
||||
*/
|
||||
public void setBounds(double x, double y, double width, double height) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -------------
|
||||
* Effect3D.java
|
||||
* -------------
|
||||
* (C) Copyright 2002-2008, by Object Refinery Limited.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 05-Nov-2002 : Version 1 (DG);
|
||||
* 14-Nov-2002 : Modified to have independent x and y offsets (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
/**
|
||||
* An interface that should be implemented by renderers that use a 3D effect.
|
||||
* This allows the axes to mirror the same effect by querying the renderer.
|
||||
*/
|
||||
public interface Effect3D {
|
||||
|
||||
/**
|
||||
* Returns the x-offset (in Java2D units) for the 3D effect.
|
||||
*
|
||||
* @return The offset.
|
||||
*/
|
||||
public double getXOffset();
|
||||
|
||||
/**
|
||||
* Returns the y-offset (in Java2D units) for the 3D effect.
|
||||
*
|
||||
* @return The offset.
|
||||
*/
|
||||
public double getYOffset();
|
||||
}
|
||||
@@ -1,347 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2007, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* ------------------
|
||||
* HashUtilities.java
|
||||
* ------------------
|
||||
* (C) Copyright 2006, 2007, by Object Refinery Limited;
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 03-Oct-2006 : Version 1 (DG);
|
||||
* 06-Mar-2007 : Fix for hashCodeForDoubleArray() method (DG);
|
||||
* 13-Nov-2007 : Added new utility methods (DG);
|
||||
* 22-Nov-2007 : Added hashCode() method for 'int' (DG);
|
||||
* 05-Dec-2007 : Added special methods to handle BooleanList, PaintList,
|
||||
* and StrokeList (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
import java.awt.GradientPaint;
|
||||
import java.awt.Paint;
|
||||
import java.awt.Stroke;
|
||||
|
||||
import org.jfree.util.BooleanList;
|
||||
import org.jfree.util.PaintList;
|
||||
import org.jfree.util.StrokeList;
|
||||
|
||||
/**
|
||||
* Some utility methods for calculating hash codes.
|
||||
*
|
||||
* @since 1.0.3
|
||||
*/
|
||||
public class HashUtilities {
|
||||
|
||||
/**
|
||||
* Returns a hash code for a <code>Paint</code> instance. If
|
||||
* <code>p</code> is <code>null</code>, this method returns zero.
|
||||
*
|
||||
* @param p the paint (<code>null</code> permitted).
|
||||
*
|
||||
* @return The hash code.
|
||||
*/
|
||||
public static int hashCodeForPaint(Paint p) {
|
||||
if (p == null) {
|
||||
return 0;
|
||||
}
|
||||
int result = 0;
|
||||
// handle GradientPaint as a special case
|
||||
if (p instanceof GradientPaint) {
|
||||
GradientPaint gp = (GradientPaint) p;
|
||||
result = 193;
|
||||
result = 37 * result + gp.getColor1().hashCode();
|
||||
result = 37 * result + gp.getPoint1().hashCode();
|
||||
result = 37 * result + gp.getColor2().hashCode();
|
||||
result = 37 * result + gp.getPoint2().hashCode();
|
||||
}
|
||||
else {
|
||||
// we assume that all other Paint instances implement equals() and
|
||||
// hashCode()...of course that might not be true, but what can we
|
||||
// do about it?
|
||||
result = p.hashCode();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for a <code>double[]</code> instance. If the array
|
||||
* is <code>null</code>, this method returns zero.
|
||||
*
|
||||
* @param a the array (<code>null</code> permitted).
|
||||
*
|
||||
* @return The hash code.
|
||||
*/
|
||||
public static int hashCodeForDoubleArray(double[] a) {
|
||||
if (a == null) {
|
||||
return 0;
|
||||
}
|
||||
int result = 193;
|
||||
long temp;
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
temp = Double.doubleToLongBits(a[i]);
|
||||
result = 29 * result + (int) (temp ^ (temp >>> 32));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash value based on a seed value and the value of a boolean
|
||||
* primitive.
|
||||
*
|
||||
* @param pre the seed value.
|
||||
* @param b the boolean value.
|
||||
*
|
||||
* @return A hash value.
|
||||
*
|
||||
* @since 1.0.7
|
||||
*/
|
||||
public static int hashCode(int pre, boolean b) {
|
||||
return 37 * pre + (b ? 0 : 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash value based on a seed value and the value of an int
|
||||
* primitive.
|
||||
*
|
||||
* @param pre the seed value.
|
||||
* @param i the int value.
|
||||
*
|
||||
* @return A hash value.
|
||||
*
|
||||
* @since 1.0.8
|
||||
*/
|
||||
public static int hashCode(int pre, int i) {
|
||||
return 37 * pre + i;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash value based on a seed value and the value of a double
|
||||
* primitive.
|
||||
*
|
||||
* @param pre the seed value.
|
||||
* @param d the double value.
|
||||
*
|
||||
* @return A hash value.
|
||||
*
|
||||
* @since 1.0.7
|
||||
*/
|
||||
public static int hashCode(int pre, double d) {
|
||||
long l = Double.doubleToLongBits(d);
|
||||
return 37 * pre + (int) (l ^ (l >>> 32));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash value based on a seed value and a paint instance.
|
||||
*
|
||||
* @param pre the seed value.
|
||||
* @param p the paint (<code>null</code> permitted).
|
||||
*
|
||||
* @return A hash value.
|
||||
*
|
||||
* @since 1.0.7
|
||||
*/
|
||||
public static int hashCode(int pre, Paint p) {
|
||||
return 37 * pre + hashCodeForPaint(p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash value based on a seed value and a stroke instance.
|
||||
*
|
||||
* @param pre the seed value.
|
||||
* @param s the stroke (<code>null</code> permitted).
|
||||
*
|
||||
* @return A hash value.
|
||||
*
|
||||
* @since 1.0.7
|
||||
*/
|
||||
public static int hashCode(int pre, Stroke s) {
|
||||
int h = (s != null ? s.hashCode() : 0);
|
||||
return 37 * pre + h;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash value based on a seed value and a string instance.
|
||||
*
|
||||
* @param pre the seed value.
|
||||
* @param s the string (<code>null</code> permitted).
|
||||
*
|
||||
* @return A hash value.
|
||||
*
|
||||
* @since 1.0.7
|
||||
*/
|
||||
public static int hashCode(int pre, String s) {
|
||||
int h = (s != null ? s.hashCode() : 0);
|
||||
return 37 * pre + h;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash value based on a seed value and a <code>Comparable</code>
|
||||
* instance.
|
||||
*
|
||||
* @param pre the seed value.
|
||||
* @param c the comparable (<code>null</code> permitted).
|
||||
*
|
||||
* @return A hash value.
|
||||
*
|
||||
* @since 1.0.7
|
||||
*/
|
||||
public static int hashCode(int pre, Comparable c) {
|
||||
int h = (c != null ? c.hashCode() : 0);
|
||||
return 37 * pre + h;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash value based on a seed value and an <code>Object</code>
|
||||
* instance.
|
||||
*
|
||||
* @param pre the seed value.
|
||||
* @param obj the object (<code>null</code> permitted).
|
||||
*
|
||||
* @return A hash value.
|
||||
*
|
||||
* @since 1.0.8
|
||||
*/
|
||||
public static int hashCode(int pre, Object obj) {
|
||||
int h = (obj != null ? obj.hashCode() : 0);
|
||||
return 37 * pre + h;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes a hash code for a {@link BooleanList}. In the latest version
|
||||
* of JCommon, the {@link BooleanList} class should implement the hashCode()
|
||||
* method correctly, but we compute it here anyway so that we can work with
|
||||
* older versions of JCommon (back to 1.0.0).
|
||||
*
|
||||
* @param pre the seed value.
|
||||
* @param list the list (<code>null</code> permitted).
|
||||
*
|
||||
* @return The hash code.
|
||||
*
|
||||
* @since 1.0.9
|
||||
*/
|
||||
public static int hashCode(int pre, BooleanList list) {
|
||||
if (list == null) {
|
||||
return pre;
|
||||
}
|
||||
int result = 127;
|
||||
int size = list.size();
|
||||
result = HashUtilities.hashCode(result, size);
|
||||
|
||||
// for efficiency, we just use the first, last and middle items to
|
||||
// compute a hashCode...
|
||||
if (size > 0) {
|
||||
result = HashUtilities.hashCode(result, list.getBoolean(0));
|
||||
if (size > 1) {
|
||||
result = HashUtilities.hashCode(result,
|
||||
list.getBoolean(size - 1));
|
||||
if (size > 2) {
|
||||
result = HashUtilities.hashCode(result,
|
||||
list.getBoolean(size / 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
return 37 * pre + result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes a hash code for a {@link PaintList}. In the latest version
|
||||
* of JCommon, the {@link PaintList} class should implement the hashCode()
|
||||
* method correctly, but we compute it here anyway so that we can work with
|
||||
* older versions of JCommon (back to 1.0.0).
|
||||
*
|
||||
* @param pre the seed value.
|
||||
* @param list the list (<code>null</code> permitted).
|
||||
*
|
||||
* @return The hash code.
|
||||
*
|
||||
* @since 1.0.9
|
||||
*/
|
||||
public static int hashCode(int pre, PaintList list) {
|
||||
if (list == null) {
|
||||
return pre;
|
||||
}
|
||||
int result = 127;
|
||||
int size = list.size();
|
||||
result = HashUtilities.hashCode(result, size);
|
||||
|
||||
// for efficiency, we just use the first, last and middle items to
|
||||
// compute a hashCode...
|
||||
if (size > 0) {
|
||||
result = HashUtilities.hashCode(result, list.getPaint(0));
|
||||
if (size > 1) {
|
||||
result = HashUtilities.hashCode(result,
|
||||
list.getPaint(size - 1));
|
||||
if (size > 2) {
|
||||
result = HashUtilities.hashCode(result,
|
||||
list.getPaint(size / 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
return 37 * pre + result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes a hash code for a {@link StrokeList}. In the latest version
|
||||
* of JCommon, the {@link StrokeList} class should implement the hashCode()
|
||||
* method correctly, but we compute it here anyway so that we can work with
|
||||
* older versions of JCommon (back to 1.0.0).
|
||||
*
|
||||
* @param pre the seed value.
|
||||
* @param list the list (<code>null</code> permitted).
|
||||
*
|
||||
* @return The hash code.
|
||||
*
|
||||
* @since 1.0.9
|
||||
*/
|
||||
public static int hashCode(int pre, StrokeList list) {
|
||||
if (list == null) {
|
||||
return pre;
|
||||
}
|
||||
int result = 127;
|
||||
int size = list.size();
|
||||
result = HashUtilities.hashCode(result, size);
|
||||
|
||||
// for efficiency, we just use the first, last and middle items to
|
||||
// compute a hashCode...
|
||||
if (size > 0) {
|
||||
result = HashUtilities.hashCode(result, list.getStroke(0));
|
||||
if (size > 1) {
|
||||
result = HashUtilities.hashCode(result,
|
||||
list.getStroke(size - 1));
|
||||
if (size > 2) {
|
||||
result = HashUtilities.hashCode(result,
|
||||
list.getStroke(size / 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
return 37 * pre + result;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,154 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -------------------------
|
||||
* LegendItemCollection.java
|
||||
* -------------------------
|
||||
* (C) Copyright 2002-2008, by Object Refinery Limited.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 07-Feb-2002 : Version 1 (DG);
|
||||
* 24-Sep-2002 : Added get(int) and getItemCount() methods (DG);
|
||||
* 02-Oct-2002 : Fixed errors reported by Checkstyle (DG);
|
||||
* 18-Apr-2005 : Added equals() method and implemented Cloneable and
|
||||
* Serializable (DG);
|
||||
* 23-Apr-2008 : Fixed clone() method (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.jfree.util.ObjectUtilities;
|
||||
|
||||
/**
|
||||
* A collection of legend items.
|
||||
*/
|
||||
public class LegendItemCollection implements Cloneable, Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
private static final long serialVersionUID = 1365215565589815953L;
|
||||
|
||||
/** Storage for the legend items. */
|
||||
private List items;
|
||||
|
||||
/**
|
||||
* Constructs a new legend item collection, initially empty.
|
||||
*/
|
||||
public LegendItemCollection() {
|
||||
this.items = new java.util.ArrayList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a legend item to the collection.
|
||||
*
|
||||
* @param item the item to add.
|
||||
*/
|
||||
public void add(LegendItem item) {
|
||||
this.items.add(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the legend items from another collection to this collection.
|
||||
*
|
||||
* @param collection the other collection.
|
||||
*/
|
||||
public void addAll(LegendItemCollection collection) {
|
||||
this.items.addAll(collection.items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a legend item from the collection.
|
||||
*
|
||||
* @param index the legend item index (zero-based).
|
||||
*
|
||||
* @return The legend item.
|
||||
*/
|
||||
public LegendItem get(int index) {
|
||||
return (LegendItem) this.items.get(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of legend items in the collection.
|
||||
*
|
||||
* @return The item count.
|
||||
*/
|
||||
public int getItemCount() {
|
||||
return this.items.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an iterator that provides access to all the legend items.
|
||||
*
|
||||
* @return An iterator.
|
||||
*/
|
||||
public Iterator iterator() {
|
||||
return this.items.iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this collection for equality with an arbitrary object.
|
||||
*
|
||||
* @param obj the object (<code>null</code> permitted).
|
||||
*
|
||||
* @return A boolean.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof LegendItemCollection)) {
|
||||
return false;
|
||||
}
|
||||
LegendItemCollection that = (LegendItemCollection) obj;
|
||||
if (!this.items.equals(that.items)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone of the collection.
|
||||
*
|
||||
* @return A clone.
|
||||
*
|
||||
* @throws CloneNotSupportedException if an item in the collection is not
|
||||
* cloneable.
|
||||
*/
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
LegendItemCollection clone = (LegendItemCollection) super.clone();
|
||||
clone.items = (List) ObjectUtilities.deepClone(this.items);
|
||||
return clone;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* ---------------------
|
||||
* LegendItemSource.java
|
||||
* ---------------------
|
||||
* (C) Copyright 2005-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 23-Feb-2005 : Version 1 (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
/**
|
||||
* A source of legend items. A {@link org.jfree.chart.title.LegendTitle} will
|
||||
* maintain a list of sources (often just one) from which it obtains legend
|
||||
* items.
|
||||
*/
|
||||
public interface LegendItemSource {
|
||||
|
||||
/**
|
||||
* Returns a (possibly empty) collection of legend items.
|
||||
*
|
||||
* @return The legend item collection (never <code>null</code>).
|
||||
*/
|
||||
public LegendItemCollection getLegendItems();
|
||||
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -------------------------
|
||||
* LegendRenderingOrder.java
|
||||
* -------------------------
|
||||
* (C) Copyright 2004-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: Angel;
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 26-Mar-2004 : Version 1 (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Represents the order for rendering legend items.
|
||||
*/
|
||||
public final class LegendRenderingOrder implements Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
private static final long serialVersionUID = -3832486612685808616L;
|
||||
|
||||
/** In order. */
|
||||
public static final LegendRenderingOrder STANDARD
|
||||
= new LegendRenderingOrder("LegendRenderingOrder.STANDARD");
|
||||
|
||||
/** In reverse order. */
|
||||
public static final LegendRenderingOrder REVERSE
|
||||
= new LegendRenderingOrder("LegendRenderingOrder.REVERSE");
|
||||
|
||||
/** The name. */
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* Private constructor.
|
||||
*
|
||||
* @param name the name.
|
||||
*/
|
||||
private LegendRenderingOrder(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representing the object.
|
||||
*
|
||||
* @return The string.
|
||||
*/
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if this object is equal to the specified
|
||||
* object, and <code>false</code> otherwise.
|
||||
*
|
||||
* @param obj the other object.
|
||||
*
|
||||
* @return A boolean.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof LegendRenderingOrder)) {
|
||||
return false;
|
||||
}
|
||||
LegendRenderingOrder order = (LegendRenderingOrder) obj;
|
||||
if (!this.name.equals(order.toString())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that serialization returns the unique instances.
|
||||
*
|
||||
* @return The object.
|
||||
*
|
||||
* @throws ObjectStreamException if there is a problem.
|
||||
*/
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
if (this.equals(LegendRenderingOrder.STANDARD)) {
|
||||
return LegendRenderingOrder.STANDARD;
|
||||
}
|
||||
else if (this.equals(LegendRenderingOrder.REVERSE)) {
|
||||
return LegendRenderingOrder.REVERSE;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
# org.jfree.chart.ChartPanel ResourceBundle properties file
|
||||
#
|
||||
# Changes (from 31-Aug-2003)
|
||||
# --------------------------
|
||||
# 31-Aug-2003 : Initial version (AL);
|
||||
#
|
||||
|
||||
Auto_Range=Auto Range
|
||||
All_Axes=Both Axes
|
||||
Chart_Properties=Chart Properties
|
||||
Copy=Copy
|
||||
Domain_Axis=Domain Axis
|
||||
PNG_Image_Files=PNG Image Files
|
||||
Print...=Print...
|
||||
Properties...=Properties...
|
||||
Save_as...=Save as...
|
||||
Range_Axis=Range Axis
|
||||
Zoom_In=Zoom In
|
||||
Zoom_Out=Zoom Out
|
||||
@@ -1,20 +0,0 @@
|
||||
# org.jfree.chart.ChartPanel ResourceBundle properties file - german version
|
||||
#
|
||||
# Changes (from 31-Aug-2003)
|
||||
# --------------------------
|
||||
# 31-Aug-2003 : Initial version (AL);
|
||||
# 15-Mar-2004 : Revised version (Christian W. Zuckschwerdt);
|
||||
#
|
||||
|
||||
Auto_Range=Autojustage
|
||||
All_Axes=Beide Achsen
|
||||
Chart_Properties=Diagramm-Eigenschaften
|
||||
Copy=Kopieren
|
||||
Domain_Axis=Horizontale Achse
|
||||
PNG_Image_Files=PNG Datei (Portable Network Graphics) (*.png)
|
||||
Print...=Drucken...
|
||||
Properties...=Eigenschaften...
|
||||
Save_as...=Speichern unter...
|
||||
Range_Axis=Vertikale Achse
|
||||
Zoom_In=Hineinzoomen
|
||||
Zoom_Out=Herauszoomen
|
||||
@@ -1,19 +0,0 @@
|
||||
# org.jfree.chart.ChartPanel ResourceBundle properties file - spanish version
|
||||
#
|
||||
# Changes (from 16-Dec-2003)
|
||||
# --------------------------
|
||||
# 16-Dec-2003 : Initial Version: Complejo Hospitalario Universitario Juan Canalejo
|
||||
#
|
||||
|
||||
Auto_Range=Escala autom\u00E1tica
|
||||
All_Axes=Todos los ejes
|
||||
Chart_Properties=Propiedades del gr\u00E1fico
|
||||
Copy=Copiar
|
||||
Domain_Axis=Eje horizontal
|
||||
PNG_Image_Files=Formato PNG (Portable Network Graphics) (*.png)
|
||||
Print...=Imprimir...
|
||||
Properties...=Propiedades...
|
||||
Save_as...=Grabar como...
|
||||
Range_Axis=Eje vertical
|
||||
Zoom_In=Acercar
|
||||
Zoom_Out=Alejar
|
||||
@@ -1,19 +0,0 @@
|
||||
# org.jfree.chart.ChartPanel ResourceBundle properties file - french version
|
||||
#
|
||||
# Changes (from 31-Aug-2003)
|
||||
# --------------------------
|
||||
# 31-Aug-2003 : Initial version (AL);
|
||||
#
|
||||
|
||||
Auto_Range=Echelle automatique
|
||||
All_Axes=Les deux axes
|
||||
Chart_Properties=Propri\u00E9t\u00E9s du graphique
|
||||
Copy=Copier
|
||||
Domain_Axis=Axe horizontal
|
||||
PNG_Image_Files=Format PNG (Portable Network Graphics) (*.png)
|
||||
Print...=Imprimer...
|
||||
Properties...=Propri\u00E9t\u00E9s...
|
||||
Save_as...=Enregistrer sous...
|
||||
Range_Axis=Axe vertical
|
||||
Zoom_In=Zoom avant
|
||||
Zoom_Out=Zoom arri\u00E8re
|
||||
@@ -1,13 +0,0 @@
|
||||
# org.jfree.chart.ChartPanel ResourceBundle properties file - italian version
|
||||
Auto_Range=Dimensiona Automaticamente
|
||||
All_Axes=Entrambi gli Assi
|
||||
Chart_Properties=Propriet\u00E0 del Grafico
|
||||
Copy=Copia
|
||||
Domain_Axis=Asse Orizzontale
|
||||
PNG_Image_Files=Immagine PNG
|
||||
Print...=Stampa...
|
||||
Properties...=Propriet\u00E0...
|
||||
Save_as...=Salva Come...
|
||||
Range_Axis=Asse Verticale
|
||||
Zoom_In=Ingrandisci
|
||||
Zoom_Out=Rimpicciolisci
|
||||
@@ -1,20 +0,0 @@
|
||||
# org.jfree.chart.ChartPanel ResourceBundle properties file
|
||||
#
|
||||
# Changes (from 31-Aug-2003)
|
||||
# --------------------------
|
||||
# 24-Mar-2003 : Translated into Dutch
|
||||
# 31-Aug-2003 : Initial version (AL);
|
||||
#
|
||||
|
||||
Auto_Range=Automatisch bereik
|
||||
All_Axes=Beide assen
|
||||
Chart_Properties=Eigenschappen
|
||||
Copy=Kopie\u00EBren
|
||||
Domain_Axis=Horizontale As
|
||||
PNG_Image_Files=PNG afbeelding
|
||||
Print...=Afdrukken...
|
||||
Properties...=Eigenschappen...
|
||||
Save_as...=Opslaan als...
|
||||
Range_Axis=Verticale As
|
||||
Zoom_In=Inzoomen
|
||||
Zoom_Out=Uitzoomen
|
||||
@@ -1,19 +0,0 @@
|
||||
# org.jfree.chart.ChartPanel ResourceBundle properties file
|
||||
#
|
||||
# Changes (from 15-Mar-2004)
|
||||
# --------------------------
|
||||
# 15-Mar-2004 : Initial version (Kuba Duda);
|
||||
#
|
||||
|
||||
Auto_Range=Automatyczny zakres
|
||||
All_Axes=Obie osie
|
||||
Chart_Properties=W\u0142a\u015bciwo\u015bci wykresu
|
||||
Copy=Kopiuj
|
||||
Domain_Axis=O\u015b pozioma
|
||||
PNG_Image_Files=Pliki graficzne PNG
|
||||
Print...=Drukuj...
|
||||
Properties...=W\u0142a\u015bciwo\u015bci...
|
||||
Save_as...=Zapisz jako...
|
||||
Range_Axis=O\u015b pionowa
|
||||
Zoom_In=Powi\u0119ksz
|
||||
Zoom_Out=Pomniejsz
|
||||
@@ -1,19 +0,0 @@
|
||||
# org.jfree.chart.ChartPanel ResourceBundle properties file - portuguese version
|
||||
#
|
||||
# Changes (from 24-May-2007)
|
||||
# --------------------------
|
||||
# 24-May-2007 : Initial version (Leonardo Alves Machado);
|
||||
#
|
||||
|
||||
Auto_Range=Escala autom\u00E1tica
|
||||
All_Axes=Todos os eixos
|
||||
Chart_Properties=Propriedades do gr\u00E1fico
|
||||
Copy=Copiar
|
||||
Domain_Axis=Eixo horizontal
|
||||
PNG_Image_Files=Formato PNG (Portable Network Graphics) (*.png)
|
||||
Print...=Imprimir...
|
||||
Properties...=Propriedades...
|
||||
Save_as...=Salvar como...
|
||||
Range_Axis=Eixo vertical
|
||||
Zoom_In=Ampliar
|
||||
Zoom_Out=Reduzir
|
||||
@@ -1,19 +0,0 @@
|
||||
# org.jfree.chart.ChartPanel ResourceBundle properties file - portuguese version
|
||||
#
|
||||
# Changes (from 09-Set-2003)
|
||||
# --------------------------
|
||||
# 09-Set-2003 : Initial version (ER);
|
||||
#
|
||||
|
||||
Auto_Range=Escala autom\u00E1tica
|
||||
All_Axes=Todos os eixos
|
||||
Chart_Properties=Propriedades do gr\u00E1fico
|
||||
Copy=Copiar
|
||||
Domain_Axis=Eixo horizontal
|
||||
PNG_Image_Files=Formato PNG (Portable Network Graphics) (*.png)
|
||||
Print...=Imprimir...
|
||||
Properties...=Propriedades...
|
||||
Save_as...=Gravar como...
|
||||
Range_Axis=Eixo vertical
|
||||
Zoom_In=Aproximar
|
||||
Zoom_Out=Afastar
|
||||
@@ -1,19 +0,0 @@
|
||||
# org.jfree.chart.ChartPanel ResourceBundle properties file
|
||||
#
|
||||
# Changes (from 10-Nov-2003)
|
||||
# --------------------------
|
||||
# 10-Nov-2003 : Initial version (AL);
|
||||
#
|
||||
|
||||
Auto_Range=\u0410\u0432\u0442\u043e\u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435
|
||||
All_Axes=\u041f\u043e \u0432\u0441\u0435\u043c \u043e\u0441\u044f\u043c
|
||||
Chart_Properties=\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u0430
|
||||
Copy=\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c
|
||||
Domain_Axis=\u041f\u043e \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u0441\u0438
|
||||
PNG_Image_Files=PNG \u0444\u0430\u0439\u043b
|
||||
Print...=\u041f\u0435\u0447\u0430\u0442\u044c...
|
||||
Properties...=\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438...
|
||||
Save_as...=\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u0430\u043a...
|
||||
Range_Axis=\u041f\u043e \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u0441\u0438
|
||||
Zoom_In=\u041f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u0442\u044c
|
||||
Zoom_Out=\u041e\u0442\u0434\u0430\u043b\u0438\u0442\u044c
|
||||
@@ -1,19 +0,0 @@
|
||||
# org.jfree.chart.ChartPanel ResourceBundle properties file
|
||||
#
|
||||
# Changes
|
||||
# -------
|
||||
# 29-Jun-2005 : Initial version, see: http://www.jfree.org/phpBB2/viewtopic.php?t=13495;
|
||||
#
|
||||
|
||||
Auto_Range=\u81ea\u52a8\u8c03\u6574
|
||||
All_Axes=\u6240\u6709\u8f74
|
||||
Chart_Properties=\u56fe\u8868\u5c5e\u6027
|
||||
Copy=\u590d\u5236
|
||||
Domain_Axis=\u6c34\u5e73\u8f74
|
||||
PNG_Image_Files=PNG \u683c\u5f0f\u7684\u56fe\u50cf
|
||||
Print...=\u6253\u5370
|
||||
Properties...=\u5c5e\u6027
|
||||
Save_as...=\u53e6\u5b58\u4e3a
|
||||
Range_Axis=\u5782\u76f4\u8f74
|
||||
Zoom_In=\u653e\u5927
|
||||
Zoom_Out=\u7f29\u5c0f
|
||||
@@ -1,19 +0,0 @@
|
||||
# org.jfree.chart.ChartPanel ResourceBundle properties file
|
||||
#
|
||||
# Changes (from 31-Aug-2003)
|
||||
# --------------------------
|
||||
# 31-Aug-2003 : Initial version (AL);
|
||||
#
|
||||
|
||||
Auto_Range=\u81ea\u52d5\u8abf\u6574
|
||||
All_Axes=\u6240\u6709\u8ef8
|
||||
Chart_Properties=\u5716\u8868\u5167\u5bb9
|
||||
Copy=\u8907\u88fd
|
||||
Domain_Axis=\u6a6b\u8ef8
|
||||
PNG_Image_Files=PNG\u5716\u6a94
|
||||
Print...=\u5217\u5370
|
||||
Properties...=\u5167\u5bb9
|
||||
Save_as...=\u53e6\u5b58\u65b0\u6a94
|
||||
Range_Axis=\u7e31\u8ef8
|
||||
Zoom_In=\u653e\u5927
|
||||
Zoom_Out=\u7e2e\u5c0f
|
||||
@@ -1,222 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -------------
|
||||
* PaintMap.java
|
||||
* -------------
|
||||
* (C) Copyright 2006-2015, by Object Refinery Limited.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes:
|
||||
* --------
|
||||
* 27-Sep-2006 : Version 1 (DG);
|
||||
* 17-Jan-2007 : Changed TreeMap to HashMap, so that different classes that
|
||||
* implement Comparable can be used as keys (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
import java.awt.Paint;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jfree.io.SerialUtilities;
|
||||
import org.jfree.util.PaintUtilities;
|
||||
|
||||
/**
|
||||
* A storage structure that maps <code>Comparable</code> instances with
|
||||
* <code>Paint</code> instances.
|
||||
* <br><br>
|
||||
* To support cloning and serialization, you should only use keys that are
|
||||
* cloneable and serializable. Special handling for the <code>Paint</code>
|
||||
* instances is included in this class.
|
||||
*
|
||||
* @since 1.0.3
|
||||
*/
|
||||
public class PaintMap implements Cloneable, Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
static final long serialVersionUID = -4639833772123069274L;
|
||||
|
||||
/** Storage for the keys and values. */
|
||||
private transient Map store;
|
||||
|
||||
/**
|
||||
* Creates a new (empty) map.
|
||||
*/
|
||||
public PaintMap() {
|
||||
this.store = new HashMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the paint associated with the specified key, or
|
||||
* <code>null</code>.
|
||||
*
|
||||
* @param key the key (<code>null</code> not permitted).
|
||||
*
|
||||
* @return The paint, or <code>null</code>.
|
||||
*
|
||||
* @throws IllegalArgumentException if <code>key</code> is
|
||||
* <code>null</code>.
|
||||
*/
|
||||
public Paint getPaint(Comparable key) {
|
||||
if (key == null) {
|
||||
throw new IllegalArgumentException("Null 'key' argument.");
|
||||
}
|
||||
return (Paint) this.store.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if the map contains the specified key, and
|
||||
* <code>false</code> otherwise.
|
||||
*
|
||||
* @param key the key.
|
||||
*
|
||||
* @return <code>true</code> if the map contains the specified key, and
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
public boolean containsKey(Comparable key) {
|
||||
return this.store.containsKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a mapping between the specified <code>key</code> and
|
||||
* <code>paint</code> values.
|
||||
*
|
||||
* @param key the key (<code>null</code> not permitted).
|
||||
* @param paint the paint.
|
||||
*
|
||||
* @throws IllegalArgumentException if <code>key</code> is
|
||||
* <code>null</code>.
|
||||
*/
|
||||
public void put(Comparable key, Paint paint) {
|
||||
if (key == null) {
|
||||
throw new IllegalArgumentException("Null 'key' argument.");
|
||||
}
|
||||
this.store.put(key, paint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the map to empty.
|
||||
*/
|
||||
public void clear() {
|
||||
this.store.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this map for equality with an arbitrary object.
|
||||
*
|
||||
* @param obj the object (<code>null</code> permitted).
|
||||
*
|
||||
* @return A boolean.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof PaintMap)) {
|
||||
return false;
|
||||
}
|
||||
PaintMap that = (PaintMap) obj;
|
||||
if (this.store.size() != that.store.size()) {
|
||||
return false;
|
||||
}
|
||||
Set keys = this.store.keySet();
|
||||
Iterator iterator = keys.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Comparable key = (Comparable) iterator.next();
|
||||
Paint p1 = getPaint(key);
|
||||
Paint p2 = that.getPaint(key);
|
||||
if (!PaintUtilities.equal(p1, p2)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone of this <code>PaintMap</code>.
|
||||
*
|
||||
* @return A clone of this instance.
|
||||
*
|
||||
* @throws CloneNotSupportedException if any key is not cloneable.
|
||||
*/
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
// TODO: I think we need to make sure the keys are actually cloned,
|
||||
// whereas the paint instances are always immutable so they're OK
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the output stream.
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
*/
|
||||
private void writeObject(ObjectOutputStream stream) throws IOException {
|
||||
stream.defaultWriteObject();
|
||||
stream.writeInt(this.store.size());
|
||||
Set keys = this.store.keySet();
|
||||
Iterator iterator = keys.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Comparable key = (Comparable) iterator.next();
|
||||
stream.writeObject(key);
|
||||
Paint paint = getPaint(key);
|
||||
SerialUtilities.writePaint(paint, stream);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the input stream.
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
* @throws ClassNotFoundException if there is a classpath problem.
|
||||
*/
|
||||
private void readObject(ObjectInputStream stream)
|
||||
throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
this.store = new HashMap();
|
||||
int keyCount = stream.readInt();
|
||||
for (int i = 0; i < keyCount; i++) {
|
||||
Comparable key = (Comparable) stream.readObject();
|
||||
Paint paint = SerialUtilities.readPaint(stream);
|
||||
this.store.put(key, paint);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,254 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* --------------------
|
||||
* PolarChartPanel.java
|
||||
* --------------------
|
||||
* (C) Copyright 2004-2008, by Solution Engineering, Inc. and Contributors.
|
||||
*
|
||||
* Original Author: Daniel Bridenbecker, Solution Engineering, Inc.;
|
||||
* Contributor(s): David Gilbert (for Object Refinery Limited);
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 19-Jan-2004 : Version 1, contributed by DB with minor changes by DG (DG);
|
||||
* ------------- JFREECHART 1.0.x ---------------------------------------------
|
||||
* 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPopupMenu;
|
||||
|
||||
import org.jfree.chart.plot.Plot;
|
||||
import org.jfree.chart.plot.PolarPlot;
|
||||
|
||||
/**
|
||||
* <code>PolarChartPanel</code> is the top level object for using the
|
||||
* {@link PolarPlot}. Since this class has a <code>JPanel</code> in the
|
||||
* inheritance hierarchy, one uses this class to integrate the Polar plot into
|
||||
* their application.
|
||||
* <p>
|
||||
* The main modification to <code>ChartPanel</code> is the popup menu. It
|
||||
* removes <code>ChartPanel</code>'s versions of:
|
||||
* <ul>
|
||||
* <li><code>Zoom In</code></li>
|
||||
* <li><code>Zoom Out</code></li>
|
||||
* <li><code>Auto Range</code></li>
|
||||
* </ul>
|
||||
* and replaces them with versions more appropriate for {@link PolarPlot}.
|
||||
*/
|
||||
public class PolarChartPanel extends ChartPanel {
|
||||
|
||||
// -----------------
|
||||
// --- Constants ---
|
||||
// -----------------
|
||||
|
||||
/** Zoom in command string. */
|
||||
private static final String POLAR_ZOOM_IN_ACTION_COMMAND = "Polar Zoom In";
|
||||
|
||||
/** Zoom out command string. */
|
||||
private static final String POLAR_ZOOM_OUT_ACTION_COMMAND
|
||||
= "Polar Zoom Out";
|
||||
|
||||
/** Auto range command string. */
|
||||
private static final String POLAR_AUTO_RANGE_ACTION_COMMAND
|
||||
= "Polar Auto Range";
|
||||
|
||||
// ------------------------
|
||||
// --- Member Variables ---
|
||||
// ------------------------
|
||||
|
||||
// --------------------
|
||||
// --- Constructors ---
|
||||
// --------------------
|
||||
/**
|
||||
* Constructs a JFreeChart panel.
|
||||
*
|
||||
* @param chart the chart.
|
||||
*/
|
||||
public PolarChartPanel(JFreeChart chart) {
|
||||
this(chart, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new panel.
|
||||
*
|
||||
* @param chart the chart.
|
||||
* @param useBuffer buffered?
|
||||
*/
|
||||
public PolarChartPanel(JFreeChart chart, boolean useBuffer) {
|
||||
super(chart, useBuffer);
|
||||
checkChart(chart);
|
||||
setMinimumDrawWidth(200);
|
||||
setMinimumDrawHeight(200);
|
||||
setMaximumDrawWidth(2000);
|
||||
setMaximumDrawHeight(2000);
|
||||
}
|
||||
|
||||
// --------------------------
|
||||
// --- ChartPanel Methods ---
|
||||
// --------------------------
|
||||
/**
|
||||
* Sets the chart that is displayed in the panel.
|
||||
*
|
||||
* @param chart The chart.
|
||||
*/
|
||||
public void setChart(JFreeChart chart) {
|
||||
checkChart(chart);
|
||||
super.setChart(chart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a popup menu for the panel.
|
||||
*
|
||||
* @param properties include a menu item for the chart property editor.
|
||||
* @param save include a menu item for saving the chart.
|
||||
* @param print include a menu item for printing the chart.
|
||||
* @param zoom include menu items for zooming.
|
||||
*
|
||||
* @return The popup menu.
|
||||
*/
|
||||
protected JPopupMenu createPopupMenu(boolean properties,
|
||||
boolean save,
|
||||
boolean print,
|
||||
boolean zoom) {
|
||||
|
||||
JPopupMenu result = super.createPopupMenu(properties, save, print, zoom);
|
||||
int zoomInIndex = getPopupMenuItem(result, "Zoom In");
|
||||
int zoomOutIndex = getPopupMenuItem(result, "Zoom Out");
|
||||
int autoIndex = getPopupMenuItem(result, "Auto Range");
|
||||
if (zoom) {
|
||||
JMenuItem zoomIn = new JMenuItem("Zoom In");
|
||||
zoomIn.setActionCommand(POLAR_ZOOM_IN_ACTION_COMMAND);
|
||||
zoomIn.addActionListener(this);
|
||||
|
||||
JMenuItem zoomOut = new JMenuItem("Zoom Out");
|
||||
zoomOut.setActionCommand(POLAR_ZOOM_OUT_ACTION_COMMAND);
|
||||
zoomOut.addActionListener(this);
|
||||
|
||||
JMenuItem auto = new JMenuItem("Auto Range");
|
||||
auto.setActionCommand(POLAR_AUTO_RANGE_ACTION_COMMAND);
|
||||
auto.addActionListener(this);
|
||||
|
||||
if (zoomInIndex != -1) {
|
||||
result.remove(zoomInIndex);
|
||||
}
|
||||
else {
|
||||
zoomInIndex = result.getComponentCount() - 1;
|
||||
}
|
||||
result.add(zoomIn, zoomInIndex);
|
||||
if (zoomOutIndex != -1) {
|
||||
result.remove(zoomOutIndex);
|
||||
}
|
||||
else {
|
||||
zoomOutIndex = zoomInIndex + 1;
|
||||
}
|
||||
result.add(zoomOut, zoomOutIndex);
|
||||
if (autoIndex != -1) {
|
||||
result.remove(autoIndex);
|
||||
}
|
||||
else {
|
||||
autoIndex = zoomOutIndex + 1;
|
||||
}
|
||||
result.add(auto, autoIndex);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles action events generated by the popup menu.
|
||||
*
|
||||
* @param event the event.
|
||||
*/
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
String command = event.getActionCommand();
|
||||
|
||||
if (command.equals(POLAR_ZOOM_IN_ACTION_COMMAND)) {
|
||||
PolarPlot plot = (PolarPlot) getChart().getPlot();
|
||||
plot.zoom(0.5);
|
||||
}
|
||||
else if (command.equals(POLAR_ZOOM_OUT_ACTION_COMMAND)) {
|
||||
PolarPlot plot = (PolarPlot) getChart().getPlot();
|
||||
plot.zoom(2.0);
|
||||
}
|
||||
else if (command.equals(POLAR_AUTO_RANGE_ACTION_COMMAND)) {
|
||||
PolarPlot plot = (PolarPlot) getChart().getPlot();
|
||||
plot.getAxis().setAutoRange(true);
|
||||
}
|
||||
else {
|
||||
super.actionPerformed(event);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------
|
||||
// --- Public Methods ---
|
||||
// ----------------------
|
||||
|
||||
// -----------------------
|
||||
// --- Private Methods ---
|
||||
// -----------------------
|
||||
|
||||
/**
|
||||
* Test that the chart is using an xy plot with time as the domain axis.
|
||||
*
|
||||
* @param chart the chart.
|
||||
*/
|
||||
private void checkChart(JFreeChart chart) {
|
||||
Plot plot = chart.getPlot();
|
||||
if (!(plot instanceof PolarPlot)) {
|
||||
throw new IllegalArgumentException("plot is not a PolarPlot");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of an item in a popup menu.
|
||||
*
|
||||
* @param menu the menu.
|
||||
* @param text the label.
|
||||
*
|
||||
* @return The item index.
|
||||
*/
|
||||
private int getPopupMenuItem(JPopupMenu menu, String text) {
|
||||
int index = -1;
|
||||
for (int i = 0; (index == -1) && (i < menu.getComponentCount()); i++) {
|
||||
Component comp = menu.getComponent(i);
|
||||
if (comp instanceof JMenuItem) {
|
||||
JMenuItem item = (JMenuItem) comp;
|
||||
if (text.equals(item.getText())) {
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,217 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* --------------
|
||||
* StrokeMap.java
|
||||
* --------------
|
||||
* (C) Copyright 2006-2015, by Object Refinery Limited.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes:
|
||||
* --------
|
||||
* 27-Sep-2006 : Version 1 (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart;
|
||||
|
||||
import java.awt.Stroke;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.jfree.io.SerialUtilities;
|
||||
import org.jfree.util.ObjectUtilities;
|
||||
|
||||
/**
|
||||
* A storage structure that maps <code>Comparable</code> instances with
|
||||
* <code>Stroke</code> instances.
|
||||
* <br><br>
|
||||
* To support cloning and serialization, you should only use keys that are
|
||||
* cloneable and serializable. Special handling for the <code>Stroke</code>
|
||||
* instances is included in this class.
|
||||
*
|
||||
* @since 1.0.3
|
||||
*/
|
||||
public class StrokeMap implements Cloneable, Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
static final long serialVersionUID = -8148916785963525169L;
|
||||
|
||||
/** Storage for the keys and values. */
|
||||
private transient Map store;
|
||||
|
||||
/**
|
||||
* Creates a new (empty) map.
|
||||
*/
|
||||
public StrokeMap() {
|
||||
this.store = new TreeMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the stroke associated with the specified key, or
|
||||
* <code>null</code>.
|
||||
*
|
||||
* @param key the key (<code>null</code> not permitted).
|
||||
*
|
||||
* @return The stroke, or <code>null</code>.
|
||||
*
|
||||
* @throws IllegalArgumentException if <code>key</code> is
|
||||
* <code>null</code>.
|
||||
*/
|
||||
public Stroke getStroke(Comparable key) {
|
||||
if (key == null) {
|
||||
throw new IllegalArgumentException("Null 'key' argument.");
|
||||
}
|
||||
return (Stroke) this.store.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if the map contains the specified key, and
|
||||
* <code>false</code> otherwise.
|
||||
*
|
||||
* @param key the key.
|
||||
*
|
||||
* @return <code>true</code> if the map contains the specified key, and
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
public boolean containsKey(Comparable key) {
|
||||
return this.store.containsKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a mapping between the specified <code>key</code> and
|
||||
* <code>stroke</code> values.
|
||||
*
|
||||
* @param key the key (<code>null</code> not permitted).
|
||||
* @param stroke the stroke.
|
||||
*/
|
||||
public void put(Comparable key, Stroke stroke) {
|
||||
if (key == null) {
|
||||
throw new IllegalArgumentException("Null 'key' argument.");
|
||||
}
|
||||
this.store.put(key, stroke);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the map to empty.
|
||||
*/
|
||||
public void clear() {
|
||||
this.store.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this map for equality with an arbitrary object.
|
||||
*
|
||||
* @param obj the object (<code>null</code> permitted).
|
||||
*
|
||||
* @return A boolean.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof StrokeMap)) {
|
||||
return false;
|
||||
}
|
||||
StrokeMap that = (StrokeMap) obj;
|
||||
if (this.store.size() != that.store.size()) {
|
||||
return false;
|
||||
}
|
||||
Set keys = this.store.keySet();
|
||||
Iterator iterator = keys.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Comparable key = (Comparable) iterator.next();
|
||||
Stroke s1 = getStroke(key);
|
||||
Stroke s2 = that.getStroke(key);
|
||||
if (!ObjectUtilities.equal(s1, s2)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone of this <code>StrokeMap</code>.
|
||||
*
|
||||
* @return A clone of this instance.
|
||||
*
|
||||
* @throws CloneNotSupportedException if any key is not cloneable.
|
||||
*/
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
// TODO: I think we need to make sure the keys are actually cloned,
|
||||
// whereas the stroke instances are always immutable so they're OK
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the output stream.
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
*/
|
||||
private void writeObject(ObjectOutputStream stream) throws IOException {
|
||||
stream.defaultWriteObject();
|
||||
stream.writeInt(this.store.size());
|
||||
Set keys = this.store.keySet();
|
||||
Iterator iterator = keys.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Comparable key = (Comparable) iterator.next();
|
||||
stream.writeObject(key);
|
||||
Stroke stroke = getStroke(key);
|
||||
SerialUtilities.writeStroke(stroke, stream);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the input stream.
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
* @throws ClassNotFoundException if there is a classpath problem.
|
||||
*/
|
||||
private void readObject(ObjectInputStream stream)
|
||||
throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
this.store = new TreeMap();
|
||||
int keyCount = stream.readInt();
|
||||
for (int i = 0; i < keyCount; i++) {
|
||||
Comparable key = (Comparable) stream.readObject();
|
||||
Stroke stroke = SerialUtilities.readStroke(stream);
|
||||
this.store.put(key, stroke);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,205 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -------------------------
|
||||
* AbstractXYAnnotation.java
|
||||
* -------------------------
|
||||
* (C) Copyright 2004-2008, by Object Refinery Limited.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes:
|
||||
* --------
|
||||
* 29-Sep-2004 : Version 1 (DG);
|
||||
* ------------- JFREECHART 1.0.x ---------------------------------------------
|
||||
* 06-Mar-2007 : Implemented hashCode() (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.annotations;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import org.jfree.chart.axis.ValueAxis;
|
||||
import org.jfree.chart.entity.EntityCollection;
|
||||
import org.jfree.chart.entity.XYAnnotationEntity;
|
||||
import org.jfree.chart.plot.PlotRenderingInfo;
|
||||
import org.jfree.chart.plot.XYPlot;
|
||||
import org.jfree.util.ObjectUtilities;
|
||||
|
||||
/**
|
||||
* The interface that must be supported by annotations that are to be added to
|
||||
* an {@link XYPlot}.
|
||||
*/
|
||||
public abstract class AbstractXYAnnotation implements XYAnnotation {
|
||||
|
||||
/** The tool tip text. */
|
||||
private String toolTipText;
|
||||
|
||||
/** The URL. */
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* Creates a new instance that has no tool tip or URL specified.
|
||||
*/
|
||||
protected AbstractXYAnnotation() {
|
||||
this.toolTipText = null;
|
||||
this.url = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tool tip text for the annotation. This will be displayed in
|
||||
* a {@link org.jfree.chart.ChartPanel} when the mouse pointer hovers over
|
||||
* the annotation.
|
||||
*
|
||||
* @return The tool tip text (possibly <code>null</code>).
|
||||
*
|
||||
* @see #setToolTipText(String)
|
||||
*/
|
||||
public String getToolTipText() {
|
||||
return this.toolTipText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the tool tip text for the annotation.
|
||||
*
|
||||
* @param text the tool tip text (<code>null</code> permitted).
|
||||
*
|
||||
* @see #getToolTipText()
|
||||
*/
|
||||
public void setToolTipText(String text) {
|
||||
this.toolTipText = text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the URL for the annotation. This URL will be used to provide
|
||||
* hyperlinks when an HTML image map is created for the chart.
|
||||
*
|
||||
* @return The URL (possibly <code>null</code>).
|
||||
*
|
||||
* @see #setURL(String)
|
||||
*/
|
||||
public String getURL() {
|
||||
return this.url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the URL for the annotation.
|
||||
*
|
||||
* @param url the URL (<code>null</code> permitted).
|
||||
*
|
||||
* @see #getURL()
|
||||
*/
|
||||
public void setURL(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the annotation.
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
* @param plot the plot.
|
||||
* @param dataArea the data area.
|
||||
* @param domainAxis the domain axis.
|
||||
* @param rangeAxis the range axis.
|
||||
* @param rendererIndex the renderer index.
|
||||
* @param info if supplied, this info object will be populated with
|
||||
* entity information.
|
||||
*/
|
||||
public abstract void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea,
|
||||
ValueAxis domainAxis, ValueAxis rangeAxis,
|
||||
int rendererIndex,
|
||||
PlotRenderingInfo info);
|
||||
|
||||
/**
|
||||
* A utility method for adding an {@link XYAnnotationEntity} to
|
||||
* a {@link PlotRenderingInfo} instance.
|
||||
*
|
||||
* @param info the plot rendering info (<code>null</code> permitted).
|
||||
* @param hotspot the hotspot area.
|
||||
* @param rendererIndex the renderer index.
|
||||
* @param toolTipText the tool tip text.
|
||||
* @param urlText the URL text.
|
||||
*/
|
||||
protected void addEntity(PlotRenderingInfo info,
|
||||
Shape hotspot, int rendererIndex,
|
||||
String toolTipText, String urlText) {
|
||||
if (info == null) {
|
||||
return;
|
||||
}
|
||||
EntityCollection entities = info.getOwner().getEntityCollection();
|
||||
if (entities == null) {
|
||||
return;
|
||||
}
|
||||
XYAnnotationEntity entity = new XYAnnotationEntity(hotspot,
|
||||
rendererIndex, toolTipText, urlText);
|
||||
entities.add(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this annotation for equality with an arbitrary object.
|
||||
*
|
||||
* @param obj the object (<code>null</code> permitted).
|
||||
*
|
||||
* @return A boolean.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof AbstractXYAnnotation)) {
|
||||
return false;
|
||||
}
|
||||
AbstractXYAnnotation that = (AbstractXYAnnotation) obj;
|
||||
if (!ObjectUtilities.equal(this.toolTipText, that.toolTipText)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtilities.equal(this.url, that.url)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for this instance.
|
||||
*
|
||||
* @return A hash code.
|
||||
*/
|
||||
public int hashCode() {
|
||||
int result = 193;
|
||||
if (this.toolTipText != null) {
|
||||
result = 37 * result + this.toolTipText.hashCode();
|
||||
}
|
||||
if (this.url != null) {
|
||||
result = 37 * result + this.url.hashCode();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -----------------------
|
||||
* CategoryAnnotation.java
|
||||
* -----------------------
|
||||
* (C) Copyright 2003-2008, by Object Refinery Limited.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes:
|
||||
* --------
|
||||
* 02-Apr-2003 : Version 1 (DG);
|
||||
* 02-Jul-2003 : Eliminated Annotation base interface (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.annotations;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import org.jfree.chart.axis.CategoryAxis;
|
||||
import org.jfree.chart.axis.ValueAxis;
|
||||
import org.jfree.chart.plot.CategoryPlot;
|
||||
|
||||
/**
|
||||
* The interface that must be supported by annotations that are to be added to
|
||||
* a {@link org.jfree.chart.plot.CategoryPlot}.
|
||||
*/
|
||||
public interface CategoryAnnotation {
|
||||
|
||||
/**
|
||||
* Draws the annotation.
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
* @param plot the plot.
|
||||
* @param dataArea the data area.
|
||||
* @param domainAxis the domain axis.
|
||||
* @param rangeAxis the range axis.
|
||||
*/
|
||||
public void draw(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea,
|
||||
CategoryAxis domainAxis, ValueAxis rangeAxis);
|
||||
|
||||
}
|
||||
@@ -1,422 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* ---------------------------
|
||||
* CategoryLineAnnotation.java
|
||||
* ---------------------------
|
||||
* (C) Copyright 2005-2008, by Object Refinery Limited.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes:
|
||||
* --------
|
||||
* 29-Jul-2005 : Version 1, based on CategoryTextAnnotation (DG);
|
||||
* ------------- JFREECHART 1.0.x ---------------------------------------------
|
||||
* 06-Mar-2007 : Reimplemented hashCode() (DG);
|
||||
* 23-Apr-2008 : Implemented PublicCloneable (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.annotations;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Paint;
|
||||
import java.awt.Stroke;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.jfree.chart.HashUtilities;
|
||||
import org.jfree.chart.axis.CategoryAnchor;
|
||||
import org.jfree.chart.axis.CategoryAxis;
|
||||
import org.jfree.chart.axis.ValueAxis;
|
||||
import org.jfree.chart.plot.CategoryPlot;
|
||||
import org.jfree.chart.plot.Plot;
|
||||
import org.jfree.chart.plot.PlotOrientation;
|
||||
import org.jfree.data.category.CategoryDataset;
|
||||
import org.jfree.io.SerialUtilities;
|
||||
import org.jfree.ui.RectangleEdge;
|
||||
import org.jfree.util.ObjectUtilities;
|
||||
import org.jfree.util.PaintUtilities;
|
||||
import org.jfree.util.PublicCloneable;
|
||||
|
||||
/**
|
||||
* A line annotation that can be placed on a {@link CategoryPlot}.
|
||||
*/
|
||||
public class CategoryLineAnnotation implements CategoryAnnotation,
|
||||
Cloneable, PublicCloneable, Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
static final long serialVersionUID = 3477740483341587984L;
|
||||
|
||||
/** The category for the start of the line. */
|
||||
private Comparable category1;
|
||||
|
||||
/** The value for the start of the line. */
|
||||
private double value1;
|
||||
|
||||
/** The category for the end of the line. */
|
||||
private Comparable category2;
|
||||
|
||||
/** The value for the end of the line. */
|
||||
private double value2;
|
||||
|
||||
/** The line color. */
|
||||
private transient Paint paint = Color.black;
|
||||
|
||||
/** The line stroke. */
|
||||
private transient Stroke stroke = new BasicStroke(1.0f);
|
||||
|
||||
/**
|
||||
* Creates a new annotation that draws a line between (category1, value1)
|
||||
* and (category2, value2).
|
||||
*
|
||||
* @param category1 the category (<code>null</code> not permitted).
|
||||
* @param value1 the value.
|
||||
* @param category2 the category (<code>null</code> not permitted).
|
||||
* @param value2 the value.
|
||||
* @param paint the line color (<code>null</code> not permitted).
|
||||
* @param stroke the line stroke (<code>null</code> not permitted).
|
||||
*/
|
||||
public CategoryLineAnnotation(Comparable category1, double value1,
|
||||
Comparable category2, double value2,
|
||||
Paint paint, Stroke stroke) {
|
||||
if (category1 == null) {
|
||||
throw new IllegalArgumentException("Null 'category1' argument.");
|
||||
}
|
||||
if (category2 == null) {
|
||||
throw new IllegalArgumentException("Null 'category2' argument.");
|
||||
}
|
||||
if (paint == null) {
|
||||
throw new IllegalArgumentException("Null 'paint' argument.");
|
||||
}
|
||||
if (stroke == null) {
|
||||
throw new IllegalArgumentException("Null 'stroke' argument.");
|
||||
}
|
||||
this.category1 = category1;
|
||||
this.value1 = value1;
|
||||
this.category2 = category2;
|
||||
this.value2 = value2;
|
||||
this.paint = paint;
|
||||
this.stroke = stroke;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the category for the start of the line.
|
||||
*
|
||||
* @return The category for the start of the line (never <code>null</code>).
|
||||
*
|
||||
* @see #setCategory1(Comparable)
|
||||
*/
|
||||
public Comparable getCategory1() {
|
||||
return this.category1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the category for the start of the line.
|
||||
*
|
||||
* @param category the category (<code>null</code> not permitted).
|
||||
*
|
||||
* @see #getCategory1()
|
||||
*/
|
||||
public void setCategory1(Comparable category) {
|
||||
if (category == null) {
|
||||
throw new IllegalArgumentException("Null 'category' argument.");
|
||||
}
|
||||
this.category1 = category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the y-value for the start of the line.
|
||||
*
|
||||
* @return The y-value for the start of the line.
|
||||
*
|
||||
* @see #setValue1(double)
|
||||
*/
|
||||
public double getValue1() {
|
||||
return this.value1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the y-value for the start of the line.
|
||||
*
|
||||
* @param value the value.
|
||||
*
|
||||
* @see #getValue1()
|
||||
*/
|
||||
public void setValue1(double value) {
|
||||
this.value1 = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the category for the end of the line.
|
||||
*
|
||||
* @return The category for the end of the line (never <code>null</code>).
|
||||
*
|
||||
* @see #setCategory2(Comparable)
|
||||
*/
|
||||
public Comparable getCategory2() {
|
||||
return this.category2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the category for the end of the line.
|
||||
*
|
||||
* @param category the category (<code>null</code> not permitted).
|
||||
*
|
||||
* @see #getCategory2()
|
||||
*/
|
||||
public void setCategory2(Comparable category) {
|
||||
if (category == null) {
|
||||
throw new IllegalArgumentException("Null 'category' argument.");
|
||||
}
|
||||
this.category2 = category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the y-value for the end of the line.
|
||||
*
|
||||
* @return The y-value for the end of the line.
|
||||
*
|
||||
* @see #setValue2(double)
|
||||
*/
|
||||
public double getValue2() {
|
||||
return this.value2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the y-value for the end of the line.
|
||||
*
|
||||
* @param value the value.
|
||||
*
|
||||
* @see #getValue2()
|
||||
*/
|
||||
public void setValue2(double value) {
|
||||
this.value2 = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the paint used to draw the connecting line.
|
||||
*
|
||||
* @return The paint (never <code>null</code>).
|
||||
*
|
||||
* @see #setPaint(Paint)
|
||||
*/
|
||||
public Paint getPaint() {
|
||||
return this.paint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the paint used to draw the connecting line.
|
||||
*
|
||||
* @param paint the paint (<code>null</code> not permitted).
|
||||
*
|
||||
* @see #getPaint()
|
||||
*/
|
||||
public void setPaint(Paint paint) {
|
||||
if (paint == null) {
|
||||
throw new IllegalArgumentException("Null 'paint' argument.");
|
||||
}
|
||||
this.paint = paint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the stroke used to draw the connecting line.
|
||||
*
|
||||
* @return The stroke (never <code>null</code>).
|
||||
*
|
||||
* @see #setStroke(Stroke)
|
||||
*/
|
||||
public Stroke getStroke() {
|
||||
return this.stroke;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the stroke used to draw the connecting line.
|
||||
*
|
||||
* @param stroke the stroke (<code>null</code> not permitted).
|
||||
*
|
||||
* @see #getStroke()
|
||||
*/
|
||||
public void setStroke(Stroke stroke) {
|
||||
if (stroke == null) {
|
||||
throw new IllegalArgumentException("Null 'stroke' argument.");
|
||||
}
|
||||
this.stroke = stroke;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the annotation.
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
* @param plot the plot.
|
||||
* @param dataArea the data area.
|
||||
* @param domainAxis the domain axis.
|
||||
* @param rangeAxis the range axis.
|
||||
*/
|
||||
public void draw(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea,
|
||||
CategoryAxis domainAxis, ValueAxis rangeAxis) {
|
||||
|
||||
CategoryDataset dataset = plot.getDataset();
|
||||
int catIndex1 = dataset.getColumnIndex(this.category1);
|
||||
int catIndex2 = dataset.getColumnIndex(this.category2);
|
||||
int catCount = dataset.getColumnCount();
|
||||
|
||||
double lineX1 = 0.0f;
|
||||
double lineY1 = 0.0f;
|
||||
double lineX2 = 0.0f;
|
||||
double lineY2 = 0.0f;
|
||||
PlotOrientation orientation = plot.getOrientation();
|
||||
RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
|
||||
plot.getDomainAxisLocation(), orientation);
|
||||
RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
|
||||
plot.getRangeAxisLocation(), orientation);
|
||||
|
||||
if (orientation == PlotOrientation.HORIZONTAL) {
|
||||
lineY1 = domainAxis.getCategoryJava2DCoordinate(
|
||||
CategoryAnchor.MIDDLE, catIndex1, catCount, dataArea,
|
||||
domainEdge);
|
||||
lineX1 = rangeAxis.valueToJava2D(this.value1, dataArea, rangeEdge);
|
||||
lineY2 = domainAxis.getCategoryJava2DCoordinate(
|
||||
CategoryAnchor.MIDDLE, catIndex2, catCount, dataArea,
|
||||
domainEdge);
|
||||
lineX2 = rangeAxis.valueToJava2D(this.value2, dataArea, rangeEdge);
|
||||
}
|
||||
else if (orientation == PlotOrientation.VERTICAL) {
|
||||
lineX1 = domainAxis.getCategoryJava2DCoordinate(
|
||||
CategoryAnchor.MIDDLE, catIndex1, catCount, dataArea,
|
||||
domainEdge);
|
||||
lineY1 = rangeAxis.valueToJava2D(this.value1, dataArea, rangeEdge);
|
||||
lineX2 = domainAxis.getCategoryJava2DCoordinate(
|
||||
CategoryAnchor.MIDDLE, catIndex2, catCount, dataArea,
|
||||
domainEdge);
|
||||
lineY2 = rangeAxis.valueToJava2D(this.value2, dataArea, rangeEdge);
|
||||
}
|
||||
g2.setPaint(this.paint);
|
||||
g2.setStroke(this.stroke);
|
||||
g2.drawLine((int) lineX1, (int) lineY1, (int) lineX2, (int) lineY2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this object for equality with another.
|
||||
*
|
||||
* @param obj the object (<code>null</code> permitted).
|
||||
*
|
||||
* @return <code>true</code> or <code>false</code>.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof CategoryLineAnnotation)) {
|
||||
return false;
|
||||
}
|
||||
CategoryLineAnnotation that = (CategoryLineAnnotation) obj;
|
||||
if (!this.category1.equals(that.getCategory1())) {
|
||||
return false;
|
||||
}
|
||||
if (this.value1 != that.getValue1()) {
|
||||
return false;
|
||||
}
|
||||
if (!this.category2.equals(that.getCategory2())) {
|
||||
return false;
|
||||
}
|
||||
if (this.value2 != that.getValue2()) {
|
||||
return false;
|
||||
}
|
||||
if (!PaintUtilities.equal(this.paint, that.paint)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtilities.equal(this.stroke, that.stroke)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for this instance.
|
||||
*
|
||||
* @return A hash code.
|
||||
*/
|
||||
public int hashCode() {
|
||||
int result = 193;
|
||||
result = 37 * result + this.category1.hashCode();
|
||||
long temp = Double.doubleToLongBits(this.value1);
|
||||
result = 37 * result + (int) (temp ^ (temp >>> 32));
|
||||
result = 37 * result + this.category2.hashCode();
|
||||
temp = Double.doubleToLongBits(this.value2);
|
||||
result = 37 * result + (int) (temp ^ (temp >>> 32));
|
||||
result = 37 * result + HashUtilities.hashCodeForPaint(this.paint);
|
||||
result = 37 * result + this.stroke.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone of the annotation.
|
||||
*
|
||||
* @return A clone.
|
||||
*
|
||||
* @throws CloneNotSupportedException this class will not throw this
|
||||
* exception, but subclasses (if any) might.
|
||||
*/
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the output stream.
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
*/
|
||||
private void writeObject(ObjectOutputStream stream) throws IOException {
|
||||
stream.defaultWriteObject();
|
||||
SerialUtilities.writePaint(this.paint, stream);
|
||||
SerialUtilities.writeStroke(this.stroke, stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the input stream.
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
* @throws ClassNotFoundException if there is a classpath problem.
|
||||
*/
|
||||
private void readObject(ObjectInputStream stream)
|
||||
throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
this.paint = SerialUtilities.readPaint(stream);
|
||||
this.stroke = SerialUtilities.readStroke(stream);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,524 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* ------------------------------
|
||||
* CategoryPointerAnnotation.java
|
||||
* ------------------------------
|
||||
* (C) Copyright 2006-2015, by Object Refinery Limited.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes:
|
||||
* --------
|
||||
* 02-Oct-2006 : Version 1 (DG);
|
||||
* 06-Mar-2007 : Implemented hashCode() (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.annotations;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Paint;
|
||||
import java.awt.Stroke;
|
||||
import java.awt.geom.GeneralPath;
|
||||
import java.awt.geom.Line2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.jfree.chart.HashUtilities;
|
||||
import org.jfree.chart.axis.CategoryAxis;
|
||||
import org.jfree.chart.axis.ValueAxis;
|
||||
import org.jfree.chart.plot.CategoryPlot;
|
||||
import org.jfree.chart.plot.Plot;
|
||||
import org.jfree.chart.plot.PlotOrientation;
|
||||
import org.jfree.data.category.CategoryDataset;
|
||||
import org.jfree.io.SerialUtilities;
|
||||
import org.jfree.text.TextUtilities;
|
||||
import org.jfree.ui.RectangleEdge;
|
||||
import org.jfree.util.ObjectUtilities;
|
||||
import org.jfree.util.PublicCloneable;
|
||||
|
||||
/**
|
||||
* An arrow and label that can be placed on a {@link CategoryPlot}. The arrow
|
||||
* is drawn at a user-definable angle so that it points towards the (category,
|
||||
* value) location for the annotation.
|
||||
* <p>
|
||||
* The arrow length (and its offset from the (category, value) location) is
|
||||
* controlled by the tip radius and the base radius attributes. Imagine two
|
||||
* circles around the (category, value) coordinate: the inner circle defined by
|
||||
* the tip radius, and the outer circle defined by the base radius. Now, draw
|
||||
* the arrow starting at some point on the outer circle (the point is
|
||||
* determined by the angle), with the arrow tip being drawn at a corresponding
|
||||
* point on the inner circle.
|
||||
*
|
||||
* @since 1.0.3
|
||||
*/
|
||||
public class CategoryPointerAnnotation extends CategoryTextAnnotation
|
||||
implements Cloneable, PublicCloneable,
|
||||
Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
private static final long serialVersionUID = -4031161445009858551L;
|
||||
|
||||
/** The default tip radius (in Java2D units). */
|
||||
public static final double DEFAULT_TIP_RADIUS = 10.0;
|
||||
|
||||
/** The default base radius (in Java2D units). */
|
||||
public static final double DEFAULT_BASE_RADIUS = 30.0;
|
||||
|
||||
/** The default label offset (in Java2D units). */
|
||||
public static final double DEFAULT_LABEL_OFFSET = 3.0;
|
||||
|
||||
/** The default arrow length (in Java2D units). */
|
||||
public static final double DEFAULT_ARROW_LENGTH = 5.0;
|
||||
|
||||
/** The default arrow width (in Java2D units). */
|
||||
public static final double DEFAULT_ARROW_WIDTH = 3.0;
|
||||
|
||||
/** The angle of the arrow's line (in radians). */
|
||||
private double angle;
|
||||
|
||||
/**
|
||||
* The radius from the (x, y) point to the tip of the arrow (in Java2D
|
||||
* units).
|
||||
*/
|
||||
private double tipRadius;
|
||||
|
||||
/**
|
||||
* The radius from the (x, y) point to the start of the arrow line (in
|
||||
* Java2D units).
|
||||
*/
|
||||
private double baseRadius;
|
||||
|
||||
/** The length of the arrow head (in Java2D units). */
|
||||
private double arrowLength;
|
||||
|
||||
/** The arrow width (in Java2D units, per side). */
|
||||
private double arrowWidth;
|
||||
|
||||
/** The arrow stroke. */
|
||||
private transient Stroke arrowStroke;
|
||||
|
||||
/** The arrow paint. */
|
||||
private transient Paint arrowPaint;
|
||||
|
||||
/** The radius from the base point to the anchor point for the label. */
|
||||
private double labelOffset;
|
||||
|
||||
/**
|
||||
* Creates a new label and arrow annotation.
|
||||
*
|
||||
* @param label the label (<code>null</code> permitted).
|
||||
* @param key the category key.
|
||||
* @param value the y-value (measured against the chart's range axis).
|
||||
* @param angle the angle of the arrow's line (in radians).
|
||||
*/
|
||||
public CategoryPointerAnnotation(String label, Comparable key, double value,
|
||||
double angle) {
|
||||
|
||||
super(label, key, value);
|
||||
this.angle = angle;
|
||||
this.tipRadius = DEFAULT_TIP_RADIUS;
|
||||
this.baseRadius = DEFAULT_BASE_RADIUS;
|
||||
this.arrowLength = DEFAULT_ARROW_LENGTH;
|
||||
this.arrowWidth = DEFAULT_ARROW_WIDTH;
|
||||
this.labelOffset = DEFAULT_LABEL_OFFSET;
|
||||
this.arrowStroke = new BasicStroke(1.0f);
|
||||
this.arrowPaint = Color.black;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the angle of the arrow.
|
||||
*
|
||||
* @return The angle (in radians).
|
||||
*
|
||||
* @see #setAngle(double)
|
||||
*/
|
||||
public double getAngle() {
|
||||
return this.angle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the angle of the arrow.
|
||||
*
|
||||
* @param angle the angle (in radians).
|
||||
*
|
||||
* @see #getAngle()
|
||||
*/
|
||||
public void setAngle(double angle) {
|
||||
this.angle = angle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tip radius.
|
||||
*
|
||||
* @return The tip radius (in Java2D units).
|
||||
*
|
||||
* @see #setTipRadius(double)
|
||||
*/
|
||||
public double getTipRadius() {
|
||||
return this.tipRadius;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the tip radius.
|
||||
*
|
||||
* @param radius the radius (in Java2D units).
|
||||
*
|
||||
* @see #getTipRadius()
|
||||
*/
|
||||
public void setTipRadius(double radius) {
|
||||
this.tipRadius = radius;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the base radius.
|
||||
*
|
||||
* @return The base radius (in Java2D units).
|
||||
*
|
||||
* @see #setBaseRadius(double)
|
||||
*/
|
||||
public double getBaseRadius() {
|
||||
return this.baseRadius;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the base radius.
|
||||
*
|
||||
* @param radius the radius (in Java2D units).
|
||||
*
|
||||
* @see #getBaseRadius()
|
||||
*/
|
||||
public void setBaseRadius(double radius) {
|
||||
this.baseRadius = radius;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the label offset.
|
||||
*
|
||||
* @return The label offset (in Java2D units).
|
||||
*
|
||||
* @see #setLabelOffset(double)
|
||||
*/
|
||||
public double getLabelOffset() {
|
||||
return this.labelOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the label offset (from the arrow base, continuing in a straight
|
||||
* line, in Java2D units).
|
||||
*
|
||||
* @param offset the offset (in Java2D units).
|
||||
*
|
||||
* @see #getLabelOffset()
|
||||
*/
|
||||
public void setLabelOffset(double offset) {
|
||||
this.labelOffset = offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the arrow length.
|
||||
*
|
||||
* @return The arrow length.
|
||||
*
|
||||
* @see #setArrowLength(double)
|
||||
*/
|
||||
public double getArrowLength() {
|
||||
return this.arrowLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the arrow length.
|
||||
*
|
||||
* @param length the length.
|
||||
*
|
||||
* @see #getArrowLength()
|
||||
*/
|
||||
public void setArrowLength(double length) {
|
||||
this.arrowLength = length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the arrow width.
|
||||
*
|
||||
* @return The arrow width (in Java2D units).
|
||||
*
|
||||
* @see #setArrowWidth(double)
|
||||
*/
|
||||
public double getArrowWidth() {
|
||||
return this.arrowWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the arrow width.
|
||||
*
|
||||
* @param width the width (in Java2D units).
|
||||
*
|
||||
* @see #getArrowWidth()
|
||||
*/
|
||||
public void setArrowWidth(double width) {
|
||||
this.arrowWidth = width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the stroke used to draw the arrow line.
|
||||
*
|
||||
* @return The arrow stroke (never <code>null</code>).
|
||||
*
|
||||
* @see #setArrowStroke(Stroke)
|
||||
*/
|
||||
public Stroke getArrowStroke() {
|
||||
return this.arrowStroke;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the stroke used to draw the arrow line.
|
||||
*
|
||||
* @param stroke the stroke (<code>null</code> not permitted).
|
||||
*
|
||||
* @see #getArrowStroke()
|
||||
*/
|
||||
public void setArrowStroke(Stroke stroke) {
|
||||
if (stroke == null) {
|
||||
throw new IllegalArgumentException("Null 'stroke' not permitted.");
|
||||
}
|
||||
this.arrowStroke = stroke;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the paint used for the arrow.
|
||||
*
|
||||
* @return The arrow paint (never <code>null</code>).
|
||||
*
|
||||
* @see #setArrowPaint(Paint)
|
||||
*/
|
||||
public Paint getArrowPaint() {
|
||||
return this.arrowPaint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the paint used for the arrow.
|
||||
*
|
||||
* @param paint the arrow paint (<code>null</code> not permitted).
|
||||
*
|
||||
* @see #getArrowPaint()
|
||||
*/
|
||||
public void setArrowPaint(Paint paint) {
|
||||
if (paint == null) {
|
||||
throw new IllegalArgumentException("Null 'paint' argument.");
|
||||
}
|
||||
this.arrowPaint = paint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the annotation.
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
* @param plot the plot.
|
||||
* @param dataArea the data area.
|
||||
* @param domainAxis the domain axis.
|
||||
* @param rangeAxis the range axis.
|
||||
*/
|
||||
public void draw(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea,
|
||||
CategoryAxis domainAxis, ValueAxis rangeAxis) {
|
||||
|
||||
PlotOrientation orientation = plot.getOrientation();
|
||||
RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
|
||||
plot.getDomainAxisLocation(), orientation);
|
||||
RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
|
||||
plot.getRangeAxisLocation(), orientation);
|
||||
CategoryDataset dataset = plot.getDataset();
|
||||
int catIndex = dataset.getColumnIndex(getCategory());
|
||||
int catCount = dataset.getColumnCount();
|
||||
double j2DX = domainAxis.getCategoryMiddle(catIndex, catCount,
|
||||
dataArea, domainEdge);
|
||||
double j2DY = rangeAxis.valueToJava2D(getValue(), dataArea, rangeEdge);
|
||||
if (orientation == PlotOrientation.HORIZONTAL) {
|
||||
double temp = j2DX;
|
||||
j2DX = j2DY;
|
||||
j2DY = temp;
|
||||
}
|
||||
double startX = j2DX + Math.cos(this.angle) * this.baseRadius;
|
||||
double startY = j2DY + Math.sin(this.angle) * this.baseRadius;
|
||||
|
||||
double endX = j2DX + Math.cos(this.angle) * this.tipRadius;
|
||||
double endY = j2DY + Math.sin(this.angle) * this.tipRadius;
|
||||
|
||||
double arrowBaseX = endX + Math.cos(this.angle) * this.arrowLength;
|
||||
double arrowBaseY = endY + Math.sin(this.angle) * this.arrowLength;
|
||||
|
||||
double arrowLeftX = arrowBaseX
|
||||
+ Math.cos(this.angle + Math.PI / 2.0) * this.arrowWidth;
|
||||
double arrowLeftY = arrowBaseY
|
||||
+ Math.sin(this.angle + Math.PI / 2.0) * this.arrowWidth;
|
||||
|
||||
double arrowRightX = arrowBaseX
|
||||
- Math.cos(this.angle + Math.PI / 2.0) * this.arrowWidth;
|
||||
double arrowRightY = arrowBaseY
|
||||
- Math.sin(this.angle + Math.PI / 2.0) * this.arrowWidth;
|
||||
|
||||
GeneralPath arrow = new GeneralPath();
|
||||
arrow.moveTo((float) endX, (float) endY);
|
||||
arrow.lineTo((float) arrowLeftX, (float) arrowLeftY);
|
||||
arrow.lineTo((float) arrowRightX, (float) arrowRightY);
|
||||
arrow.closePath();
|
||||
|
||||
g2.setStroke(this.arrowStroke);
|
||||
g2.setPaint(this.arrowPaint);
|
||||
Line2D line = new Line2D.Double(startX, startY, endX, endY);
|
||||
g2.draw(line);
|
||||
g2.fill(arrow);
|
||||
|
||||
// draw the label
|
||||
g2.setFont(getFont());
|
||||
g2.setPaint(getPaint());
|
||||
double labelX = j2DX
|
||||
+ Math.cos(this.angle) * (this.baseRadius + this.labelOffset);
|
||||
double labelY = j2DY
|
||||
+ Math.sin(this.angle) * (this.baseRadius + this.labelOffset);
|
||||
/* Rectangle2D hotspot = */ TextUtilities.drawAlignedString(getText(),
|
||||
g2, (float) labelX, (float) labelY, getTextAnchor());
|
||||
// TODO: implement the entity for the annotation
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this annotation for equality with an arbitrary object.
|
||||
*
|
||||
* @param obj the object (<code>null</code> permitted).
|
||||
*
|
||||
* @return <code>true</code> or <code>false</code>.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof CategoryPointerAnnotation)) {
|
||||
return false;
|
||||
}
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
CategoryPointerAnnotation that = (CategoryPointerAnnotation) obj;
|
||||
if (this.angle != that.angle) {
|
||||
return false;
|
||||
}
|
||||
if (this.tipRadius != that.tipRadius) {
|
||||
return false;
|
||||
}
|
||||
if (this.baseRadius != that.baseRadius) {
|
||||
return false;
|
||||
}
|
||||
if (this.arrowLength != that.arrowLength) {
|
||||
return false;
|
||||
}
|
||||
if (this.arrowWidth != that.arrowWidth) {
|
||||
return false;
|
||||
}
|
||||
if (!this.arrowPaint.equals(that.arrowPaint)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtilities.equal(this.arrowStroke, that.arrowStroke)) {
|
||||
return false;
|
||||
}
|
||||
if (this.labelOffset != that.labelOffset) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for this instance.
|
||||
*
|
||||
* @return A hash code.
|
||||
*/
|
||||
public int hashCode() {
|
||||
int result = 193;
|
||||
long temp = Double.doubleToLongBits(this.angle);
|
||||
result = 37 * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(this.tipRadius);
|
||||
result = 37 * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(this.baseRadius);
|
||||
result = 37 * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(this.arrowLength);
|
||||
result = 37 * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(this.arrowWidth);
|
||||
result = 37 * result + (int) (temp ^ (temp >>> 32));
|
||||
result = 37 * result + HashUtilities.hashCodeForPaint(this.arrowPaint);
|
||||
result = 37 * result + this.arrowStroke.hashCode();
|
||||
temp = Double.doubleToLongBits(this.labelOffset);
|
||||
result = 37 * result + (int) (temp ^ (temp >>> 32));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone of the annotation.
|
||||
*
|
||||
* @return A clone.
|
||||
*
|
||||
* @throws CloneNotSupportedException if the annotation can't be cloned.
|
||||
*/
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the output stream.
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
*/
|
||||
private void writeObject(ObjectOutputStream stream) throws IOException {
|
||||
stream.defaultWriteObject();
|
||||
SerialUtilities.writePaint(this.arrowPaint, stream);
|
||||
SerialUtilities.writeStroke(this.arrowStroke, stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the input stream.
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
* @throws ClassNotFoundException if there is a classpath problem.
|
||||
*/
|
||||
private void readObject(ObjectInputStream stream)
|
||||
throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
this.arrowPaint = SerialUtilities.readPaint(stream);
|
||||
this.arrowStroke = SerialUtilities.readStroke(stream);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,277 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* ---------------------------
|
||||
* CategoryTextAnnotation.java
|
||||
* ---------------------------
|
||||
* (C) Copyright 2003-2008, by Object Refinery Limited.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes:
|
||||
* --------
|
||||
* 02-Apr-2003 : Version 1 (DG);
|
||||
* 02-Jul-2003 : Added new text alignment and rotation options (DG);
|
||||
* 04-Jul-2003 : Added a category anchor option (DG);
|
||||
* 19-Aug-2003 : Added equals() method and implemented Cloneable (DG);
|
||||
* 21-Jan-2004 : Update for renamed method in ValueAxis (DG);
|
||||
* 30-Sep-2004 : Moved drawRotatedString() from RefineryUtilities
|
||||
* --> TextUtilities (DG);
|
||||
* ------------- JFREECHART 1.0.x -------------------------------------------
|
||||
* 06-Mar-2007 : Implemented hashCode() (DG);
|
||||
* 23-Apr-2008 : Implemented PublicCloneable (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.annotations;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.jfree.chart.axis.CategoryAnchor;
|
||||
import org.jfree.chart.axis.CategoryAxis;
|
||||
import org.jfree.chart.axis.ValueAxis;
|
||||
import org.jfree.chart.plot.CategoryPlot;
|
||||
import org.jfree.chart.plot.Plot;
|
||||
import org.jfree.chart.plot.PlotOrientation;
|
||||
import org.jfree.data.category.CategoryDataset;
|
||||
import org.jfree.text.TextUtilities;
|
||||
import org.jfree.ui.RectangleEdge;
|
||||
import org.jfree.util.PublicCloneable;
|
||||
|
||||
/**
|
||||
* A text annotation that can be placed on a {@link CategoryPlot}.
|
||||
*/
|
||||
public class CategoryTextAnnotation extends TextAnnotation
|
||||
implements CategoryAnnotation, Cloneable, PublicCloneable,
|
||||
Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
private static final long serialVersionUID = 3333360090781320147L;
|
||||
|
||||
/** The category. */
|
||||
private Comparable category;
|
||||
|
||||
/** The category anchor (START, MIDDLE, or END). */
|
||||
private CategoryAnchor categoryAnchor;
|
||||
|
||||
/** The value. */
|
||||
private double value;
|
||||
|
||||
/**
|
||||
* Creates a new annotation to be displayed at the given location.
|
||||
*
|
||||
* @param text the text (<code>null</code> not permitted).
|
||||
* @param category the category (<code>null</code> not permitted).
|
||||
* @param value the value.
|
||||
*/
|
||||
public CategoryTextAnnotation(String text, Comparable category,
|
||||
double value) {
|
||||
super(text);
|
||||
if (category == null) {
|
||||
throw new IllegalArgumentException("Null 'category' argument.");
|
||||
}
|
||||
this.category = category;
|
||||
this.value = value;
|
||||
this.categoryAnchor = CategoryAnchor.MIDDLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the category.
|
||||
*
|
||||
* @return The category (never <code>null</code>).
|
||||
*
|
||||
* @see #setCategory(Comparable)
|
||||
*/
|
||||
public Comparable getCategory() {
|
||||
return this.category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the category that the annotation attaches to.
|
||||
*
|
||||
* @param category the category (<code>null</code> not permitted).
|
||||
*
|
||||
* @see #getCategory()
|
||||
*/
|
||||
public void setCategory(Comparable category) {
|
||||
if (category == null) {
|
||||
throw new IllegalArgumentException("Null 'category' argument.");
|
||||
}
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the category anchor point.
|
||||
*
|
||||
* @return The category anchor point.
|
||||
*
|
||||
* @see #setCategoryAnchor(CategoryAnchor)
|
||||
*/
|
||||
public CategoryAnchor getCategoryAnchor() {
|
||||
return this.categoryAnchor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the category anchor point.
|
||||
*
|
||||
* @param anchor the anchor point (<code>null</code> not permitted).
|
||||
*
|
||||
* @see #getCategoryAnchor()
|
||||
*/
|
||||
public void setCategoryAnchor(CategoryAnchor anchor) {
|
||||
if (anchor == null) {
|
||||
throw new IllegalArgumentException("Null 'anchor' argument.");
|
||||
}
|
||||
this.categoryAnchor = anchor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value that the annotation attaches to.
|
||||
*
|
||||
* @return The value.
|
||||
*
|
||||
* @see #setValue(double)
|
||||
*/
|
||||
public double getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value.
|
||||
*
|
||||
* @param value the value.
|
||||
*
|
||||
* @see #getValue()
|
||||
*/
|
||||
public void setValue(double value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the annotation.
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
* @param plot the plot.
|
||||
* @param dataArea the data area.
|
||||
* @param domainAxis the domain axis.
|
||||
* @param rangeAxis the range axis.
|
||||
*/
|
||||
public void draw(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea,
|
||||
CategoryAxis domainAxis, ValueAxis rangeAxis) {
|
||||
|
||||
CategoryDataset dataset = plot.getDataset();
|
||||
int catIndex = dataset.getColumnIndex(this.category);
|
||||
int catCount = dataset.getColumnCount();
|
||||
|
||||
float anchorX = 0.0f;
|
||||
float anchorY = 0.0f;
|
||||
PlotOrientation orientation = plot.getOrientation();
|
||||
RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
|
||||
plot.getDomainAxisLocation(), orientation);
|
||||
RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
|
||||
plot.getRangeAxisLocation(), orientation);
|
||||
|
||||
if (orientation == PlotOrientation.HORIZONTAL) {
|
||||
anchorY = (float) domainAxis.getCategoryJava2DCoordinate(
|
||||
this.categoryAnchor, catIndex, catCount, dataArea,
|
||||
domainEdge);
|
||||
anchorX = (float) rangeAxis.valueToJava2D(this.value, dataArea,
|
||||
rangeEdge);
|
||||
}
|
||||
else if (orientation == PlotOrientation.VERTICAL) {
|
||||
anchorX = (float) domainAxis.getCategoryJava2DCoordinate(
|
||||
this.categoryAnchor, catIndex, catCount, dataArea,
|
||||
domainEdge);
|
||||
anchorY = (float) rangeAxis.valueToJava2D(this.value, dataArea,
|
||||
rangeEdge);
|
||||
}
|
||||
g2.setFont(getFont());
|
||||
g2.setPaint(getPaint());
|
||||
TextUtilities.drawRotatedString(getText(), g2, anchorX, anchorY,
|
||||
getTextAnchor(), getRotationAngle(), getRotationAnchor());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this object for equality with another.
|
||||
*
|
||||
* @param obj the object (<code>null</code> permitted).
|
||||
*
|
||||
* @return <code>true</code> or <code>false</code>.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof CategoryTextAnnotation)) {
|
||||
return false;
|
||||
}
|
||||
CategoryTextAnnotation that = (CategoryTextAnnotation) obj;
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
if (!this.category.equals(that.getCategory())) {
|
||||
return false;
|
||||
}
|
||||
if (!this.categoryAnchor.equals(that.getCategoryAnchor())) {
|
||||
return false;
|
||||
}
|
||||
if (this.value != that.getValue()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for this instance.
|
||||
*
|
||||
* @return A hash code.
|
||||
*/
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 37 * result + this.category.hashCode();
|
||||
result = 37 * result + this.categoryAnchor.hashCode();
|
||||
long temp = Double.doubleToLongBits(this.value);
|
||||
result = 37 * result + (int) (temp ^ (temp >>> 32));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone of the annotation.
|
||||
*
|
||||
* @return A clone.
|
||||
*
|
||||
* @throws CloneNotSupportedException this class will not throw this
|
||||
* exception, but subclasses (if any) might.
|
||||
*/
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,357 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -------------------
|
||||
* TextAnnotation.java
|
||||
* -------------------
|
||||
* (C) Copyright 2002-2008, by Object Refinery Limited.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes:
|
||||
* --------
|
||||
* 28-Aug-2002 : Version 1 (DG);
|
||||
* 07-Nov-2002 : Fixed errors reported by Checkstyle, added accessor
|
||||
* methods (DG);
|
||||
* 13-Jan-2003 : Reviewed Javadocs (DG);
|
||||
* 26-Mar-2003 : Implemented Serializable (DG);
|
||||
* 02-Jun-2003 : Added anchor and rotation settings (DG);
|
||||
* 19-Aug-2003 : Added equals() method and implemented Cloneable (DG);
|
||||
* 29-Sep-2004 : Updated equals() method (DG);
|
||||
* 06-Jun-2005 : Fixed equals() method to work with GradientPaint (DG);
|
||||
* ------------- JFREECHART 1.0.x ---------------------------------------------
|
||||
* 16-Jan-2007 : Added argument checks, fixed hashCode() method and updated
|
||||
* API docs (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.annotations;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Paint;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.jfree.chart.HashUtilities;
|
||||
import org.jfree.io.SerialUtilities;
|
||||
import org.jfree.ui.TextAnchor;
|
||||
import org.jfree.util.ObjectUtilities;
|
||||
import org.jfree.util.PaintUtilities;
|
||||
|
||||
/**
|
||||
* A base class for text annotations. This class records the content but not
|
||||
* the location of the annotation.
|
||||
*/
|
||||
public class TextAnnotation implements Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
private static final long serialVersionUID = 7008912287533127432L;
|
||||
|
||||
/** The default font. */
|
||||
public static final Font DEFAULT_FONT
|
||||
= new Font("SansSerif", Font.PLAIN, 10);
|
||||
|
||||
/** The default paint. */
|
||||
public static final Paint DEFAULT_PAINT = Color.black;
|
||||
|
||||
/** The default text anchor. */
|
||||
public static final TextAnchor DEFAULT_TEXT_ANCHOR = TextAnchor.CENTER;
|
||||
|
||||
/** The default rotation anchor. */
|
||||
public static final TextAnchor DEFAULT_ROTATION_ANCHOR = TextAnchor.CENTER;
|
||||
|
||||
/** The default rotation angle. */
|
||||
public static final double DEFAULT_ROTATION_ANGLE = 0.0;
|
||||
|
||||
/** The text. */
|
||||
private String text;
|
||||
|
||||
/** The font. */
|
||||
private Font font;
|
||||
|
||||
/** The paint. */
|
||||
private transient Paint paint;
|
||||
|
||||
/** The text anchor. */
|
||||
private TextAnchor textAnchor;
|
||||
|
||||
/** The rotation anchor. */
|
||||
private TextAnchor rotationAnchor;
|
||||
|
||||
/** The rotation angle. */
|
||||
private double rotationAngle;
|
||||
|
||||
/**
|
||||
* Creates a text annotation with default settings.
|
||||
*
|
||||
* @param text the text (<code>null</code> not permitted).
|
||||
*/
|
||||
protected TextAnnotation(String text) {
|
||||
if (text == null) {
|
||||
throw new IllegalArgumentException("Null 'text' argument.");
|
||||
}
|
||||
this.text = text;
|
||||
this.font = DEFAULT_FONT;
|
||||
this.paint = DEFAULT_PAINT;
|
||||
this.textAnchor = DEFAULT_TEXT_ANCHOR;
|
||||
this.rotationAnchor = DEFAULT_ROTATION_ANCHOR;
|
||||
this.rotationAngle = DEFAULT_ROTATION_ANGLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the text for the annotation.
|
||||
*
|
||||
* @return The text (never <code>null</code>).
|
||||
*
|
||||
* @see #setText(String)
|
||||
*/
|
||||
public String getText() {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the text for the annotation.
|
||||
*
|
||||
* @param text the text (<code>null</code> not permitted).
|
||||
*
|
||||
* @see #getText()
|
||||
*/
|
||||
public void setText(String text) {
|
||||
if (text == null) {
|
||||
throw new IllegalArgumentException("Null 'text' argument.");
|
||||
}
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the font for the annotation.
|
||||
*
|
||||
* @return The font (never <code>null</code>).
|
||||
*
|
||||
* @see #setFont(Font)
|
||||
*/
|
||||
public Font getFont() {
|
||||
return this.font;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the font for the annotation.
|
||||
*
|
||||
* @param font the font (<code>null</code> not permitted).
|
||||
*
|
||||
* @see #getFont()
|
||||
*/
|
||||
public void setFont(Font font) {
|
||||
if (font == null) {
|
||||
throw new IllegalArgumentException("Null 'font' argument.");
|
||||
}
|
||||
this.font = font;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the paint for the annotation.
|
||||
*
|
||||
* @return The paint (never <code>null</code>).
|
||||
*
|
||||
* @see #setPaint(Paint)
|
||||
*/
|
||||
public Paint getPaint() {
|
||||
return this.paint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the paint for the annotation.
|
||||
*
|
||||
* @param paint the paint (<code>null</code> not permitted).
|
||||
*
|
||||
* @see #getPaint()
|
||||
*/
|
||||
public void setPaint(Paint paint) {
|
||||
if (paint == null) {
|
||||
throw new IllegalArgumentException("Null 'paint' argument.");
|
||||
}
|
||||
this.paint = paint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the text anchor.
|
||||
*
|
||||
* @return The text anchor.
|
||||
*
|
||||
* @see #setTextAnchor(TextAnchor)
|
||||
*/
|
||||
public TextAnchor getTextAnchor() {
|
||||
return this.textAnchor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the text anchor (the point on the text bounding rectangle that is
|
||||
* aligned to the (x, y) coordinate of the annotation).
|
||||
*
|
||||
* @param anchor the anchor point (<code>null</code> not permitted).
|
||||
*
|
||||
* @see #getTextAnchor()
|
||||
*/
|
||||
public void setTextAnchor(TextAnchor anchor) {
|
||||
if (anchor == null) {
|
||||
throw new IllegalArgumentException("Null 'anchor' argument.");
|
||||
}
|
||||
this.textAnchor = anchor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rotation anchor.
|
||||
*
|
||||
* @return The rotation anchor point (never <code>null</code>).
|
||||
*
|
||||
* @see #setRotationAnchor(TextAnchor)
|
||||
*/
|
||||
public TextAnchor getRotationAnchor() {
|
||||
return this.rotationAnchor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the rotation anchor point.
|
||||
*
|
||||
* @param anchor the anchor (<code>null</code> not permitted).
|
||||
*
|
||||
* @see #getRotationAnchor()
|
||||
*/
|
||||
public void setRotationAnchor(TextAnchor anchor) {
|
||||
this.rotationAnchor = anchor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rotation angle in radians.
|
||||
*
|
||||
* @return The rotation angle.
|
||||
*
|
||||
* @see #setRotationAngle(double)
|
||||
*/
|
||||
public double getRotationAngle() {
|
||||
return this.rotationAngle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the rotation angle. The angle is measured clockwise in radians.
|
||||
*
|
||||
* @param angle the angle (in radians).
|
||||
*
|
||||
* @see #getRotationAngle()
|
||||
*/
|
||||
public void setRotationAngle(double angle) {
|
||||
this.rotationAngle = angle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this object for equality with an arbitrary object.
|
||||
*
|
||||
* @param obj the object (<code>null</code> permitted).
|
||||
*
|
||||
* @return <code>true</code> or <code>false</code>.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
// now try to reject equality...
|
||||
if (!(obj instanceof TextAnnotation)) {
|
||||
return false;
|
||||
}
|
||||
TextAnnotation that = (TextAnnotation) obj;
|
||||
if (!ObjectUtilities.equal(this.text, that.getText())) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtilities.equal(this.font, that.getFont())) {
|
||||
return false;
|
||||
}
|
||||
if (!PaintUtilities.equal(this.paint, that.getPaint())) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtilities.equal(this.textAnchor, that.getTextAnchor())) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtilities.equal(this.rotationAnchor,
|
||||
that.getRotationAnchor())) {
|
||||
return false;
|
||||
}
|
||||
if (this.rotationAngle != that.getRotationAngle()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// seem to be the same...
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for this instance.
|
||||
*
|
||||
* @return A hash code.
|
||||
*/
|
||||
public int hashCode() {
|
||||
int result = 193;
|
||||
result = 37 * result + this.font.hashCode();
|
||||
result = 37 * result + HashUtilities.hashCodeForPaint(this.paint);
|
||||
result = 37 * result + this.rotationAnchor.hashCode();
|
||||
long temp = Double.doubleToLongBits(this.rotationAngle);
|
||||
result = 37 * result + (int) (temp ^ (temp >>> 32));
|
||||
result = 37 * result + this.text.hashCode();
|
||||
result = 37 * result + this.textAnchor.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the output stream.
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
*/
|
||||
private void writeObject(ObjectOutputStream stream) throws IOException {
|
||||
stream.defaultWriteObject();
|
||||
SerialUtilities.writePaint(this.paint, stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the input stream.
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
* @throws ClassNotFoundException if there is a classpath problem.
|
||||
*/
|
||||
private void readObject(ObjectInputStream stream)
|
||||
throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
this.paint = SerialUtilities.readPaint(stream);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -----------------
|
||||
* XYAnnotation.java
|
||||
* -----------------
|
||||
* (C) Copyright 2002-2008, by Object Refinery Limited.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes:
|
||||
* --------
|
||||
* 28-Aug-2002 : Version 1 (DG);
|
||||
* 07-Nov-2002 : Fixed errors reported by Checkstyle (DG);
|
||||
* 13-Jan-2003 : Reviewed Javadocs (DG);
|
||||
* 09-May-2003 : Added plot to draw() method (DG);
|
||||
* 02-Jul-2003 : Eliminated the Annotation base interface (DG);
|
||||
* 29-Sep-2004 : Added 'rendererIndex' and 'info' parameter to draw() method
|
||||
* to support chart entities (tool tips etc) (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.annotations;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import org.jfree.chart.axis.ValueAxis;
|
||||
import org.jfree.chart.plot.PlotRenderingInfo;
|
||||
import org.jfree.chart.plot.XYPlot;
|
||||
|
||||
/**
|
||||
* The interface that must be supported by annotations that are to be added to
|
||||
* an {@link XYPlot}.
|
||||
*/
|
||||
public interface XYAnnotation {
|
||||
|
||||
/**
|
||||
* Draws the annotation.
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
* @param plot the plot.
|
||||
* @param dataArea the data area.
|
||||
* @param domainAxis the domain axis.
|
||||
* @param rangeAxis the range axis.
|
||||
* @param rendererIndex the renderer index.
|
||||
* @param info an optional info object that will be populated with
|
||||
* entity information.
|
||||
*/
|
||||
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea,
|
||||
ValueAxis domainAxis, ValueAxis rangeAxis,
|
||||
int rendererIndex,
|
||||
PlotRenderingInfo info);
|
||||
|
||||
}
|
||||
@@ -1,308 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* --------------------
|
||||
* XYBoxAnnotation.java
|
||||
* --------------------
|
||||
* (C) Copyright 2005-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes:
|
||||
* --------
|
||||
* 19-Jan-2005 : Version 1 (DG);
|
||||
* 06-Jun-2005 : Fixed equals() method to handle GradientPaint (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.annotations;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Paint;
|
||||
import java.awt.Stroke;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.jfree.chart.axis.ValueAxis;
|
||||
import org.jfree.chart.plot.Plot;
|
||||
import org.jfree.chart.plot.PlotOrientation;
|
||||
import org.jfree.chart.plot.PlotRenderingInfo;
|
||||
import org.jfree.chart.plot.XYPlot;
|
||||
import org.jfree.io.SerialUtilities;
|
||||
import org.jfree.ui.RectangleEdge;
|
||||
import org.jfree.util.ObjectUtilities;
|
||||
import org.jfree.util.PaintUtilities;
|
||||
import org.jfree.util.PublicCloneable;
|
||||
|
||||
/**
|
||||
* A box annotation that can be placed on an {@link XYPlot}. The
|
||||
* box coordinates are specified in data space.
|
||||
*/
|
||||
public class XYBoxAnnotation extends AbstractXYAnnotation
|
||||
implements Cloneable, PublicCloneable, Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
private static final long serialVersionUID = 6764703772526757457L;
|
||||
|
||||
/** The lower x-coordinate. */
|
||||
private double x0;
|
||||
|
||||
/** The lower y-coordinate. */
|
||||
private double y0;
|
||||
|
||||
/** The upper x-coordinate. */
|
||||
private double x1;
|
||||
|
||||
/** The upper y-coordinate. */
|
||||
private double y1;
|
||||
|
||||
/** The stroke used to draw the box outline. */
|
||||
private transient Stroke stroke;
|
||||
|
||||
/** The paint used to draw the box outline. */
|
||||
private transient Paint outlinePaint;
|
||||
|
||||
/** The paint used to fill the box. */
|
||||
private transient Paint fillPaint;
|
||||
|
||||
/**
|
||||
* Creates a new annotation (where, by default, the box is drawn
|
||||
* with a black outline).
|
||||
*
|
||||
* @param x0 the lower x-coordinate of the box (in data space).
|
||||
* @param y0 the lower y-coordinate of the box (in data space).
|
||||
* @param x1 the upper x-coordinate of the box (in data space).
|
||||
* @param y1 the upper y-coordinate of the box (in data space).
|
||||
*/
|
||||
public XYBoxAnnotation(double x0, double y0, double x1, double y1) {
|
||||
this(x0, y0, x1, y1, new BasicStroke(1.0f), Color.black);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new annotation where the box is drawn as an outline using
|
||||
* the specified <code>stroke</code> and <code>outlinePaint</code>.
|
||||
*
|
||||
* @param x0 the lower x-coordinate of the box (in data space).
|
||||
* @param y0 the lower y-coordinate of the box (in data space).
|
||||
* @param x1 the upper x-coordinate of the box (in data space).
|
||||
* @param y1 the upper y-coordinate of the box (in data space).
|
||||
* @param stroke the shape stroke (<code>null</code> permitted).
|
||||
* @param outlinePaint the shape color (<code>null</code> permitted).
|
||||
*/
|
||||
public XYBoxAnnotation(double x0, double y0, double x1, double y1,
|
||||
Stroke stroke, Paint outlinePaint) {
|
||||
this(x0, y0, x1, y1, stroke, outlinePaint, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new annotation.
|
||||
*
|
||||
* @param x0 the lower x-coordinate of the box (in data space).
|
||||
* @param y0 the lower y-coordinate of the box (in data space).
|
||||
* @param x1 the upper x-coordinate of the box (in data space).
|
||||
* @param y1 the upper y-coordinate of the box (in data space).
|
||||
* @param stroke the shape stroke (<code>null</code> permitted).
|
||||
* @param outlinePaint the shape color (<code>null</code> permitted).
|
||||
* @param fillPaint the paint used to fill the shape (<code>null</code>
|
||||
* permitted).
|
||||
*/
|
||||
public XYBoxAnnotation(double x0, double y0, double x1, double y1,
|
||||
Stroke stroke, Paint outlinePaint, Paint fillPaint) {
|
||||
this.x0 = x0;
|
||||
this.y0 = y0;
|
||||
this.x1 = x1;
|
||||
this.y1 = y1;
|
||||
this.stroke = stroke;
|
||||
this.outlinePaint = outlinePaint;
|
||||
this.fillPaint = fillPaint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the annotation. This method is usually called by the
|
||||
* {@link XYPlot} class, you shouldn't need to call it directly.
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
* @param plot the plot.
|
||||
* @param dataArea the data area.
|
||||
* @param domainAxis the domain axis.
|
||||
* @param rangeAxis the range axis.
|
||||
* @param rendererIndex the renderer index.
|
||||
* @param info the plot rendering info.
|
||||
*/
|
||||
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea,
|
||||
ValueAxis domainAxis, ValueAxis rangeAxis,
|
||||
int rendererIndex, PlotRenderingInfo info) {
|
||||
|
||||
PlotOrientation orientation = plot.getOrientation();
|
||||
RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
|
||||
plot.getDomainAxisLocation(), orientation);
|
||||
RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
|
||||
plot.getRangeAxisLocation(), orientation);
|
||||
|
||||
double transX0 = domainAxis.valueToJava2D(this.x0, dataArea,
|
||||
domainEdge);
|
||||
double transY0 = rangeAxis.valueToJava2D(this.y0, dataArea, rangeEdge);
|
||||
double transX1 = domainAxis.valueToJava2D(this.x1, dataArea,
|
||||
domainEdge);
|
||||
double transY1 = rangeAxis.valueToJava2D(this.y1, dataArea, rangeEdge);
|
||||
|
||||
Rectangle2D box = null;
|
||||
if (orientation == PlotOrientation.HORIZONTAL) {
|
||||
box = new Rectangle2D.Double(transY0, transX1, transY1 - transY0,
|
||||
transX0 - transX1);
|
||||
}
|
||||
else if (orientation == PlotOrientation.VERTICAL) {
|
||||
box = new Rectangle2D.Double(transX0, transY1, transX1 - transX0,
|
||||
transY0 - transY1);
|
||||
}
|
||||
|
||||
if (this.fillPaint != null) {
|
||||
g2.setPaint(this.fillPaint);
|
||||
g2.fill(box);
|
||||
}
|
||||
|
||||
if (this.stroke != null && this.outlinePaint != null) {
|
||||
g2.setPaint(this.outlinePaint);
|
||||
g2.setStroke(this.stroke);
|
||||
g2.draw(box);
|
||||
}
|
||||
addEntity(info, box, rendererIndex, getToolTipText(), getURL());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this annotation for equality with an arbitrary object.
|
||||
*
|
||||
* @param obj the object (<code>null</code> permitted).
|
||||
*
|
||||
* @return A boolean.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
// now try to reject equality
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof XYBoxAnnotation)) {
|
||||
return false;
|
||||
}
|
||||
XYBoxAnnotation that = (XYBoxAnnotation) obj;
|
||||
if (!(this.x0 == that.x0)) {
|
||||
return false;
|
||||
}
|
||||
if (!(this.y0 == that.y0)) {
|
||||
return false;
|
||||
}
|
||||
if (!(this.x1 == that.x1)) {
|
||||
return false;
|
||||
}
|
||||
if (!(this.y1 == that.y1)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtilities.equal(this.stroke, that.stroke)) {
|
||||
return false;
|
||||
}
|
||||
if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) {
|
||||
return false;
|
||||
}
|
||||
if (!PaintUtilities.equal(this.fillPaint, that.fillPaint)) {
|
||||
return false;
|
||||
}
|
||||
// seem to be the same
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code.
|
||||
*
|
||||
* @return A hash code.
|
||||
*/
|
||||
public int hashCode() {
|
||||
int result;
|
||||
long temp;
|
||||
temp = Double.doubleToLongBits(this.x0);
|
||||
result = (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(this.x1);
|
||||
result = 29 * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(this.y0);
|
||||
result = 29 * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(this.y1);
|
||||
result = 29 * result + (int) (temp ^ (temp >>> 32));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone.
|
||||
*
|
||||
* @return A clone.
|
||||
*
|
||||
* @throws CloneNotSupportedException not thrown by this class, but may be
|
||||
* by subclasses.
|
||||
*/
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the output stream (<code>null</code> not permitted).
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
*/
|
||||
private void writeObject(ObjectOutputStream stream) throws IOException {
|
||||
stream.defaultWriteObject();
|
||||
SerialUtilities.writeStroke(this.stroke, stream);
|
||||
SerialUtilities.writePaint(this.outlinePaint, stream);
|
||||
SerialUtilities.writePaint(this.fillPaint, stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the input stream (<code>null</code> not permitted).
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
* @throws ClassNotFoundException if there is a classpath problem.
|
||||
*/
|
||||
private void readObject(ObjectInputStream stream)
|
||||
throws IOException, ClassNotFoundException {
|
||||
|
||||
stream.defaultReadObject();
|
||||
this.stroke = SerialUtilities.readStroke(stream);
|
||||
this.outlinePaint = SerialUtilities.readPaint(stream);
|
||||
this.fillPaint = SerialUtilities.readPaint(stream);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,306 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* --------------------------
|
||||
* XYDataImageAnnotation.java
|
||||
* --------------------------
|
||||
* (C) Copyright 2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes:
|
||||
* --------
|
||||
* 17-Sep-2008 : Version 1, based on XYImageAnnotation (DG);
|
||||
*/
|
||||
|
||||
package org.jfree.chart.annotations;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
||||
import org.jfree.chart.axis.AxisLocation;
|
||||
import org.jfree.chart.axis.ValueAxis;
|
||||
import org.jfree.chart.plot.Plot;
|
||||
import org.jfree.chart.plot.PlotOrientation;
|
||||
import org.jfree.chart.plot.PlotRenderingInfo;
|
||||
import org.jfree.chart.plot.XYPlot;
|
||||
import org.jfree.ui.RectangleEdge;
|
||||
import org.jfree.util.ObjectUtilities;
|
||||
import org.jfree.util.PublicCloneable;
|
||||
|
||||
/**
|
||||
* An annotation that allows an image to be placed within a rectangle specified
|
||||
* in data coordinates on an {@link XYPlot}. Note that this annotation
|
||||
* is not currently serializable, so don't use it if you plan on serializing
|
||||
* your chart(s).
|
||||
*
|
||||
* @since 1.0.11
|
||||
*/
|
||||
public class XYDataImageAnnotation extends AbstractXYAnnotation
|
||||
implements Cloneable, PublicCloneable {
|
||||
|
||||
/** The image. */
|
||||
private transient Image image;
|
||||
|
||||
/**
|
||||
* The x-coordinate (in data space).
|
||||
*/
|
||||
private double x;
|
||||
|
||||
/**
|
||||
* The y-coordinate (in data space).
|
||||
*/
|
||||
private double y;
|
||||
|
||||
/**
|
||||
* The image display area width in data coordinates.
|
||||
*/
|
||||
private double w;
|
||||
|
||||
/**
|
||||
* The image display area height in data coordinates.
|
||||
*/
|
||||
private double h;
|
||||
|
||||
/**
|
||||
* Creates a new annotation to be displayed within the specified rectangle.
|
||||
*
|
||||
* @param image the image (<code>null</code> not permitted).
|
||||
* @param x the x-coordinate (in data space).
|
||||
* @param y the y-coordinate (in data space).
|
||||
* @param w the image display area width.
|
||||
* @param h the image display area height.
|
||||
*/
|
||||
public XYDataImageAnnotation(Image image, double x, double y, double w,
|
||||
double h) {
|
||||
if (image == null) {
|
||||
throw new IllegalArgumentException("Null 'image' argument.");
|
||||
}
|
||||
this.image = image;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.w = w;
|
||||
this.h = h;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the image for the annotation.
|
||||
*
|
||||
* @return The image.
|
||||
*/
|
||||
public Image getImage() {
|
||||
return this.image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the x-coordinate (in data space) for the annotation.
|
||||
*
|
||||
* @return The x-coordinate.
|
||||
*/
|
||||
public double getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the y-coordinate (in data space) for the annotation.
|
||||
*
|
||||
* @return The y-coordinate.
|
||||
*/
|
||||
public double getY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the width (in data space) of the data rectangle into which the
|
||||
* image will be drawn.
|
||||
*
|
||||
* @return The width.
|
||||
*/
|
||||
public double getWidth() {
|
||||
return this.w;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the height (in data space) of the data rectangle into which the
|
||||
* image will be drawn.
|
||||
*
|
||||
* @return The height.
|
||||
*/
|
||||
public double getHeight() {
|
||||
return this.h;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the annotation. This method is called by the drawing code in the
|
||||
* {@link XYPlot} class, you don't normally need to call this method
|
||||
* directly.
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
* @param plot the plot.
|
||||
* @param dataArea the data area.
|
||||
* @param domainAxis the domain axis.
|
||||
* @param rangeAxis the range axis.
|
||||
* @param rendererIndex the renderer index.
|
||||
* @param info if supplied, this info object will be populated with
|
||||
* entity information.
|
||||
*/
|
||||
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea,
|
||||
ValueAxis domainAxis, ValueAxis rangeAxis,
|
||||
int rendererIndex,
|
||||
PlotRenderingInfo info) {
|
||||
|
||||
PlotOrientation orientation = plot.getOrientation();
|
||||
AxisLocation xAxisLocation = plot.getDomainAxisLocation();
|
||||
AxisLocation yAxisLocation = plot.getRangeAxisLocation();
|
||||
RectangleEdge xEdge = Plot.resolveDomainAxisLocation(xAxisLocation,
|
||||
orientation);
|
||||
RectangleEdge yEdge = Plot.resolveRangeAxisLocation(yAxisLocation,
|
||||
orientation);
|
||||
float j2DX0 = (float) domainAxis.valueToJava2D(this.x, dataArea, xEdge);
|
||||
float j2DY0 = (float) rangeAxis.valueToJava2D(this.y, dataArea, yEdge);
|
||||
float j2DX1 = (float) domainAxis.valueToJava2D(this.x + this.w,
|
||||
dataArea, xEdge);
|
||||
float j2DY1 = (float) rangeAxis.valueToJava2D(this.y + this.h,
|
||||
dataArea, yEdge);
|
||||
float xx0 = 0.0f;
|
||||
float yy0 = 0.0f;
|
||||
float xx1 = 0.0f;
|
||||
float yy1 = 0.0f;
|
||||
if (orientation == PlotOrientation.HORIZONTAL) {
|
||||
xx0 = j2DY0;
|
||||
xx1 = j2DY1;
|
||||
yy0 = j2DX0;
|
||||
yy1 = j2DX1;
|
||||
}
|
||||
else if (orientation == PlotOrientation.VERTICAL) {
|
||||
xx0 = j2DX0;
|
||||
xx1 = j2DX1;
|
||||
yy0 = j2DY0;
|
||||
yy1 = j2DY1;
|
||||
}
|
||||
// TODO: rotate the image when drawn with horizontal orientation?
|
||||
g2.drawImage(this.image, (int) xx0, (int) Math.min(yy0, yy1),
|
||||
(int) (xx1 - xx0), (int) Math.abs(yy1 - yy0), null);
|
||||
String toolTip = getToolTipText();
|
||||
String url = getURL();
|
||||
if (toolTip != null || url != null) {
|
||||
addEntity(info, new Rectangle2D.Float(xx0, yy0, (xx1 - xx0),
|
||||
(yy1 - yy0)), rendererIndex, toolTip, url);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this object for equality with an arbitrary object.
|
||||
*
|
||||
* @param obj the object (<code>null</code> permitted).
|
||||
*
|
||||
* @return A boolean.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
// now try to reject equality...
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof XYDataImageAnnotation)) {
|
||||
return false;
|
||||
}
|
||||
XYDataImageAnnotation that = (XYDataImageAnnotation) obj;
|
||||
if (this.x != that.x) {
|
||||
return false;
|
||||
}
|
||||
if (this.y != that.y) {
|
||||
return false;
|
||||
}
|
||||
if (this.w != that.w) {
|
||||
return false;
|
||||
}
|
||||
if (this.h != that.h) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtilities.equal(this.image, that.image)) {
|
||||
return false;
|
||||
}
|
||||
// seems to be the same...
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for this object.
|
||||
*
|
||||
* @return A hash code.
|
||||
*/
|
||||
public int hashCode() {
|
||||
return this.image.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone of the annotation.
|
||||
*
|
||||
* @return A clone.
|
||||
*
|
||||
* @throws CloneNotSupportedException if the annotation can't be cloned.
|
||||
*/
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the output stream.
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
*/
|
||||
private void writeObject(ObjectOutputStream stream) throws IOException {
|
||||
stream.defaultWriteObject();
|
||||
// FIXME
|
||||
//SerialUtilities.writeImage(this.image, stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the input stream.
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
* @throws ClassNotFoundException if there is a classpath problem.
|
||||
*/
|
||||
private void readObject(ObjectInputStream stream)
|
||||
throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
// FIXME
|
||||
//this.image = SerialUtilities.readImage(stream);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,257 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -------------------------
|
||||
* XYDrawableAnnotation.java
|
||||
* -------------------------
|
||||
* (C) Copyright 2003-2008, by Object Refinery Limited.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes:
|
||||
* --------
|
||||
* 21-May-2003 : Version 1 (DG);
|
||||
* 21-Jan-2004 : Update for renamed method in ValueAxis (DG);
|
||||
* 30-Sep-2004 : Added support for tool tips and URLs (DG);
|
||||
* 18-Jun-2008 : Added scaling factor (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.annotations;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.jfree.chart.axis.ValueAxis;
|
||||
import org.jfree.chart.plot.Plot;
|
||||
import org.jfree.chart.plot.PlotOrientation;
|
||||
import org.jfree.chart.plot.PlotRenderingInfo;
|
||||
import org.jfree.chart.plot.XYPlot;
|
||||
import org.jfree.ui.Drawable;
|
||||
import org.jfree.ui.RectangleEdge;
|
||||
import org.jfree.util.ObjectUtilities;
|
||||
import org.jfree.util.PublicCloneable;
|
||||
|
||||
/**
|
||||
* A general annotation that can be placed on an {@link XYPlot}.
|
||||
*/
|
||||
public class XYDrawableAnnotation extends AbstractXYAnnotation
|
||||
implements Cloneable, PublicCloneable, Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
private static final long serialVersionUID = -6540812859722691020L;
|
||||
|
||||
/** The scaling factor. */
|
||||
private double drawScaleFactor;
|
||||
|
||||
/** The x-coordinate. */
|
||||
private double x;
|
||||
|
||||
/** The y-coordinate. */
|
||||
private double y;
|
||||
|
||||
/** The width. */
|
||||
private double displayWidth;
|
||||
|
||||
/** The height. */
|
||||
private double displayHeight;
|
||||
|
||||
/** The drawable object. */
|
||||
private Drawable drawable;
|
||||
|
||||
/**
|
||||
* Creates a new annotation to be displayed within the given area.
|
||||
*
|
||||
* @param x the x-coordinate for the area.
|
||||
* @param y the y-coordinate for the area.
|
||||
* @param width the width of the area.
|
||||
* @param height the height of the area.
|
||||
* @param drawable the drawable object (<code>null</code> not permitted).
|
||||
*/
|
||||
public XYDrawableAnnotation(double x, double y, double width, double height,
|
||||
Drawable drawable) {
|
||||
this(x, y, width, height, 1.0, drawable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new annotation to be displayed within the given area. If you
|
||||
* specify a <code>drawScaleFactor</code> of 2.0, the <code>drawable</code>
|
||||
* will be drawn at twice the requested display size then scaled down to
|
||||
* fit the space.
|
||||
*
|
||||
* @param x the x-coordinate for the area.
|
||||
* @param y the y-coordinate for the area.
|
||||
* @param displayWidth the width of the area.
|
||||
* @param displayHeight the height of the area.
|
||||
* @param drawScaleFactor the scaling factor for drawing.
|
||||
* @param drawable the drawable object (<code>null</code> not permitted).
|
||||
*
|
||||
* @since 1.0.11
|
||||
*/
|
||||
public XYDrawableAnnotation(double x, double y, double displayWidth,
|
||||
double displayHeight, double drawScaleFactor, Drawable drawable) {
|
||||
|
||||
if (drawable == null) {
|
||||
throw new IllegalArgumentException("Null 'drawable' argument.");
|
||||
}
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.displayWidth = displayWidth;
|
||||
this.displayHeight = displayHeight;
|
||||
this.drawScaleFactor = drawScaleFactor;
|
||||
this.drawable = drawable;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the annotation.
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
* @param plot the plot.
|
||||
* @param dataArea the data area.
|
||||
* @param domainAxis the domain axis.
|
||||
* @param rangeAxis the range axis.
|
||||
* @param rendererIndex the renderer index.
|
||||
* @param info if supplied, this info object will be populated with
|
||||
* entity information.
|
||||
*/
|
||||
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea,
|
||||
ValueAxis domainAxis, ValueAxis rangeAxis,
|
||||
int rendererIndex,
|
||||
PlotRenderingInfo info) {
|
||||
|
||||
PlotOrientation orientation = plot.getOrientation();
|
||||
RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
|
||||
plot.getDomainAxisLocation(), orientation);
|
||||
RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
|
||||
plot.getRangeAxisLocation(), orientation);
|
||||
float j2DX = (float) domainAxis.valueToJava2D(this.x, dataArea,
|
||||
domainEdge);
|
||||
float j2DY = (float) rangeAxis.valueToJava2D(this.y, dataArea,
|
||||
rangeEdge);
|
||||
Rectangle2D displayArea = new Rectangle2D.Double(
|
||||
j2DX - this.displayWidth / 2.0,
|
||||
j2DY - this.displayHeight / 2.0, this.displayWidth,
|
||||
this.displayHeight);
|
||||
|
||||
// here we change the AffineTransform so we can draw the annotation
|
||||
// to a larger area and scale it down into the display area
|
||||
// afterwards, the original transform is restored
|
||||
AffineTransform savedTransform = g2.getTransform();
|
||||
Rectangle2D drawArea = new Rectangle2D.Double(0.0, 0.0,
|
||||
this.displayWidth * this.drawScaleFactor,
|
||||
this.displayHeight * this.drawScaleFactor);
|
||||
|
||||
g2.scale(1/this.drawScaleFactor, 1/this.drawScaleFactor);
|
||||
g2.translate((j2DX - this.displayWidth / 2.0) * this.drawScaleFactor,
|
||||
(j2DY - this.displayHeight / 2.0) * this.drawScaleFactor);
|
||||
this.drawable.draw(g2, drawArea);
|
||||
g2.setTransform(savedTransform);
|
||||
String toolTip = getToolTipText();
|
||||
String url = getURL();
|
||||
if (toolTip != null || url != null) {
|
||||
addEntity(info, displayArea, rendererIndex, toolTip, url);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this annotation for equality with an arbitrary object.
|
||||
*
|
||||
* @param obj the object to test against.
|
||||
*
|
||||
* @return <code>true</code> or <code>false</code>.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
if (obj == this) { // simple case
|
||||
return true;
|
||||
}
|
||||
// now try to reject equality...
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof XYDrawableAnnotation)) {
|
||||
return false;
|
||||
}
|
||||
XYDrawableAnnotation that = (XYDrawableAnnotation) obj;
|
||||
if (this.x != that.x) {
|
||||
return false;
|
||||
}
|
||||
if (this.y != that.y) {
|
||||
return false;
|
||||
}
|
||||
if (this.displayWidth != that.displayWidth) {
|
||||
return false;
|
||||
}
|
||||
if (this.displayHeight != that.displayHeight) {
|
||||
return false;
|
||||
}
|
||||
if (this.drawScaleFactor != that.drawScaleFactor) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtilities.equal(this.drawable, that.drawable)) {
|
||||
return false;
|
||||
}
|
||||
// seem to be the same...
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code.
|
||||
*
|
||||
* @return A hash code.
|
||||
*/
|
||||
public int hashCode() {
|
||||
int result;
|
||||
long temp;
|
||||
temp = Double.doubleToLongBits(this.x);
|
||||
result = (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(this.y);
|
||||
result = 29 * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(this.displayWidth);
|
||||
result = 29 * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(this.displayHeight);
|
||||
result = 29 * result + (int) (temp ^ (temp >>> 32));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone of the annotation.
|
||||
*
|
||||
* @return A clone.
|
||||
*
|
||||
* @throws CloneNotSupportedException if the annotation can't be cloned.
|
||||
*/
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,318 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* ----------------------
|
||||
* XYImageAnnotation.java
|
||||
* ----------------------
|
||||
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): Mike Harris;
|
||||
*
|
||||
* Changes:
|
||||
* --------
|
||||
* 01-Dec-2003 : Version 1 (DG);
|
||||
* 21-Jan-2004 : Update for renamed method in ValueAxis (DG);
|
||||
* 18-May-2004 : Fixed bug with plot orientation (DG);
|
||||
* 29-Sep-2004 : Now extends AbstractXYAnnotation, with modified draw()
|
||||
* method signature and updated equals() method (DG);
|
||||
* ------------- JFREECHART 1.0.x ---------------------------------------------
|
||||
* 01-Dec-2006 : Added anchor attribute (see patch 1584860 from
|
||||
* Mike Harris) (DG);
|
||||
*/
|
||||
|
||||
package org.jfree.chart.annotations;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.jfree.chart.axis.AxisLocation;
|
||||
import org.jfree.chart.axis.ValueAxis;
|
||||
import org.jfree.chart.plot.Plot;
|
||||
import org.jfree.chart.plot.PlotOrientation;
|
||||
import org.jfree.chart.plot.PlotRenderingInfo;
|
||||
import org.jfree.chart.plot.XYPlot;
|
||||
import org.jfree.ui.RectangleAnchor;
|
||||
import org.jfree.ui.RectangleEdge;
|
||||
import org.jfree.util.ObjectUtilities;
|
||||
import org.jfree.util.PublicCloneable;
|
||||
|
||||
/**
|
||||
* An annotation that allows an image to be placed at some location on
|
||||
* an {@link XYPlot}.
|
||||
*
|
||||
* TODO: implement serialization properly (image is not serializable).
|
||||
*/
|
||||
public class XYImageAnnotation extends AbstractXYAnnotation
|
||||
implements Cloneable, PublicCloneable, Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
private static final long serialVersionUID = -4364694501921559958L;
|
||||
|
||||
/** The x-coordinate (in data space). */
|
||||
private double x;
|
||||
|
||||
/** The y-coordinate (in data space). */
|
||||
private double y;
|
||||
|
||||
/** The image. */
|
||||
private transient Image image;
|
||||
|
||||
/**
|
||||
* The image anchor point.
|
||||
*
|
||||
* @since 1.0.4
|
||||
*/
|
||||
private RectangleAnchor anchor;
|
||||
|
||||
/**
|
||||
* Creates a new annotation to be displayed at the specified (x, y)
|
||||
* location.
|
||||
*
|
||||
* @param x the x-coordinate (in data space).
|
||||
* @param y the y-coordinate (in data space).
|
||||
* @param image the image (<code>null</code> not permitted).
|
||||
*/
|
||||
public XYImageAnnotation(double x, double y, Image image) {
|
||||
this(x, y, image, RectangleAnchor.CENTER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new annotation to be displayed at the specified (x, y)
|
||||
* location.
|
||||
*
|
||||
* @param x the x-coordinate (in data space).
|
||||
* @param y the y-coordinate (in data space).
|
||||
* @param image the image (<code>null</code> not permitted).
|
||||
* @param anchor the image anchor (<code>null</code> not permitted).
|
||||
*
|
||||
* @since 1.0.4
|
||||
*/
|
||||
public XYImageAnnotation(double x, double y, Image image,
|
||||
RectangleAnchor anchor) {
|
||||
if (image == null) {
|
||||
throw new IllegalArgumentException("Null 'image' argument.");
|
||||
}
|
||||
if (anchor == null) {
|
||||
throw new IllegalArgumentException("Null 'anchor' argument.");
|
||||
}
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.image = image;
|
||||
this.anchor = anchor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the x-coordinate (in data space) for the annotation.
|
||||
*
|
||||
* @return The x-coordinate.
|
||||
*
|
||||
* @since 1.0.4
|
||||
*/
|
||||
public double getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the y-coordinate (in data space) for the annotation.
|
||||
*
|
||||
* @return The y-coordinate.
|
||||
*
|
||||
* @since 1.0.4
|
||||
*/
|
||||
public double getY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the image for the annotation.
|
||||
*
|
||||
* @return The image.
|
||||
*
|
||||
* @since 1.0.4
|
||||
*/
|
||||
public Image getImage() {
|
||||
return this.image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the image anchor for the annotation.
|
||||
*
|
||||
* @return The image anchor.
|
||||
*
|
||||
* @since 1.0.4
|
||||
*/
|
||||
public RectangleAnchor getImageAnchor() {
|
||||
return this.anchor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the annotation. This method is called by the drawing code in the
|
||||
* {@link XYPlot} class, you don't normally need to call this method
|
||||
* directly.
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
* @param plot the plot.
|
||||
* @param dataArea the data area.
|
||||
* @param domainAxis the domain axis.
|
||||
* @param rangeAxis the range axis.
|
||||
* @param rendererIndex the renderer index.
|
||||
* @param info if supplied, this info object will be populated with
|
||||
* entity information.
|
||||
*/
|
||||
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea,
|
||||
ValueAxis domainAxis, ValueAxis rangeAxis,
|
||||
int rendererIndex,
|
||||
PlotRenderingInfo info) {
|
||||
|
||||
PlotOrientation orientation = plot.getOrientation();
|
||||
AxisLocation domainAxisLocation = plot.getDomainAxisLocation();
|
||||
AxisLocation rangeAxisLocation = plot.getRangeAxisLocation();
|
||||
RectangleEdge domainEdge
|
||||
= Plot.resolveDomainAxisLocation(domainAxisLocation, orientation);
|
||||
RectangleEdge rangeEdge
|
||||
= Plot.resolveRangeAxisLocation(rangeAxisLocation, orientation);
|
||||
float j2DX
|
||||
= (float) domainAxis.valueToJava2D(this.x, dataArea, domainEdge);
|
||||
float j2DY
|
||||
= (float) rangeAxis.valueToJava2D(this.y, dataArea, rangeEdge);
|
||||
float xx = 0.0f;
|
||||
float yy = 0.0f;
|
||||
if (orientation == PlotOrientation.HORIZONTAL) {
|
||||
xx = j2DY;
|
||||
yy = j2DX;
|
||||
}
|
||||
else if (orientation == PlotOrientation.VERTICAL) {
|
||||
xx = j2DX;
|
||||
yy = j2DY;
|
||||
}
|
||||
int w = this.image.getWidth(null);
|
||||
int h = this.image.getHeight(null);
|
||||
|
||||
Rectangle2D imageRect = new Rectangle2D.Double(0, 0, w, h);
|
||||
Point2D anchorPoint = RectangleAnchor.coordinates(imageRect,
|
||||
this.anchor);
|
||||
xx = xx - (float) anchorPoint.getX();
|
||||
yy = yy - (float) anchorPoint.getY();
|
||||
g2.drawImage(this.image, (int) xx, (int) yy, null);
|
||||
|
||||
String toolTip = getToolTipText();
|
||||
String url = getURL();
|
||||
if (toolTip != null || url != null) {
|
||||
addEntity(info, new Rectangle2D.Float(xx, yy, w, h), rendererIndex,
|
||||
toolTip, url);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this object for equality with an arbitrary object.
|
||||
*
|
||||
* @param obj the object (<code>null</code> permitted).
|
||||
*
|
||||
* @return A boolean.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
// now try to reject equality...
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof XYImageAnnotation)) {
|
||||
return false;
|
||||
}
|
||||
XYImageAnnotation that = (XYImageAnnotation) obj;
|
||||
if (this.x != that.x) {
|
||||
return false;
|
||||
}
|
||||
if (this.y != that.y) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtilities.equal(this.image, that.image)) {
|
||||
return false;
|
||||
}
|
||||
if (!this.anchor.equals(that.anchor)) {
|
||||
return false;
|
||||
}
|
||||
// seems to be the same...
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for this object.
|
||||
*
|
||||
* @return A hash code.
|
||||
*/
|
||||
public int hashCode() {
|
||||
return this.image.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone of the annotation.
|
||||
*
|
||||
* @return A clone.
|
||||
*
|
||||
* @throws CloneNotSupportedException if the annotation can't be cloned.
|
||||
*/
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the output stream.
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
*/
|
||||
private void writeObject(ObjectOutputStream stream) throws IOException {
|
||||
stream.defaultWriteObject();
|
||||
//SerialUtilities.writeImage(this.image, stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the input stream.
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
* @throws ClassNotFoundException if there is a classpath problem.
|
||||
*/
|
||||
private void readObject(ObjectInputStream stream)
|
||||
throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
//this.image = SerialUtilities.readImage(stream);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,312 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* ---------------------
|
||||
* XYLineAnnotation.java
|
||||
* ---------------------
|
||||
* (C) Copyright 2003-2008, by Object Refinery Limited.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes:
|
||||
* --------
|
||||
* 02-Apr-2003 : Version 1 (DG);
|
||||
* 19-Aug-2003 : Added equals method, implemented Cloneable, and applied
|
||||
* serialization fixes (DG);
|
||||
* 21-Jan-2004 : Update for renamed method in ValueAxis (DG);
|
||||
* 14-Apr-2004 : Fixed draw() method to handle plot orientation correctly (DG);
|
||||
* 29-Sep-2004 : Added support for tool tips and URLS, now extends
|
||||
* AbstractXYAnnotation (DG);
|
||||
* 04-Oct-2004 : Renamed ShapeUtils --> ShapeUtilities (DG);
|
||||
* 08-Jun-2005 : Fixed equals() method to handle GradientPaint() (DG);
|
||||
* 05-Nov-2008 : Added workaround for JRE bug 6574155, see JFreeChart bug
|
||||
* 2221495 (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.annotations;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Paint;
|
||||
import java.awt.Stroke;
|
||||
import java.awt.geom.Line2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.jfree.chart.axis.ValueAxis;
|
||||
import org.jfree.chart.plot.Plot;
|
||||
import org.jfree.chart.plot.PlotOrientation;
|
||||
import org.jfree.chart.plot.PlotRenderingInfo;
|
||||
import org.jfree.chart.plot.XYPlot;
|
||||
import org.jfree.chart.util.LineUtilities;
|
||||
import org.jfree.io.SerialUtilities;
|
||||
import org.jfree.ui.RectangleEdge;
|
||||
import org.jfree.util.ObjectUtilities;
|
||||
import org.jfree.util.PaintUtilities;
|
||||
import org.jfree.util.PublicCloneable;
|
||||
import org.jfree.util.ShapeUtilities;
|
||||
|
||||
/**
|
||||
* A simple line annotation that can be placed on an {@link XYPlot}.
|
||||
*/
|
||||
public class XYLineAnnotation extends AbstractXYAnnotation
|
||||
implements Cloneable, PublicCloneable, Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
private static final long serialVersionUID = -80535465244091334L;
|
||||
|
||||
/** The x-coordinate. */
|
||||
private double x1;
|
||||
|
||||
/** The y-coordinate. */
|
||||
private double y1;
|
||||
|
||||
/** The x-coordinate. */
|
||||
private double x2;
|
||||
|
||||
/** The y-coordinate. */
|
||||
private double y2;
|
||||
|
||||
/** The line stroke. */
|
||||
private transient Stroke stroke;
|
||||
|
||||
/** The line color. */
|
||||
private transient Paint paint;
|
||||
|
||||
/**
|
||||
* Creates a new annotation that draws a line from (x1, y1) to (x2, y2)
|
||||
* where the coordinates are measured in data space (that is, against the
|
||||
* plot's axes).
|
||||
*
|
||||
* @param x1 the x-coordinate for the start of the line.
|
||||
* @param y1 the y-coordinate for the start of the line.
|
||||
* @param x2 the x-coordinate for the end of the line.
|
||||
* @param y2 the y-coordinate for the end of the line.
|
||||
*/
|
||||
public XYLineAnnotation(double x1, double y1, double x2, double y2) {
|
||||
this(x1, y1, x2, y2, new BasicStroke(1.0f), Color.black);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new annotation that draws a line from (x1, y1) to (x2, y2)
|
||||
* where the coordinates are measured in data space (that is, against the
|
||||
* plot's axes).
|
||||
*
|
||||
* @param x1 the x-coordinate for the start of the line.
|
||||
* @param y1 the y-coordinate for the start of the line.
|
||||
* @param x2 the x-coordinate for the end of the line.
|
||||
* @param y2 the y-coordinate for the end of the line.
|
||||
* @param stroke the line stroke (<code>null</code> not permitted).
|
||||
* @param paint the line color (<code>null</code> not permitted).
|
||||
*/
|
||||
public XYLineAnnotation(double x1, double y1, double x2, double y2,
|
||||
Stroke stroke, Paint paint) {
|
||||
|
||||
if (stroke == null) {
|
||||
throw new IllegalArgumentException("Null 'stroke' argument.");
|
||||
}
|
||||
if (paint == null) {
|
||||
throw new IllegalArgumentException("Null 'paint' argument.");
|
||||
}
|
||||
this.x1 = x1;
|
||||
this.y1 = y1;
|
||||
this.x2 = x2;
|
||||
this.y2 = y2;
|
||||
this.stroke = stroke;
|
||||
this.paint = paint;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the annotation. This method is called by the {@link XYPlot}
|
||||
* class, you won't normally need to call it yourself.
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
* @param plot the plot.
|
||||
* @param dataArea the data area.
|
||||
* @param domainAxis the domain axis.
|
||||
* @param rangeAxis the range axis.
|
||||
* @param rendererIndex the renderer index.
|
||||
* @param info if supplied, this info object will be populated with
|
||||
* entity information.
|
||||
*/
|
||||
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea,
|
||||
ValueAxis domainAxis, ValueAxis rangeAxis,
|
||||
int rendererIndex,
|
||||
PlotRenderingInfo info) {
|
||||
|
||||
PlotOrientation orientation = plot.getOrientation();
|
||||
RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
|
||||
plot.getDomainAxisLocation(), orientation);
|
||||
RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
|
||||
plot.getRangeAxisLocation(), orientation);
|
||||
float j2DX1 = 0.0f;
|
||||
float j2DX2 = 0.0f;
|
||||
float j2DY1 = 0.0f;
|
||||
float j2DY2 = 0.0f;
|
||||
if (orientation == PlotOrientation.VERTICAL) {
|
||||
j2DX1 = (float) domainAxis.valueToJava2D(this.x1, dataArea,
|
||||
domainEdge);
|
||||
j2DY1 = (float) rangeAxis.valueToJava2D(this.y1, dataArea,
|
||||
rangeEdge);
|
||||
j2DX2 = (float) domainAxis.valueToJava2D(this.x2, dataArea,
|
||||
domainEdge);
|
||||
j2DY2 = (float) rangeAxis.valueToJava2D(this.y2, dataArea,
|
||||
rangeEdge);
|
||||
}
|
||||
else if (orientation == PlotOrientation.HORIZONTAL) {
|
||||
j2DY1 = (float) domainAxis.valueToJava2D(this.x1, dataArea,
|
||||
domainEdge);
|
||||
j2DX1 = (float) rangeAxis.valueToJava2D(this.y1, dataArea,
|
||||
rangeEdge);
|
||||
j2DY2 = (float) domainAxis.valueToJava2D(this.x2, dataArea,
|
||||
domainEdge);
|
||||
j2DX2 = (float) rangeAxis.valueToJava2D(this.y2, dataArea,
|
||||
rangeEdge);
|
||||
}
|
||||
g2.setPaint(this.paint);
|
||||
g2.setStroke(this.stroke);
|
||||
Line2D line = new Line2D.Float(j2DX1, j2DY1, j2DX2, j2DY2);
|
||||
// line is clipped to avoid JRE bug 6574155, for more info
|
||||
// see JFreeChart bug 2221495
|
||||
boolean visible = LineUtilities.clipLine(line, dataArea);
|
||||
if (visible) {
|
||||
g2.draw(line);
|
||||
}
|
||||
|
||||
String toolTip = getToolTipText();
|
||||
String url = getURL();
|
||||
if (toolTip != null || url != null) {
|
||||
addEntity(info, ShapeUtilities.createLineRegion(line, 1.0f),
|
||||
rendererIndex, toolTip, url);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this object for equality with an arbitrary object.
|
||||
*
|
||||
* @param obj the object to test against (<code>null</code> permitted).
|
||||
*
|
||||
* @return <code>true</code> or <code>false</code>.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof XYLineAnnotation)) {
|
||||
return false;
|
||||
}
|
||||
XYLineAnnotation that = (XYLineAnnotation) obj;
|
||||
if (this.x1 != that.x1) {
|
||||
return false;
|
||||
}
|
||||
if (this.y1 != that.y1) {
|
||||
return false;
|
||||
}
|
||||
if (this.x2 != that.x2) {
|
||||
return false;
|
||||
}
|
||||
if (this.y2 != that.y2) {
|
||||
return false;
|
||||
}
|
||||
if (!PaintUtilities.equal(this.paint, that.paint)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtilities.equal(this.stroke, that.stroke)) {
|
||||
return false;
|
||||
}
|
||||
// seems to be the same...
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code.
|
||||
*
|
||||
* @return A hash code.
|
||||
*/
|
||||
public int hashCode() {
|
||||
int result;
|
||||
long temp;
|
||||
temp = Double.doubleToLongBits(this.x1);
|
||||
result = (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(this.x2);
|
||||
result = 29 * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(this.y1);
|
||||
result = 29 * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(this.y2);
|
||||
result = 29 * result + (int) (temp ^ (temp >>> 32));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone of the annotation.
|
||||
*
|
||||
* @return A clone.
|
||||
*
|
||||
* @throws CloneNotSupportedException if the annotation can't be cloned.
|
||||
*/
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the output stream.
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
*/
|
||||
private void writeObject(ObjectOutputStream stream) throws IOException {
|
||||
stream.defaultWriteObject();
|
||||
SerialUtilities.writePaint(this.paint, stream);
|
||||
SerialUtilities.writeStroke(this.stroke, stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the input stream.
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
* @throws ClassNotFoundException if there is a classpath problem.
|
||||
*/
|
||||
private void readObject(ObjectInputStream stream)
|
||||
throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
this.paint = SerialUtilities.readPaint(stream);
|
||||
this.stroke = SerialUtilities.readStroke(stream);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,532 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* ------------------------
|
||||
* XYPointerAnnotation.java
|
||||
* ------------------------
|
||||
* (C) Copyright 2003-2008, by Object Refinery Limited.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes:
|
||||
* --------
|
||||
* 21-May-2003 : Version 1 (DG);
|
||||
* 10-Jun-2003 : Changed BoundsAnchor to TextAnchor (DG);
|
||||
* 02-Jul-2003 : Added accessor methods and simplified constructor (DG);
|
||||
* 19-Aug-2003 : Implemented Cloneable (DG);
|
||||
* 13-Oct-2003 : Fixed bug where arrow paint is not set correctly (DG);
|
||||
* 21-Jan-2004 : Update for renamed method in ValueAxis (DG);
|
||||
* 29-Sep-2004 : Changes to draw() method signature (DG);
|
||||
* ------------- JFREECHART 1.0.x ---------------------------------------------
|
||||
* 20-Feb-2006 : Correction for equals() method (fixes bug 1435160) (DG);
|
||||
* 12-Jul-2006 : Fix drawing for PlotOrientation.HORIZONTAL, thanks to
|
||||
* Skunk (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.annotations;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Paint;
|
||||
import java.awt.Stroke;
|
||||
import java.awt.geom.GeneralPath;
|
||||
import java.awt.geom.Line2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.jfree.chart.HashUtilities;
|
||||
import org.jfree.chart.axis.ValueAxis;
|
||||
import org.jfree.chart.plot.Plot;
|
||||
import org.jfree.chart.plot.PlotOrientation;
|
||||
import org.jfree.chart.plot.PlotRenderingInfo;
|
||||
import org.jfree.chart.plot.XYPlot;
|
||||
import org.jfree.io.SerialUtilities;
|
||||
import org.jfree.text.TextUtilities;
|
||||
import org.jfree.ui.RectangleEdge;
|
||||
import org.jfree.util.ObjectUtilities;
|
||||
import org.jfree.util.PublicCloneable;
|
||||
|
||||
/**
|
||||
* An arrow and label that can be placed on an
|
||||
* {@link org.jfree.chart.plot.XYPlot}. The arrow is drawn at a user-definable
|
||||
* angle so that it points towards the (x, y) location for the annotation.
|
||||
* <p>
|
||||
* The arrow length (and its offset from the (x, y) location) is controlled by
|
||||
* the tip radius and the base radius attributes. Imagine two circles around
|
||||
* the (x, y) coordinate: the inner circle defined by the tip radius, and the
|
||||
* outer circle defined by the base radius. Now, draw the arrow starting at
|
||||
* some point on the outer circle (the point is determined by the angle), with
|
||||
* the arrow tip being drawn at a corresponding point on the inner circle.
|
||||
*
|
||||
*/
|
||||
public class XYPointerAnnotation extends XYTextAnnotation
|
||||
implements Cloneable, PublicCloneable, Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
private static final long serialVersionUID = -4031161445009858551L;
|
||||
|
||||
/** The default tip radius (in Java2D units). */
|
||||
public static final double DEFAULT_TIP_RADIUS = 10.0;
|
||||
|
||||
/** The default base radius (in Java2D units). */
|
||||
public static final double DEFAULT_BASE_RADIUS = 30.0;
|
||||
|
||||
/** The default label offset (in Java2D units). */
|
||||
public static final double DEFAULT_LABEL_OFFSET = 3.0;
|
||||
|
||||
/** The default arrow length (in Java2D units). */
|
||||
public static final double DEFAULT_ARROW_LENGTH = 5.0;
|
||||
|
||||
/** The default arrow width (in Java2D units). */
|
||||
public static final double DEFAULT_ARROW_WIDTH = 3.0;
|
||||
|
||||
/** The angle of the arrow's line (in radians). */
|
||||
private double angle;
|
||||
|
||||
/**
|
||||
* The radius from the (x, y) point to the tip of the arrow (in Java2D
|
||||
* units).
|
||||
*/
|
||||
private double tipRadius;
|
||||
|
||||
/**
|
||||
* The radius from the (x, y) point to the start of the arrow line (in
|
||||
* Java2D units).
|
||||
*/
|
||||
private double baseRadius;
|
||||
|
||||
/** The length of the arrow head (in Java2D units). */
|
||||
private double arrowLength;
|
||||
|
||||
/** The arrow width (in Java2D units, per side). */
|
||||
private double arrowWidth;
|
||||
|
||||
/** The arrow stroke. */
|
||||
private transient Stroke arrowStroke;
|
||||
|
||||
/** The arrow paint. */
|
||||
private transient Paint arrowPaint;
|
||||
|
||||
/** The radius from the base point to the anchor point for the label. */
|
||||
private double labelOffset;
|
||||
|
||||
/**
|
||||
* Creates a new label and arrow annotation.
|
||||
*
|
||||
* @param label the label (<code>null</code> permitted).
|
||||
* @param x the x-coordinate (measured against the chart's domain axis).
|
||||
* @param y the y-coordinate (measured against the chart's range axis).
|
||||
* @param angle the angle of the arrow's line (in radians).
|
||||
*/
|
||||
public XYPointerAnnotation(String label, double x, double y, double angle) {
|
||||
|
||||
super(label, x, y);
|
||||
this.angle = angle;
|
||||
this.tipRadius = DEFAULT_TIP_RADIUS;
|
||||
this.baseRadius = DEFAULT_BASE_RADIUS;
|
||||
this.arrowLength = DEFAULT_ARROW_LENGTH;
|
||||
this.arrowWidth = DEFAULT_ARROW_WIDTH;
|
||||
this.labelOffset = DEFAULT_LABEL_OFFSET;
|
||||
this.arrowStroke = new BasicStroke(1.0f);
|
||||
this.arrowPaint = Color.black;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the angle of the arrow.
|
||||
*
|
||||
* @return The angle (in radians).
|
||||
*
|
||||
* @see #setAngle(double)
|
||||
*/
|
||||
public double getAngle() {
|
||||
return this.angle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the angle of the arrow.
|
||||
*
|
||||
* @param angle the angle (in radians).
|
||||
*
|
||||
* @see #getAngle()
|
||||
*/
|
||||
public void setAngle(double angle) {
|
||||
this.angle = angle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tip radius.
|
||||
*
|
||||
* @return The tip radius (in Java2D units).
|
||||
*
|
||||
* @see #setTipRadius(double)
|
||||
*/
|
||||
public double getTipRadius() {
|
||||
return this.tipRadius;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the tip radius.
|
||||
*
|
||||
* @param radius the radius (in Java2D units).
|
||||
*
|
||||
* @see #getTipRadius()
|
||||
*/
|
||||
public void setTipRadius(double radius) {
|
||||
this.tipRadius = radius;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the base radius.
|
||||
*
|
||||
* @return The base radius (in Java2D units).
|
||||
*
|
||||
* @see #setBaseRadius(double)
|
||||
*/
|
||||
public double getBaseRadius() {
|
||||
return this.baseRadius;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the base radius.
|
||||
*
|
||||
* @param radius the radius (in Java2D units).
|
||||
*
|
||||
* @see #getBaseRadius()
|
||||
*/
|
||||
public void setBaseRadius(double radius) {
|
||||
this.baseRadius = radius;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the label offset.
|
||||
*
|
||||
* @return The label offset (in Java2D units).
|
||||
*
|
||||
* @see #setLabelOffset(double)
|
||||
*/
|
||||
public double getLabelOffset() {
|
||||
return this.labelOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the label offset (from the arrow base, continuing in a straight
|
||||
* line, in Java2D units).
|
||||
*
|
||||
* @param offset the offset (in Java2D units).
|
||||
*
|
||||
* @see #getLabelOffset()
|
||||
*/
|
||||
public void setLabelOffset(double offset) {
|
||||
this.labelOffset = offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the arrow length.
|
||||
*
|
||||
* @return The arrow length.
|
||||
*
|
||||
* @see #setArrowLength(double)
|
||||
*/
|
||||
public double getArrowLength() {
|
||||
return this.arrowLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the arrow length.
|
||||
*
|
||||
* @param length the length.
|
||||
*
|
||||
* @see #getArrowLength()
|
||||
*/
|
||||
public void setArrowLength(double length) {
|
||||
this.arrowLength = length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the arrow width.
|
||||
*
|
||||
* @return The arrow width (in Java2D units).
|
||||
*
|
||||
* @see #setArrowWidth(double)
|
||||
*/
|
||||
public double getArrowWidth() {
|
||||
return this.arrowWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the arrow width.
|
||||
*
|
||||
* @param width the width (in Java2D units).
|
||||
*
|
||||
* @see #getArrowWidth()
|
||||
*/
|
||||
public void setArrowWidth(double width) {
|
||||
this.arrowWidth = width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the stroke used to draw the arrow line.
|
||||
*
|
||||
* @return The arrow stroke (never <code>null</code>).
|
||||
*
|
||||
* @see #setArrowStroke(Stroke)
|
||||
*/
|
||||
public Stroke getArrowStroke() {
|
||||
return this.arrowStroke;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the stroke used to draw the arrow line.
|
||||
*
|
||||
* @param stroke the stroke (<code>null</code> not permitted).
|
||||
*
|
||||
* @see #getArrowStroke()
|
||||
*/
|
||||
public void setArrowStroke(Stroke stroke) {
|
||||
if (stroke == null) {
|
||||
throw new IllegalArgumentException("Null 'stroke' not permitted.");
|
||||
}
|
||||
this.arrowStroke = stroke;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the paint used for the arrow.
|
||||
*
|
||||
* @return The arrow paint (never <code>null</code>).
|
||||
*
|
||||
* @see #setArrowPaint(Paint)
|
||||
*/
|
||||
public Paint getArrowPaint() {
|
||||
return this.arrowPaint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the paint used for the arrow.
|
||||
*
|
||||
* @param paint the arrow paint (<code>null</code> not permitted).
|
||||
*
|
||||
* @see #getArrowPaint()
|
||||
*/
|
||||
public void setArrowPaint(Paint paint) {
|
||||
if (paint == null) {
|
||||
throw new IllegalArgumentException("Null 'paint' argument.");
|
||||
}
|
||||
this.arrowPaint = paint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the annotation.
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
* @param plot the plot.
|
||||
* @param dataArea the data area.
|
||||
* @param domainAxis the domain axis.
|
||||
* @param rangeAxis the range axis.
|
||||
* @param rendererIndex the renderer index.
|
||||
* @param info the plot rendering info.
|
||||
*/
|
||||
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea,
|
||||
ValueAxis domainAxis, ValueAxis rangeAxis,
|
||||
int rendererIndex,
|
||||
PlotRenderingInfo info) {
|
||||
|
||||
PlotOrientation orientation = plot.getOrientation();
|
||||
RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
|
||||
plot.getDomainAxisLocation(), orientation);
|
||||
RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
|
||||
plot.getRangeAxisLocation(), orientation);
|
||||
double j2DX = domainAxis.valueToJava2D(getX(), dataArea, domainEdge);
|
||||
double j2DY = rangeAxis.valueToJava2D(getY(), dataArea, rangeEdge);
|
||||
if (orientation == PlotOrientation.HORIZONTAL) {
|
||||
double temp = j2DX;
|
||||
j2DX = j2DY;
|
||||
j2DY = temp;
|
||||
}
|
||||
double startX = j2DX + Math.cos(this.angle) * this.baseRadius;
|
||||
double startY = j2DY + Math.sin(this.angle) * this.baseRadius;
|
||||
|
||||
double endX = j2DX + Math.cos(this.angle) * this.tipRadius;
|
||||
double endY = j2DY + Math.sin(this.angle) * this.tipRadius;
|
||||
|
||||
double arrowBaseX = endX + Math.cos(this.angle) * this.arrowLength;
|
||||
double arrowBaseY = endY + Math.sin(this.angle) * this.arrowLength;
|
||||
|
||||
double arrowLeftX = arrowBaseX
|
||||
+ Math.cos(this.angle + Math.PI / 2.0) * this.arrowWidth;
|
||||
double arrowLeftY = arrowBaseY
|
||||
+ Math.sin(this.angle + Math.PI / 2.0) * this.arrowWidth;
|
||||
|
||||
double arrowRightX = arrowBaseX
|
||||
- Math.cos(this.angle + Math.PI / 2.0) * this.arrowWidth;
|
||||
double arrowRightY = arrowBaseY
|
||||
- Math.sin(this.angle + Math.PI / 2.0) * this.arrowWidth;
|
||||
|
||||
GeneralPath arrow = new GeneralPath();
|
||||
arrow.moveTo((float) endX, (float) endY);
|
||||
arrow.lineTo((float) arrowLeftX, (float) arrowLeftY);
|
||||
arrow.lineTo((float) arrowRightX, (float) arrowRightY);
|
||||
arrow.closePath();
|
||||
|
||||
g2.setStroke(this.arrowStroke);
|
||||
g2.setPaint(this.arrowPaint);
|
||||
Line2D line = new Line2D.Double(startX, startY, endX, endY);
|
||||
g2.draw(line);
|
||||
g2.fill(arrow);
|
||||
|
||||
// draw the label
|
||||
g2.setFont(getFont());
|
||||
g2.setPaint(getPaint());
|
||||
double labelX = j2DX
|
||||
+ Math.cos(this.angle) * (this.baseRadius + this.labelOffset);
|
||||
double labelY = j2DY
|
||||
+ Math.sin(this.angle) * (this.baseRadius + this.labelOffset);
|
||||
Rectangle2D hotspot = TextUtilities.drawAlignedString(getText(),
|
||||
g2, (float) labelX, (float) labelY, getTextAnchor());
|
||||
|
||||
String toolTip = getToolTipText();
|
||||
String url = getURL();
|
||||
if (toolTip != null || url != null) {
|
||||
addEntity(info, hotspot, rendererIndex, toolTip, url);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this annotation for equality with an arbitrary object.
|
||||
*
|
||||
* @param obj the object (<code>null</code> permitted).
|
||||
*
|
||||
* @return <code>true</code> or <code>false</code>.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof XYPointerAnnotation)) {
|
||||
return false;
|
||||
}
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
XYPointerAnnotation that = (XYPointerAnnotation) obj;
|
||||
if (this.angle != that.angle) {
|
||||
return false;
|
||||
}
|
||||
if (this.tipRadius != that.tipRadius) {
|
||||
return false;
|
||||
}
|
||||
if (this.baseRadius != that.baseRadius) {
|
||||
return false;
|
||||
}
|
||||
if (this.arrowLength != that.arrowLength) {
|
||||
return false;
|
||||
}
|
||||
if (this.arrowWidth != that.arrowWidth) {
|
||||
return false;
|
||||
}
|
||||
if (!this.arrowPaint.equals(that.arrowPaint)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtilities.equal(this.arrowStroke, that.arrowStroke)) {
|
||||
return false;
|
||||
}
|
||||
if (this.labelOffset != that.labelOffset) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for this instance.
|
||||
*
|
||||
* @return A hash code.
|
||||
*/
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
long temp = Double.doubleToLongBits(this.angle);
|
||||
result = 37 * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(this.tipRadius);
|
||||
result = 37 * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(this.baseRadius);
|
||||
result = 37 * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(this.arrowLength);
|
||||
result = 37 * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(this.arrowWidth);
|
||||
result = 37 * result + (int) (temp ^ (temp >>> 32));
|
||||
result = result * 37 + HashUtilities.hashCodeForPaint(this.arrowPaint);
|
||||
result = result * 37 + this.arrowStroke.hashCode();
|
||||
temp = Double.doubleToLongBits(this.labelOffset);
|
||||
result = 37 * result + (int) (temp ^ (temp >>> 32));
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone of the annotation.
|
||||
*
|
||||
* @return A clone.
|
||||
*
|
||||
* @throws CloneNotSupportedException if the annotation can't be cloned.
|
||||
*/
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the output stream.
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
*/
|
||||
private void writeObject(ObjectOutputStream stream) throws IOException {
|
||||
stream.defaultWriteObject();
|
||||
SerialUtilities.writePaint(this.arrowPaint, stream);
|
||||
SerialUtilities.writeStroke(this.arrowStroke, stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the input stream.
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
* @throws ClassNotFoundException if there is a classpath problem.
|
||||
*/
|
||||
private void readObject(ObjectInputStream stream)
|
||||
throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
this.arrowPaint = SerialUtilities.readPaint(stream);
|
||||
this.arrowStroke = SerialUtilities.readStroke(stream);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,359 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* ------------------------
|
||||
* XYPolygonAnnotation.java
|
||||
* ------------------------
|
||||
* (C) Copyright 2005-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes:
|
||||
* --------
|
||||
* 09-Feb-2005 : Version 1 (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.annotations;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Paint;
|
||||
import java.awt.Stroke;
|
||||
import java.awt.geom.GeneralPath;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.jfree.chart.HashUtilities;
|
||||
import org.jfree.chart.axis.ValueAxis;
|
||||
import org.jfree.chart.plot.Plot;
|
||||
import org.jfree.chart.plot.PlotOrientation;
|
||||
import org.jfree.chart.plot.PlotRenderingInfo;
|
||||
import org.jfree.chart.plot.XYPlot;
|
||||
import org.jfree.io.SerialUtilities;
|
||||
import org.jfree.ui.RectangleEdge;
|
||||
import org.jfree.util.ObjectUtilities;
|
||||
import org.jfree.util.PaintUtilities;
|
||||
import org.jfree.util.PublicCloneable;
|
||||
|
||||
/**
|
||||
* A polygon annotation that can be placed on an {@link XYPlot}. The
|
||||
* polygon coordinates are specified in data space.
|
||||
*/
|
||||
public class XYPolygonAnnotation extends AbstractXYAnnotation
|
||||
implements Cloneable, PublicCloneable, Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
private static final long serialVersionUID = -6984203651995900036L;
|
||||
|
||||
/** The polygon. */
|
||||
private double[] polygon;
|
||||
|
||||
/** The stroke used to draw the box outline. */
|
||||
private transient Stroke stroke;
|
||||
|
||||
/** The paint used to draw the box outline. */
|
||||
private transient Paint outlinePaint;
|
||||
|
||||
/** The paint used to fill the box. */
|
||||
private transient Paint fillPaint;
|
||||
|
||||
/**
|
||||
* Creates a new annotation (where, by default, the polygon is drawn
|
||||
* with a black outline). The array of polygon coordinates must contain
|
||||
* an even number of coordinates (each pair is an (x, y) location on the
|
||||
* plot) and the last point is automatically joined back to the first point.
|
||||
*
|
||||
* @param polygon the coordinates of the polygon's vertices
|
||||
* (<code>null</code> not permitted).
|
||||
*/
|
||||
public XYPolygonAnnotation(double[] polygon) {
|
||||
this(polygon, new BasicStroke(1.0f), Color.black);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new annotation where the box is drawn as an outline using
|
||||
* the specified <code>stroke</code> and <code>outlinePaint</code>.
|
||||
* The array of polygon coordinates must contain an even number of
|
||||
* coordinates (each pair is an (x, y) location on the plot) and the last
|
||||
* point is automatically joined back to the first point.
|
||||
*
|
||||
* @param polygon the coordinates of the polygon's vertices
|
||||
* (<code>null</code> not permitted).
|
||||
* @param stroke the shape stroke (<code>null</code> permitted).
|
||||
* @param outlinePaint the shape color (<code>null</code> permitted).
|
||||
*/
|
||||
public XYPolygonAnnotation(double[] polygon,
|
||||
Stroke stroke, Paint outlinePaint) {
|
||||
this(polygon, stroke, outlinePaint, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new annotation. The array of polygon coordinates must
|
||||
* contain an even number of coordinates (each pair is an (x, y) location
|
||||
* on the plot) and the last point is automatically joined back to the
|
||||
* first point.
|
||||
*
|
||||
* @param polygon the coordinates of the polygon's vertices
|
||||
* (<code>null</code> not permitted).
|
||||
* @param stroke the shape stroke (<code>null</code> permitted).
|
||||
* @param outlinePaint the shape color (<code>null</code> permitted).
|
||||
* @param fillPaint the paint used to fill the shape (<code>null</code>
|
||||
* permitted).
|
||||
*/
|
||||
public XYPolygonAnnotation(double[] polygon,
|
||||
Stroke stroke,
|
||||
Paint outlinePaint, Paint fillPaint) {
|
||||
if (polygon == null) {
|
||||
throw new IllegalArgumentException("Null 'polygon' argument.");
|
||||
}
|
||||
if (polygon.length % 2 != 0) {
|
||||
throw new IllegalArgumentException("The 'polygon' array must "
|
||||
+ "contain an even number of items.");
|
||||
}
|
||||
this.polygon = (double[]) polygon.clone();
|
||||
this.stroke = stroke;
|
||||
this.outlinePaint = outlinePaint;
|
||||
this.fillPaint = fillPaint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the coordinates of the polygon's vertices. The returned array
|
||||
* is a copy, so it is safe to modify without altering the annotation's
|
||||
* state.
|
||||
*
|
||||
* @return The coordinates of the polygon's vertices.
|
||||
*
|
||||
* @since 1.0.2
|
||||
*/
|
||||
public double[] getPolygonCoordinates() {
|
||||
return (double[]) this.polygon.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the fill paint.
|
||||
*
|
||||
* @return The fill paint (possibly <code>null</code>).
|
||||
*
|
||||
* @since 1.0.2
|
||||
*/
|
||||
public Paint getFillPaint() {
|
||||
return this.fillPaint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the outline stroke.
|
||||
*
|
||||
* @return The outline stroke (possibly <code>null</code>).
|
||||
*
|
||||
* @since 1.0.2
|
||||
*/
|
||||
public Stroke getOutlineStroke() {
|
||||
return this.stroke;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the outline paint.
|
||||
*
|
||||
* @return The outline paint (possibly <code>null</code>).
|
||||
*
|
||||
* @since 1.0.2
|
||||
*/
|
||||
public Paint getOutlinePaint() {
|
||||
return this.outlinePaint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the annotation. This method is usually called by the
|
||||
* {@link XYPlot} class, you shouldn't need to call it directly.
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
* @param plot the plot.
|
||||
* @param dataArea the data area.
|
||||
* @param domainAxis the domain axis.
|
||||
* @param rangeAxis the range axis.
|
||||
* @param rendererIndex the renderer index.
|
||||
* @param info the plot rendering info.
|
||||
*/
|
||||
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea,
|
||||
ValueAxis domainAxis, ValueAxis rangeAxis,
|
||||
int rendererIndex, PlotRenderingInfo info) {
|
||||
|
||||
// if we don't have at least 2 (x, y) coordinates, just return
|
||||
if (this.polygon.length < 4) {
|
||||
return;
|
||||
}
|
||||
PlotOrientation orientation = plot.getOrientation();
|
||||
RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
|
||||
plot.getDomainAxisLocation(), orientation);
|
||||
RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
|
||||
plot.getRangeAxisLocation(), orientation);
|
||||
|
||||
GeneralPath area = new GeneralPath();
|
||||
double x = domainAxis.valueToJava2D(this.polygon[0], dataArea,
|
||||
domainEdge);
|
||||
double y = rangeAxis.valueToJava2D(this.polygon[1], dataArea,
|
||||
rangeEdge);
|
||||
if (orientation == PlotOrientation.HORIZONTAL) {
|
||||
area.moveTo((float) y, (float) x);
|
||||
for (int i = 2; i < this.polygon.length; i += 2) {
|
||||
x = domainAxis.valueToJava2D(this.polygon[i], dataArea,
|
||||
domainEdge);
|
||||
y = rangeAxis.valueToJava2D(this.polygon[i + 1], dataArea,
|
||||
rangeEdge);
|
||||
area.lineTo((float) y, (float) x);
|
||||
}
|
||||
area.closePath();
|
||||
}
|
||||
else if (orientation == PlotOrientation.VERTICAL) {
|
||||
area.moveTo((float) x, (float) y);
|
||||
for (int i = 2; i < this.polygon.length; i += 2) {
|
||||
x = domainAxis.valueToJava2D(this.polygon[i], dataArea,
|
||||
domainEdge);
|
||||
y = rangeAxis.valueToJava2D(this.polygon[i + 1], dataArea,
|
||||
rangeEdge);
|
||||
area.lineTo((float) x, (float) y);
|
||||
}
|
||||
area.closePath();
|
||||
}
|
||||
|
||||
|
||||
if (this.fillPaint != null) {
|
||||
g2.setPaint(this.fillPaint);
|
||||
g2.fill(area);
|
||||
}
|
||||
|
||||
if (this.stroke != null && this.outlinePaint != null) {
|
||||
g2.setPaint(this.outlinePaint);
|
||||
g2.setStroke(this.stroke);
|
||||
g2.draw(area);
|
||||
}
|
||||
addEntity(info, area, rendererIndex, getToolTipText(), getURL());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this annotation for equality with an arbitrary object.
|
||||
*
|
||||
* @param obj the object (<code>null</code> permitted).
|
||||
*
|
||||
* @return A boolean.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
// now try to reject equality
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof XYPolygonAnnotation)) {
|
||||
return false;
|
||||
}
|
||||
XYPolygonAnnotation that = (XYPolygonAnnotation) obj;
|
||||
if (!Arrays.equals(this.polygon, that.polygon)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtilities.equal(this.stroke, that.stroke)) {
|
||||
return false;
|
||||
}
|
||||
if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) {
|
||||
return false;
|
||||
}
|
||||
if (!PaintUtilities.equal(this.fillPaint, that.fillPaint)) {
|
||||
return false;
|
||||
}
|
||||
// seem to be the same
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for this instance.
|
||||
*
|
||||
* @return A hash code.
|
||||
*/
|
||||
public int hashCode() {
|
||||
int result = 193;
|
||||
result = 37 * result + HashUtilities.hashCodeForDoubleArray(
|
||||
this.polygon);
|
||||
result = 37 * result + HashUtilities.hashCodeForPaint(this.fillPaint);
|
||||
result = 37 * result + HashUtilities.hashCodeForPaint(
|
||||
this.outlinePaint);
|
||||
if (this.stroke != null) {
|
||||
result = 37 * result + this.stroke.hashCode();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone.
|
||||
*
|
||||
* @return A clone.
|
||||
*
|
||||
* @throws CloneNotSupportedException not thrown by this class, but may be
|
||||
* by subclasses.
|
||||
*/
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the output stream (<code>null</code> not permitted).
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
*/
|
||||
private void writeObject(ObjectOutputStream stream) throws IOException {
|
||||
stream.defaultWriteObject();
|
||||
SerialUtilities.writeStroke(this.stroke, stream);
|
||||
SerialUtilities.writePaint(this.outlinePaint, stream);
|
||||
SerialUtilities.writePaint(this.fillPaint, stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the input stream (<code>null</code> not permitted).
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
* @throws ClassNotFoundException if there is a classpath problem.
|
||||
*/
|
||||
private void readObject(ObjectInputStream stream)
|
||||
throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
this.stroke = SerialUtilities.readStroke(stream);
|
||||
this.outlinePaint = SerialUtilities.readPaint(stream);
|
||||
this.fillPaint = SerialUtilities.readPaint(stream);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,310 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* ----------------------
|
||||
* XYShapeAnnotation.java
|
||||
* ----------------------
|
||||
* (C) Copyright 2003-2008, by Ondax, Inc. and Contributors.
|
||||
*
|
||||
* Original Author: Greg Steckman (for Ondax, Inc.);
|
||||
* Contributor(s): David Gilbert (for Object Refinery Limited);
|
||||
*
|
||||
* Changes:
|
||||
* --------
|
||||
* 15-Aug-2003 : Version 1, adapted from
|
||||
* org.jfree.chart.annotations.XYLineAnnotation (GS);
|
||||
* 21-Jan-2004 : Update for renamed method in ValueAxis (DG);
|
||||
* 20-Apr-2004 : Added new constructor and fixed bug 934258 (DG);
|
||||
* 29-Sep-2004 : Added 'fillPaint' to allow for colored shapes, now extends
|
||||
* AbstractXYAnnotation to add tool tip and URL support, and
|
||||
* implemented equals() and Cloneable (DG);
|
||||
* 21-Jan-2005 : Modified constructor for consistency with other
|
||||
* constructors (DG);
|
||||
* 06-Jun-2005 : Fixed equals() method to handle GradientPaint (DG);
|
||||
* ------------- JFREECHART 1.0.x ---------------------------------------------
|
||||
* 24-Oct-2006 : Calculate AffineTransform on shape's bounding rectangle
|
||||
* rather than sample points (0, 0) and (1, 1) (DG);
|
||||
* 06-Mar-2007 : Implemented hashCode() (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.annotations;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Paint;
|
||||
import java.awt.Shape;
|
||||
import java.awt.Stroke;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.jfree.chart.HashUtilities;
|
||||
import org.jfree.chart.axis.ValueAxis;
|
||||
import org.jfree.chart.plot.Plot;
|
||||
import org.jfree.chart.plot.PlotOrientation;
|
||||
import org.jfree.chart.plot.PlotRenderingInfo;
|
||||
import org.jfree.chart.plot.XYPlot;
|
||||
import org.jfree.io.SerialUtilities;
|
||||
import org.jfree.ui.RectangleEdge;
|
||||
import org.jfree.util.ObjectUtilities;
|
||||
import org.jfree.util.PaintUtilities;
|
||||
import org.jfree.util.PublicCloneable;
|
||||
|
||||
/**
|
||||
* A simple <code>Shape</code> annotation that can be placed on an
|
||||
* {@link XYPlot}. The shape coordinates are specified in data space.
|
||||
*/
|
||||
public class XYShapeAnnotation extends AbstractXYAnnotation
|
||||
implements Cloneable, PublicCloneable, Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
private static final long serialVersionUID = -8553218317600684041L;
|
||||
|
||||
/** The shape. */
|
||||
private transient Shape shape;
|
||||
|
||||
/** The stroke used to draw the shape's outline. */
|
||||
private transient Stroke stroke;
|
||||
|
||||
/** The paint used to draw the shape's outline. */
|
||||
private transient Paint outlinePaint;
|
||||
|
||||
/** The paint used to fill the shape. */
|
||||
private transient Paint fillPaint;
|
||||
|
||||
/**
|
||||
* Creates a new annotation (where, by default, the shape is drawn
|
||||
* with a black outline).
|
||||
*
|
||||
* @param shape the shape (coordinates in data space, <code>null</code>
|
||||
* not permitted).
|
||||
*/
|
||||
public XYShapeAnnotation(Shape shape) {
|
||||
this(shape, new BasicStroke(1.0f), Color.black);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new annotation where the shape is drawn as an outline using
|
||||
* the specified <code>stroke</code> and <code>outlinePaint</code>.
|
||||
*
|
||||
* @param shape the shape (<code>null</code> not permitted).
|
||||
* @param stroke the shape stroke (<code>null</code> permitted).
|
||||
* @param outlinePaint the shape color (<code>null</code> permitted).
|
||||
*/
|
||||
public XYShapeAnnotation(Shape shape, Stroke stroke, Paint outlinePaint) {
|
||||
this(shape, stroke, outlinePaint, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new annotation.
|
||||
*
|
||||
* @param shape the shape (<code>null</code> not permitted).
|
||||
* @param stroke the shape stroke (<code>null</code> permitted).
|
||||
* @param outlinePaint the shape color (<code>null</code> permitted).
|
||||
* @param fillPaint the paint used to fill the shape (<code>null</code>
|
||||
* permitted.
|
||||
*/
|
||||
public XYShapeAnnotation(Shape shape, Stroke stroke, Paint outlinePaint,
|
||||
Paint fillPaint) {
|
||||
if (shape == null) {
|
||||
throw new IllegalArgumentException("Null 'shape' argument.");
|
||||
}
|
||||
this.shape = shape;
|
||||
this.stroke = stroke;
|
||||
this.outlinePaint = outlinePaint;
|
||||
this.fillPaint = fillPaint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the annotation. This method is usually called by the
|
||||
* {@link XYPlot} class, you shouldn't need to call it directly.
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
* @param plot the plot.
|
||||
* @param dataArea the data area.
|
||||
* @param domainAxis the domain axis.
|
||||
* @param rangeAxis the range axis.
|
||||
* @param rendererIndex the renderer index.
|
||||
* @param info the plot rendering info.
|
||||
*/
|
||||
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea,
|
||||
ValueAxis domainAxis, ValueAxis rangeAxis,
|
||||
int rendererIndex,
|
||||
PlotRenderingInfo info) {
|
||||
|
||||
PlotOrientation orientation = plot.getOrientation();
|
||||
RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
|
||||
plot.getDomainAxisLocation(), orientation);
|
||||
RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
|
||||
plot.getRangeAxisLocation(), orientation);
|
||||
|
||||
// compute transform matrix elements via sample points. Assume no
|
||||
// rotation or shear.
|
||||
Rectangle2D bounds = this.shape.getBounds2D();
|
||||
double x0 = bounds.getMinX();
|
||||
double x1 = bounds.getMaxX();
|
||||
double xx0 = domainAxis.valueToJava2D(x0, dataArea, domainEdge);
|
||||
double xx1 = domainAxis.valueToJava2D(x1, dataArea, domainEdge);
|
||||
double m00 = (xx1 - xx0) / (x1 - x0);
|
||||
double m02 = xx0 - x0 * m00;
|
||||
|
||||
double y0 = bounds.getMaxY();
|
||||
double y1 = bounds.getMinY();
|
||||
double yy0 = rangeAxis.valueToJava2D(y0, dataArea, rangeEdge);
|
||||
double yy1 = rangeAxis.valueToJava2D(y1, dataArea, rangeEdge);
|
||||
double m11 = (yy1 - yy0) / (y1 - y0);
|
||||
double m12 = yy0 - m11 * y0;
|
||||
|
||||
// create transform & transform shape
|
||||
Shape s = null;
|
||||
if (orientation == PlotOrientation.HORIZONTAL) {
|
||||
AffineTransform t1 = new AffineTransform(0.0f, 1.0f, 1.0f, 0.0f,
|
||||
0.0f, 0.0f);
|
||||
AffineTransform t2 = new AffineTransform(m11, 0.0f, 0.0f, m00,
|
||||
m12, m02);
|
||||
s = t1.createTransformedShape(this.shape);
|
||||
s = t2.createTransformedShape(s);
|
||||
}
|
||||
else if (orientation == PlotOrientation.VERTICAL) {
|
||||
AffineTransform t = new AffineTransform(m00, 0, 0, m11, m02, m12);
|
||||
s = t.createTransformedShape(this.shape);
|
||||
}
|
||||
|
||||
if (this.fillPaint != null) {
|
||||
g2.setPaint(this.fillPaint);
|
||||
g2.fill(s);
|
||||
}
|
||||
|
||||
if (this.stroke != null && this.outlinePaint != null) {
|
||||
g2.setPaint(this.outlinePaint);
|
||||
g2.setStroke(this.stroke);
|
||||
g2.draw(s);
|
||||
}
|
||||
addEntity(info, s, rendererIndex, getToolTipText(), getURL());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this annotation for equality with an arbitrary object.
|
||||
*
|
||||
* @param obj the object (<code>null</code> permitted).
|
||||
*
|
||||
* @return A boolean.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
// now try to reject equality
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof XYShapeAnnotation)) {
|
||||
return false;
|
||||
}
|
||||
XYShapeAnnotation that = (XYShapeAnnotation) obj;
|
||||
if (!this.shape.equals(that.shape)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtilities.equal(this.stroke, that.stroke)) {
|
||||
return false;
|
||||
}
|
||||
if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) {
|
||||
return false;
|
||||
}
|
||||
if (!PaintUtilities.equal(this.fillPaint, that.fillPaint)) {
|
||||
return false;
|
||||
}
|
||||
// seem to be the same
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for this instance.
|
||||
*
|
||||
* @return A hash code.
|
||||
*/
|
||||
public int hashCode() {
|
||||
int result = 193;
|
||||
result = 37 * result + this.shape.hashCode();
|
||||
if (this.stroke != null) {
|
||||
result = 37 * result + this.stroke.hashCode();
|
||||
}
|
||||
result = 37 * result + HashUtilities.hashCodeForPaint(
|
||||
this.outlinePaint);
|
||||
result = 37 * result + HashUtilities.hashCodeForPaint(this.fillPaint);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone.
|
||||
*
|
||||
* @return A clone.
|
||||
*
|
||||
* @throws CloneNotSupportedException ???.
|
||||
*/
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the output stream.
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
*/
|
||||
private void writeObject(ObjectOutputStream stream) throws IOException {
|
||||
stream.defaultWriteObject();
|
||||
SerialUtilities.writeShape(this.shape, stream);
|
||||
SerialUtilities.writeStroke(this.stroke, stream);
|
||||
SerialUtilities.writePaint(this.outlinePaint, stream);
|
||||
SerialUtilities.writePaint(this.fillPaint, stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the input stream.
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
* @throws ClassNotFoundException if there is a classpath problem.
|
||||
*/
|
||||
private void readObject(ObjectInputStream stream)
|
||||
throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
this.shape = SerialUtilities.readShape(stream);
|
||||
this.stroke = SerialUtilities.readStroke(stream);
|
||||
this.outlinePaint = SerialUtilities.readPaint(stream);
|
||||
this.fillPaint = SerialUtilities.readPaint(stream);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,501 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* ---------------------
|
||||
* XYTextAnnotation.java
|
||||
* ---------------------
|
||||
* (C) Copyright 2002-2008, by Object Refinery Limited.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes:
|
||||
* --------
|
||||
* 28-Aug-2002 : Version 1 (DG);
|
||||
* 07-Nov-2002 : Fixed errors reported by Checkstyle (DG);
|
||||
* 13-Jan-2003 : Reviewed Javadocs (DG);
|
||||
* 26-Mar-2003 : Implemented Serializable (DG);
|
||||
* 02-Jul-2003 : Added new text alignment and rotation options (DG);
|
||||
* 19-Aug-2003 : Implemented Cloneable (DG);
|
||||
* 17-Jan-2003 : Added fix for bug 878706, where the annotation is placed
|
||||
* incorrectly for a plot with horizontal orientation (thanks to
|
||||
* Ed Yu for the fix) (DG);
|
||||
* 21-Jan-2004 : Update for renamed method in ValueAxis (DG);
|
||||
* ------------- JFREECHART 1.0.x ---------------------------------------------
|
||||
* 26-Jan-2006 : Fixed equals() method (bug 1415480) (DG);
|
||||
* 06-Mar-2007 : Added argument checks, re-implemented hashCode() method (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.annotations;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Paint;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.jfree.chart.HashUtilities;
|
||||
import org.jfree.chart.axis.ValueAxis;
|
||||
import org.jfree.chart.plot.Plot;
|
||||
import org.jfree.chart.plot.PlotOrientation;
|
||||
import org.jfree.chart.plot.PlotRenderingInfo;
|
||||
import org.jfree.chart.plot.XYPlot;
|
||||
import org.jfree.io.SerialUtilities;
|
||||
import org.jfree.text.TextUtilities;
|
||||
import org.jfree.ui.RectangleEdge;
|
||||
import org.jfree.ui.TextAnchor;
|
||||
import org.jfree.util.PaintUtilities;
|
||||
import org.jfree.util.PublicCloneable;
|
||||
|
||||
/**
|
||||
* A text annotation that can be placed at a particular (x, y) location on an
|
||||
* {@link XYPlot}.
|
||||
*/
|
||||
public class XYTextAnnotation extends AbstractXYAnnotation
|
||||
implements Cloneable, PublicCloneable, Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
private static final long serialVersionUID = -2946063342782506328L;
|
||||
|
||||
/** The default font. */
|
||||
public static final Font DEFAULT_FONT = new Font("SansSerif", Font.PLAIN,
|
||||
10);
|
||||
|
||||
/** The default paint. */
|
||||
public static final Paint DEFAULT_PAINT = Color.black;
|
||||
|
||||
/** The default text anchor. */
|
||||
public static final TextAnchor DEFAULT_TEXT_ANCHOR = TextAnchor.CENTER;
|
||||
|
||||
/** The default rotation anchor. */
|
||||
public static final TextAnchor DEFAULT_ROTATION_ANCHOR = TextAnchor.CENTER;
|
||||
|
||||
/** The default rotation angle. */
|
||||
public static final double DEFAULT_ROTATION_ANGLE = 0.0;
|
||||
|
||||
/** The text. */
|
||||
private String text;
|
||||
|
||||
/** The font. */
|
||||
private Font font;
|
||||
|
||||
/** The paint. */
|
||||
private transient Paint paint;
|
||||
|
||||
/** The x-coordinate. */
|
||||
private double x;
|
||||
|
||||
/** The y-coordinate. */
|
||||
private double y;
|
||||
|
||||
/** The text anchor (to be aligned with (x, y)). */
|
||||
private TextAnchor textAnchor;
|
||||
|
||||
/** The rotation anchor. */
|
||||
private TextAnchor rotationAnchor;
|
||||
|
||||
/** The rotation angle. */
|
||||
private double rotationAngle;
|
||||
|
||||
/**
|
||||
* Creates a new annotation to be displayed at the given coordinates. The
|
||||
* coordinates are specified in data space (they will be converted to
|
||||
* Java2D space for display).
|
||||
*
|
||||
* @param text the text (<code>null</code> not permitted).
|
||||
* @param x the x-coordinate (in data space).
|
||||
* @param y the y-coordinate (in data space).
|
||||
*/
|
||||
public XYTextAnnotation(String text, double x, double y) {
|
||||
if (text == null) {
|
||||
throw new IllegalArgumentException("Null 'text' argument.");
|
||||
}
|
||||
this.text = text;
|
||||
this.font = DEFAULT_FONT;
|
||||
this.paint = DEFAULT_PAINT;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.textAnchor = DEFAULT_TEXT_ANCHOR;
|
||||
this.rotationAnchor = DEFAULT_ROTATION_ANCHOR;
|
||||
this.rotationAngle = DEFAULT_ROTATION_ANGLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the text for the annotation.
|
||||
*
|
||||
* @return The text (never <code>null</code>).
|
||||
*
|
||||
* @see #setText(String)
|
||||
*/
|
||||
public String getText() {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the text for the annotation.
|
||||
*
|
||||
* @param text the text (<code>null</code> not permitted).
|
||||
*
|
||||
* @see #getText()
|
||||
*/
|
||||
public void setText(String text) {
|
||||
if (text == null) {
|
||||
throw new IllegalArgumentException("Null 'text' argument.");
|
||||
}
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the font for the annotation.
|
||||
*
|
||||
* @return The font (never <code>null</code>).
|
||||
*
|
||||
* @see #setFont(Font)
|
||||
*/
|
||||
public Font getFont() {
|
||||
return this.font;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the font for the annotation.
|
||||
*
|
||||
* @param font the font (<code>null</code> not permitted).
|
||||
*
|
||||
* @see #getFont()
|
||||
*/
|
||||
public void setFont(Font font) {
|
||||
if (font == null) {
|
||||
throw new IllegalArgumentException("Null 'font' argument.");
|
||||
}
|
||||
this.font = font;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the paint for the annotation.
|
||||
*
|
||||
* @return The paint (never <code>null</code>).
|
||||
*
|
||||
* @see #setPaint(Paint)
|
||||
*/
|
||||
public Paint getPaint() {
|
||||
return this.paint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the paint for the annotation.
|
||||
*
|
||||
* @param paint the paint (<code>null</code> not permitted).
|
||||
*
|
||||
* @see #getPaint()
|
||||
*/
|
||||
public void setPaint(Paint paint) {
|
||||
if (paint == null) {
|
||||
throw new IllegalArgumentException("Null 'paint' argument.");
|
||||
}
|
||||
this.paint = paint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the text anchor.
|
||||
*
|
||||
* @return The text anchor (never <code>null</code>).
|
||||
*
|
||||
* @see #setTextAnchor(TextAnchor)
|
||||
*/
|
||||
public TextAnchor getTextAnchor() {
|
||||
return this.textAnchor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the text anchor (the point on the text bounding rectangle that is
|
||||
* aligned to the (x, y) coordinate of the annotation).
|
||||
*
|
||||
* @param anchor the anchor point (<code>null</code> not permitted).
|
||||
*
|
||||
* @see #getTextAnchor()
|
||||
*/
|
||||
public void setTextAnchor(TextAnchor anchor) {
|
||||
if (anchor == null) {
|
||||
throw new IllegalArgumentException("Null 'anchor' argument.");
|
||||
}
|
||||
this.textAnchor = anchor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rotation anchor.
|
||||
*
|
||||
* @return The rotation anchor point (never <code>null</code>).
|
||||
*
|
||||
* @see #setRotationAnchor(TextAnchor)
|
||||
*/
|
||||
public TextAnchor getRotationAnchor() {
|
||||
return this.rotationAnchor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the rotation anchor point.
|
||||
*
|
||||
* @param anchor the anchor (<code>null</code> not permitted).
|
||||
*
|
||||
* @see #getRotationAnchor()
|
||||
*/
|
||||
public void setRotationAnchor(TextAnchor anchor) {
|
||||
if (anchor == null) {
|
||||
throw new IllegalArgumentException("Null 'anchor' argument.");
|
||||
}
|
||||
this.rotationAnchor = anchor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rotation angle.
|
||||
*
|
||||
* @return The rotation angle.
|
||||
*
|
||||
* @see #setRotationAngle(double)
|
||||
*/
|
||||
public double getRotationAngle() {
|
||||
return this.rotationAngle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the rotation angle. The angle is measured clockwise in radians.
|
||||
*
|
||||
* @param angle the angle (in radians).
|
||||
*
|
||||
* @see #getRotationAngle()
|
||||
*/
|
||||
public void setRotationAngle(double angle) {
|
||||
this.rotationAngle = angle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the x coordinate for the text anchor point (measured against the
|
||||
* domain axis).
|
||||
*
|
||||
* @return The x coordinate (in data space).
|
||||
*
|
||||
* @see #setX(double)
|
||||
*/
|
||||
public double getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the x coordinate for the text anchor point (measured against the
|
||||
* domain axis).
|
||||
*
|
||||
* @param x the x coordinate (in data space).
|
||||
*
|
||||
* @see #getX()
|
||||
*/
|
||||
public void setX(double x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the y coordinate for the text anchor point (measured against the
|
||||
* range axis).
|
||||
*
|
||||
* @return The y coordinate (in data space).
|
||||
*
|
||||
* @see #setY(double)
|
||||
*/
|
||||
public double getY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the y coordinate for the text anchor point (measured against the
|
||||
* range axis).
|
||||
*
|
||||
* @param y the y coordinate.
|
||||
*
|
||||
* @see #getY()
|
||||
*/
|
||||
public void setY(double y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the annotation.
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
* @param plot the plot.
|
||||
* @param dataArea the data area.
|
||||
* @param domainAxis the domain axis.
|
||||
* @param rangeAxis the range axis.
|
||||
* @param rendererIndex the renderer index.
|
||||
* @param info an optional info object that will be populated with
|
||||
* entity information.
|
||||
*/
|
||||
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea,
|
||||
ValueAxis domainAxis, ValueAxis rangeAxis,
|
||||
int rendererIndex,
|
||||
PlotRenderingInfo info) {
|
||||
|
||||
PlotOrientation orientation = plot.getOrientation();
|
||||
RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
|
||||
plot.getDomainAxisLocation(), orientation);
|
||||
RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
|
||||
plot.getRangeAxisLocation(), orientation);
|
||||
|
||||
float anchorX = (float) domainAxis.valueToJava2D(
|
||||
this.x, dataArea, domainEdge);
|
||||
float anchorY = (float) rangeAxis.valueToJava2D(
|
||||
this.y, dataArea, rangeEdge);
|
||||
|
||||
if (orientation == PlotOrientation.HORIZONTAL) {
|
||||
float tempAnchor = anchorX;
|
||||
anchorX = anchorY;
|
||||
anchorY = tempAnchor;
|
||||
}
|
||||
|
||||
g2.setFont(getFont());
|
||||
g2.setPaint(getPaint());
|
||||
TextUtilities.drawRotatedString(getText(), g2, anchorX, anchorY,
|
||||
getTextAnchor(), getRotationAngle(), getRotationAnchor());
|
||||
Shape hotspot = TextUtilities.calculateRotatedStringBounds(
|
||||
getText(), g2, anchorX, anchorY, getTextAnchor(),
|
||||
getRotationAngle(), getRotationAnchor());
|
||||
|
||||
String toolTip = getToolTipText();
|
||||
String url = getURL();
|
||||
if (toolTip != null || url != null) {
|
||||
addEntity(info, hotspot, rendererIndex, toolTip, url);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this annotation for equality with an arbitrary object.
|
||||
*
|
||||
* @param obj the object (<code>null</code> permitted).
|
||||
*
|
||||
* @return A boolean.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof XYTextAnnotation)) {
|
||||
return false;
|
||||
}
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
XYTextAnnotation that = (XYTextAnnotation) obj;
|
||||
if (!this.text.equals(that.text)) {
|
||||
return false;
|
||||
}
|
||||
if (this.x != that.x) {
|
||||
return false;
|
||||
}
|
||||
if (this.y != that.y) {
|
||||
return false;
|
||||
}
|
||||
if (!this.font.equals(that.font)) {
|
||||
return false;
|
||||
}
|
||||
if (!PaintUtilities.equal(this.paint, that.paint)) {
|
||||
return false;
|
||||
}
|
||||
if (!this.rotationAnchor.equals(that.rotationAnchor)) {
|
||||
return false;
|
||||
}
|
||||
if (this.rotationAngle != that.rotationAngle) {
|
||||
return false;
|
||||
}
|
||||
if (!this.textAnchor.equals(that.textAnchor)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for the object.
|
||||
*
|
||||
* @return A hash code.
|
||||
*/
|
||||
public int hashCode() {
|
||||
int result = 193;
|
||||
result = 37 * this.text.hashCode();
|
||||
result = 37 * this.font.hashCode();
|
||||
result = 37 * result + HashUtilities.hashCodeForPaint(this.paint);
|
||||
long temp = Double.doubleToLongBits(this.x);
|
||||
result = 37 * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(this.y);
|
||||
result = 37 * result + (int) (temp ^ (temp >>> 32));
|
||||
result = 37 * result + this.textAnchor.hashCode();
|
||||
result = 37 * result + this.rotationAnchor.hashCode();
|
||||
temp = Double.doubleToLongBits(this.rotationAngle);
|
||||
result = 37 * result + (int) (temp ^ (temp >>> 32));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone of the annotation.
|
||||
*
|
||||
* @return A clone.
|
||||
*
|
||||
* @throws CloneNotSupportedException if the annotation can't be cloned.
|
||||
*/
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the output stream.
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
*/
|
||||
private void writeObject(ObjectOutputStream stream) throws IOException {
|
||||
stream.defaultWriteObject();
|
||||
SerialUtilities.writePaint(this.paint, stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the input stream.
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
* @throws ClassNotFoundException if there is a classpath problem.
|
||||
*/
|
||||
private void readObject(ObjectInputStream stream)
|
||||
throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
this.paint = SerialUtilities.readPaint(stream);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,394 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* ----------------------
|
||||
* XYTitleAnnotation.java
|
||||
* ----------------------
|
||||
* (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): Andrew Mickish;
|
||||
*
|
||||
* Changes:
|
||||
* --------
|
||||
* 02-Feb-2007 : Version 1 (DG);
|
||||
* 30-Apr-2007 : Fixed equals() method (DG);
|
||||
* 26-Feb-2008 : Fixed NullPointerException when drawing chart with a null
|
||||
* ChartRenderingInfo - see patch 1901599 by Andrew Mickish (DG);
|
||||
* 03-Sep-2008 : Moved from experimental to main (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.annotations;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.jfree.chart.HashUtilities;
|
||||
import org.jfree.chart.axis.AxisLocation;
|
||||
import org.jfree.chart.axis.ValueAxis;
|
||||
import org.jfree.chart.block.BlockParams;
|
||||
import org.jfree.chart.block.EntityBlockResult;
|
||||
import org.jfree.chart.block.RectangleConstraint;
|
||||
import org.jfree.chart.plot.Plot;
|
||||
import org.jfree.chart.plot.PlotOrientation;
|
||||
import org.jfree.chart.plot.PlotRenderingInfo;
|
||||
import org.jfree.chart.plot.XYPlot;
|
||||
import org.jfree.chart.title.Title;
|
||||
import org.jfree.chart.util.XYCoordinateType;
|
||||
import org.jfree.data.Range;
|
||||
import org.jfree.ui.RectangleAnchor;
|
||||
import org.jfree.ui.RectangleEdge;
|
||||
import org.jfree.ui.Size2D;
|
||||
import org.jfree.util.ObjectUtilities;
|
||||
import org.jfree.util.PublicCloneable;
|
||||
|
||||
/**
|
||||
* An annotation that allows any {@link Title} to be placed at a location on
|
||||
* an {@link XYPlot}.
|
||||
*
|
||||
* @since 1.0.11
|
||||
*/
|
||||
public class XYTitleAnnotation extends AbstractXYAnnotation
|
||||
implements Cloneable, PublicCloneable, Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
private static final long serialVersionUID = -4364694501921559958L;
|
||||
|
||||
/** The coordinate type. */
|
||||
private XYCoordinateType coordinateType;
|
||||
|
||||
/** The x-coordinate (in data space). */
|
||||
private double x;
|
||||
|
||||
/** The y-coordinate (in data space). */
|
||||
private double y;
|
||||
|
||||
/** The maximum width. */
|
||||
private double maxWidth;
|
||||
|
||||
/** The maximum height. */
|
||||
private double maxHeight;
|
||||
|
||||
/** The title. */
|
||||
private Title title;
|
||||
|
||||
/**
|
||||
* The title anchor point.
|
||||
*/
|
||||
private RectangleAnchor anchor;
|
||||
|
||||
/**
|
||||
* Creates a new annotation to be displayed at the specified (x, y)
|
||||
* location.
|
||||
*
|
||||
* @param x the x-coordinate (in data space).
|
||||
* @param y the y-coordinate (in data space).
|
||||
* @param title the title (<code>null</code> not permitted).
|
||||
*/
|
||||
public XYTitleAnnotation(double x, double y, Title title) {
|
||||
this(x, y, title, RectangleAnchor.CENTER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new annotation to be displayed at the specified (x, y)
|
||||
* location.
|
||||
*
|
||||
* @param x the x-coordinate (in data space).
|
||||
* @param y the y-coordinate (in data space).
|
||||
* @param title the title (<code>null</code> not permitted).
|
||||
* @param anchor the title anchor (<code>null</code> not permitted).
|
||||
*/
|
||||
public XYTitleAnnotation(double x, double y, Title title,
|
||||
RectangleAnchor anchor) {
|
||||
if (title == null) {
|
||||
throw new IllegalArgumentException("Null 'title' argument.");
|
||||
}
|
||||
if (anchor == null) {
|
||||
throw new IllegalArgumentException("Null 'anchor' argument.");
|
||||
}
|
||||
this.coordinateType = XYCoordinateType.RELATIVE;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.maxWidth = 0.0;
|
||||
this.maxHeight = 0.0;
|
||||
this.title = title;
|
||||
this.anchor = anchor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the coordinate type (set in the constructor).
|
||||
*
|
||||
* @return The coordinate type (never <code>null</code>).
|
||||
*/
|
||||
public XYCoordinateType getCoordinateType() {
|
||||
return this.coordinateType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the x-coordinate for the annotation.
|
||||
*
|
||||
* @return The x-coordinate.
|
||||
*/
|
||||
public double getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the y-coordinate for the annotation.
|
||||
*
|
||||
* @return The y-coordinate.
|
||||
*/
|
||||
public double getY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the title for the annotation.
|
||||
*
|
||||
* @return The title.
|
||||
*/
|
||||
public Title getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the title anchor for the annotation.
|
||||
*
|
||||
* @return The title anchor.
|
||||
*/
|
||||
public RectangleAnchor getTitleAnchor() {
|
||||
return this.anchor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum width.
|
||||
*
|
||||
* @return The maximum width.
|
||||
*/
|
||||
public double getMaxWidth() {
|
||||
return this.maxWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum width.
|
||||
*
|
||||
* @param max the maximum width (0.0 or less means no maximum).
|
||||
*/
|
||||
public void setMaxWidth(double max) {
|
||||
this.maxWidth = max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum height.
|
||||
*
|
||||
* @return The maximum height.
|
||||
*/
|
||||
public double getMaxHeight() {
|
||||
return this.maxHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum height.
|
||||
*
|
||||
* @param max the maximum height.
|
||||
*/
|
||||
public void setMaxHeight(double max) {
|
||||
this.maxHeight = max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the annotation. This method is called by the drawing code in the
|
||||
* {@link XYPlot} class, you don't normally need to call this method
|
||||
* directly.
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
* @param plot the plot.
|
||||
* @param dataArea the data area.
|
||||
* @param domainAxis the domain axis.
|
||||
* @param rangeAxis the range axis.
|
||||
* @param rendererIndex the renderer index.
|
||||
* @param info if supplied, this info object will be populated with
|
||||
* entity information.
|
||||
*/
|
||||
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea,
|
||||
ValueAxis domainAxis, ValueAxis rangeAxis,
|
||||
int rendererIndex,
|
||||
PlotRenderingInfo info) {
|
||||
|
||||
PlotOrientation orientation = plot.getOrientation();
|
||||
AxisLocation domainAxisLocation = plot.getDomainAxisLocation();
|
||||
AxisLocation rangeAxisLocation = plot.getRangeAxisLocation();
|
||||
RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
|
||||
domainAxisLocation, orientation);
|
||||
RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
|
||||
rangeAxisLocation, orientation);
|
||||
Range xRange = domainAxis.getRange();
|
||||
Range yRange = rangeAxis.getRange();
|
||||
double anchorX = 0.0;
|
||||
double anchorY = 0.0;
|
||||
if (this.coordinateType == XYCoordinateType.RELATIVE) {
|
||||
anchorX = xRange.getLowerBound() + (this.x * xRange.getLength());
|
||||
anchorY = yRange.getLowerBound() + (this.y * yRange.getLength());
|
||||
}
|
||||
else {
|
||||
anchorX = domainAxis.valueToJava2D(this.x, dataArea, domainEdge);
|
||||
anchorY = rangeAxis.valueToJava2D(this.y, dataArea, rangeEdge);
|
||||
}
|
||||
|
||||
float j2DX = (float) domainAxis.valueToJava2D(anchorX, dataArea,
|
||||
domainEdge);
|
||||
float j2DY = (float) rangeAxis.valueToJava2D(anchorY, dataArea,
|
||||
rangeEdge);
|
||||
float xx = 0.0f;
|
||||
float yy = 0.0f;
|
||||
if (orientation == PlotOrientation.HORIZONTAL) {
|
||||
xx = j2DY;
|
||||
yy = j2DX;
|
||||
}
|
||||
else if (orientation == PlotOrientation.VERTICAL) {
|
||||
xx = j2DX;
|
||||
yy = j2DY;
|
||||
}
|
||||
|
||||
double maxW = dataArea.getWidth();
|
||||
double maxH = dataArea.getHeight();
|
||||
if (this.coordinateType == XYCoordinateType.RELATIVE) {
|
||||
if (this.maxWidth > 0.0) {
|
||||
maxW = maxW * this.maxWidth;
|
||||
}
|
||||
if (this.maxHeight > 0.0) {
|
||||
maxH = maxH * this.maxHeight;
|
||||
}
|
||||
}
|
||||
if (this.coordinateType == XYCoordinateType.DATA) {
|
||||
maxW = this.maxWidth;
|
||||
maxH = this.maxHeight;
|
||||
}
|
||||
RectangleConstraint rc = new RectangleConstraint(
|
||||
new Range(0, maxW), new Range(0, maxH));
|
||||
|
||||
Size2D size = this.title.arrange(g2, rc);
|
||||
Rectangle2D titleRect = new Rectangle2D.Double(0, 0, size.width,
|
||||
size.height);
|
||||
Point2D anchorPoint = RectangleAnchor.coordinates(titleRect,
|
||||
this.anchor);
|
||||
xx = xx - (float) anchorPoint.getX();
|
||||
yy = yy - (float) anchorPoint.getY();
|
||||
titleRect.setRect(xx, yy, titleRect.getWidth(), titleRect.getHeight());
|
||||
BlockParams p = new BlockParams();
|
||||
if (info != null) {
|
||||
if (info.getOwner().getEntityCollection() != null) {
|
||||
p.setGenerateEntities(true);
|
||||
}
|
||||
}
|
||||
Object result = this.title.draw(g2, titleRect, p);
|
||||
if (info != null) {
|
||||
if (result instanceof EntityBlockResult) {
|
||||
EntityBlockResult ebr = (EntityBlockResult) result;
|
||||
info.getOwner().getEntityCollection().addAll(
|
||||
ebr.getEntityCollection());
|
||||
}
|
||||
String toolTip = getToolTipText();
|
||||
String url = getURL();
|
||||
if (toolTip != null || url != null) {
|
||||
addEntity(info, new Rectangle2D.Float(xx, yy,
|
||||
(float) size.width, (float) size.height),
|
||||
rendererIndex, toolTip, url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this object for equality with an arbitrary object.
|
||||
*
|
||||
* @param obj the object (<code>null</code> permitted).
|
||||
*
|
||||
* @return A boolean.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof XYTitleAnnotation)) {
|
||||
return false;
|
||||
}
|
||||
XYTitleAnnotation that = (XYTitleAnnotation) obj;
|
||||
if (this.coordinateType != that.coordinateType) {
|
||||
return false;
|
||||
}
|
||||
if (this.x != that.x) {
|
||||
return false;
|
||||
}
|
||||
if (this.y != that.y) {
|
||||
return false;
|
||||
}
|
||||
if (this.maxWidth != that.maxWidth) {
|
||||
return false;
|
||||
}
|
||||
if (this.maxHeight != that.maxHeight) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtilities.equal(this.title, that.title)) {
|
||||
return false;
|
||||
}
|
||||
if (!this.anchor.equals(that.anchor)) {
|
||||
return false;
|
||||
}
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for this object.
|
||||
*
|
||||
* @return A hash code.
|
||||
*/
|
||||
public int hashCode() {
|
||||
int result = 193;
|
||||
result = HashUtilities.hashCode(result, this.anchor);
|
||||
result = HashUtilities.hashCode(result, this.coordinateType);
|
||||
result = HashUtilities.hashCode(result, this.x);
|
||||
result = HashUtilities.hashCode(result, this.y);
|
||||
result = HashUtilities.hashCode(result, this.maxWidth);
|
||||
result = HashUtilities.hashCode(result, this.maxHeight);
|
||||
result = HashUtilities.hashCode(result, this.title);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone of the annotation.
|
||||
*
|
||||
* @return A clone.
|
||||
*
|
||||
* @throws CloneNotSupportedException if the annotation can't be cloned.
|
||||
*/
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html>
|
||||
<body bgcolor="white">
|
||||
A framework for addings annotations to charts.
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,144 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -------------------
|
||||
* AxisCollection.java
|
||||
* -------------------
|
||||
* (C) Copyright 2003-2008, by Object Refinery Limited.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 03-Nov-2003 : Added standard header (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.axis;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jfree.ui.RectangleEdge;
|
||||
|
||||
/**
|
||||
* A collection of axes that have been assigned to the TOP, BOTTOM, LEFT or
|
||||
* RIGHT of a chart. This class is used internally by JFreeChart, you won't
|
||||
* normally need to use it yourself.
|
||||
*/
|
||||
public class AxisCollection {
|
||||
|
||||
/** The axes that need to be drawn at the top of the plot area. */
|
||||
private List axesAtTop;
|
||||
|
||||
/** The axes that need to be drawn at the bottom of the plot area. */
|
||||
private List axesAtBottom;
|
||||
|
||||
/** The axes that need to be drawn at the left of the plot area. */
|
||||
private List axesAtLeft;
|
||||
|
||||
/** The axes that need to be drawn at the right of the plot area. */
|
||||
private List axesAtRight;
|
||||
|
||||
/**
|
||||
* Creates a new empty collection.
|
||||
*/
|
||||
public AxisCollection() {
|
||||
this.axesAtTop = new java.util.ArrayList();
|
||||
this.axesAtBottom = new java.util.ArrayList();
|
||||
this.axesAtLeft = new java.util.ArrayList();
|
||||
this.axesAtRight = new java.util.ArrayList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of the axes (if any) that need to be drawn at the top of
|
||||
* the plot area.
|
||||
*
|
||||
* @return A list of axes.
|
||||
*/
|
||||
public List getAxesAtTop() {
|
||||
return this.axesAtTop;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of the axes (if any) that need to be drawn at the bottom
|
||||
* of the plot area.
|
||||
*
|
||||
* @return A list of axes.
|
||||
*/
|
||||
public List getAxesAtBottom() {
|
||||
return this.axesAtBottom;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of the axes (if any) that need to be drawn at the left
|
||||
* of the plot area.
|
||||
*
|
||||
* @return A list of axes.
|
||||
*/
|
||||
public List getAxesAtLeft() {
|
||||
return this.axesAtLeft;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of the axes (if any) that need to be drawn at the right
|
||||
* of the plot area.
|
||||
*
|
||||
* @return A list of axes.
|
||||
*/
|
||||
public List getAxesAtRight() {
|
||||
return this.axesAtRight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an axis to the collection.
|
||||
*
|
||||
* @param axis the axis (<code>null</code> not permitted).
|
||||
* @param edge the edge of the plot that the axis should be drawn on
|
||||
* (<code>null</code> not permitted).
|
||||
*/
|
||||
public void add(Axis axis, RectangleEdge edge) {
|
||||
if (axis == null) {
|
||||
throw new IllegalArgumentException("Null 'axis' argument.");
|
||||
}
|
||||
if (edge == null) {
|
||||
throw new IllegalArgumentException("Null 'edge' argument.");
|
||||
}
|
||||
if (edge == RectangleEdge.TOP) {
|
||||
this.axesAtTop.add(axis);
|
||||
}
|
||||
else if (edge == RectangleEdge.BOTTOM) {
|
||||
this.axesAtBottom.add(axis);
|
||||
}
|
||||
else if (edge == RectangleEdge.LEFT) {
|
||||
this.axesAtLeft.add(axis);
|
||||
}
|
||||
else if (edge == RectangleEdge.RIGHT) {
|
||||
this.axesAtRight.add(axis);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,185 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -----------------
|
||||
* AxisLocation.java
|
||||
* -----------------
|
||||
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): Nick Guenther;
|
||||
*
|
||||
* Changes:
|
||||
* --------
|
||||
* 02-May-2003 : Version 1 (DG);
|
||||
* 03-Jul-2003 : Added isTopOrBottom() and isLeftOrRight() methods (DG);
|
||||
* 13-Aug-2003 : Fixed readResolve() bug (id=788202) (DG);
|
||||
* 24-Mar-2004 : Added static getOpposite() method (DG);
|
||||
* ------------- JFREECHART 1.0.x ---------------------------------------------
|
||||
* 22-Mar-2007 : Added getOpposite() method, suggested by Nick Guenther (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.axis;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Used to indicate the location of an axis on a 2D plot, prior to knowing the
|
||||
* orientation of the plot.
|
||||
*/
|
||||
public final class AxisLocation implements Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
private static final long serialVersionUID = -3276922179323563410L;
|
||||
|
||||
/** Axis at the top or left. */
|
||||
public static final AxisLocation TOP_OR_LEFT = new AxisLocation(
|
||||
"AxisLocation.TOP_OR_LEFT");
|
||||
|
||||
/** Axis at the top or right. */
|
||||
public static final AxisLocation TOP_OR_RIGHT = new AxisLocation(
|
||||
"AxisLocation.TOP_OR_RIGHT");
|
||||
|
||||
/** Axis at the bottom or left. */
|
||||
public static final AxisLocation BOTTOM_OR_LEFT = new AxisLocation(
|
||||
"AxisLocation.BOTTOM_OR_LEFT");
|
||||
|
||||
/** Axis at the bottom or right. */
|
||||
public static final AxisLocation BOTTOM_OR_RIGHT = new AxisLocation(
|
||||
"AxisLocation.BOTTOM_OR_RIGHT");
|
||||
|
||||
/** The name. */
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* Private constructor.
|
||||
*
|
||||
* @param name the name.
|
||||
*/
|
||||
private AxisLocation(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the location that is opposite to this location.
|
||||
*
|
||||
* @return The opposite location.
|
||||
*
|
||||
* @since 1.0.5
|
||||
*/
|
||||
public AxisLocation getOpposite() {
|
||||
return getOpposite(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representing the object.
|
||||
*
|
||||
* @return The string.
|
||||
*/
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if this object is equal to the specified
|
||||
* object, and <code>false</code> otherwise.
|
||||
*
|
||||
* @param obj the other object (<code>null</code> permitted).
|
||||
*
|
||||
* @return A boolean.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof AxisLocation)) {
|
||||
return false;
|
||||
}
|
||||
AxisLocation location = (AxisLocation) obj;
|
||||
if (!this.name.equals(location.toString())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the location that is opposite to the supplied location.
|
||||
*
|
||||
* @param location the location (<code>null</code> not permitted).
|
||||
*
|
||||
* @return The opposite location.
|
||||
*/
|
||||
public static AxisLocation getOpposite(AxisLocation location) {
|
||||
if (location == null) {
|
||||
throw new IllegalArgumentException("Null 'location' argument.");
|
||||
}
|
||||
AxisLocation result = null;
|
||||
if (location == AxisLocation.TOP_OR_LEFT) {
|
||||
result = AxisLocation.BOTTOM_OR_RIGHT;
|
||||
}
|
||||
else if (location == AxisLocation.TOP_OR_RIGHT) {
|
||||
result = AxisLocation.BOTTOM_OR_LEFT;
|
||||
}
|
||||
else if (location == AxisLocation.BOTTOM_OR_LEFT) {
|
||||
result = AxisLocation.TOP_OR_RIGHT;
|
||||
}
|
||||
else if (location == AxisLocation.BOTTOM_OR_RIGHT) {
|
||||
result = AxisLocation.TOP_OR_LEFT;
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException("AxisLocation not recognised.");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that serialization returns the unique instances.
|
||||
*
|
||||
* @return The object.
|
||||
*
|
||||
* @throws ObjectStreamException if there is a problem.
|
||||
*/
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
if (this.equals(AxisLocation.TOP_OR_RIGHT)) {
|
||||
return AxisLocation.TOP_OR_RIGHT;
|
||||
}
|
||||
else if (this.equals(AxisLocation.BOTTOM_OR_RIGHT)) {
|
||||
return AxisLocation.BOTTOM_OR_RIGHT;
|
||||
}
|
||||
else if (this.equals(AxisLocation.TOP_OR_LEFT)) {
|
||||
return AxisLocation.TOP_OR_LEFT;
|
||||
}
|
||||
else if (this.equals(AxisLocation.BOTTOM_OR_LEFT)) {
|
||||
return AxisLocation.BOTTOM_OR_LEFT;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,378 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* --------------
|
||||
* AxisSpace.java
|
||||
* --------------
|
||||
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 03-Jul-2003 : Version 1 (DG);
|
||||
* 14-Aug-2003 : Implemented Cloneable (DG);
|
||||
* 18-Aug-2003 : Implemented Serializable (DG);
|
||||
* 17-Mar-2004 : Added a toString() method for debugging (DG);
|
||||
* 07-Jan-2005 : Updated equals() method (DG);
|
||||
* 11-Jan-2005 : Removed deprecated methods in preparation for 1.0.0
|
||||
* release (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.axis;
|
||||
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.jfree.ui.RectangleEdge;
|
||||
import org.jfree.util.PublicCloneable;
|
||||
|
||||
/**
|
||||
* A record that contains the space required at each edge of a plot.
|
||||
*/
|
||||
public class AxisSpace implements Cloneable, PublicCloneable, Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
private static final long serialVersionUID = -2490732595134766305L;
|
||||
|
||||
/** The top space. */
|
||||
private double top;
|
||||
|
||||
/** The bottom space. */
|
||||
private double bottom;
|
||||
|
||||
/** The left space. */
|
||||
private double left;
|
||||
|
||||
/** The right space. */
|
||||
private double right;
|
||||
|
||||
/**
|
||||
* Creates a new axis space record.
|
||||
*/
|
||||
public AxisSpace() {
|
||||
this.top = 0.0;
|
||||
this.bottom = 0.0;
|
||||
this.left = 0.0;
|
||||
this.right = 0.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the space reserved for axes at the top of the plot area.
|
||||
*
|
||||
* @return The space (in Java2D units).
|
||||
*/
|
||||
public double getTop() {
|
||||
return this.top;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the space reserved for axes at the top of the plot area.
|
||||
*
|
||||
* @param space the space (in Java2D units).
|
||||
*/
|
||||
public void setTop(double space) {
|
||||
this.top = space;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the space reserved for axes at the bottom of the plot area.
|
||||
*
|
||||
* @return The space (in Java2D units).
|
||||
*/
|
||||
public double getBottom() {
|
||||
return this.bottom;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the space reserved for axes at the bottom of the plot area.
|
||||
*
|
||||
* @param space the space (in Java2D units).
|
||||
*/
|
||||
public void setBottom(double space) {
|
||||
this.bottom = space;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the space reserved for axes at the left of the plot area.
|
||||
*
|
||||
* @return The space (in Java2D units).
|
||||
*/
|
||||
public double getLeft() {
|
||||
return this.left;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the space reserved for axes at the left of the plot area.
|
||||
*
|
||||
* @param space the space (in Java2D units).
|
||||
*/
|
||||
public void setLeft(double space) {
|
||||
this.left = space;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the space reserved for axes at the right of the plot area.
|
||||
*
|
||||
* @return The space (in Java2D units).
|
||||
*/
|
||||
public double getRight() {
|
||||
return this.right;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the space reserved for axes at the right of the plot area.
|
||||
*
|
||||
* @param space the space (in Java2D units).
|
||||
*/
|
||||
public void setRight(double space) {
|
||||
this.right = space;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds space to the top, bottom, left or right edge of the plot area.
|
||||
*
|
||||
* @param space the space (in Java2D units).
|
||||
* @param edge the edge (<code>null</code> not permitted).
|
||||
*/
|
||||
public void add(double space, RectangleEdge edge) {
|
||||
if (edge == null) {
|
||||
throw new IllegalArgumentException("Null 'edge' argument.");
|
||||
}
|
||||
if (edge == RectangleEdge.TOP) {
|
||||
this.top += space;
|
||||
}
|
||||
else if (edge == RectangleEdge.BOTTOM) {
|
||||
this.bottom += space;
|
||||
}
|
||||
else if (edge == RectangleEdge.LEFT) {
|
||||
this.left += space;
|
||||
}
|
||||
else if (edge == RectangleEdge.RIGHT) {
|
||||
this.right += space;
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException("Unrecognised 'edge' argument.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this object reserves at least as much space as another.
|
||||
*
|
||||
* @param space the other space.
|
||||
*/
|
||||
public void ensureAtLeast(AxisSpace space) {
|
||||
this.top = Math.max(this.top, space.top);
|
||||
this.bottom = Math.max(this.bottom, space.bottom);
|
||||
this.left = Math.max(this.left, space.left);
|
||||
this.right = Math.max(this.right, space.right);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures there is a minimum amount of space at the edge corresponding to
|
||||
* the specified axis location.
|
||||
*
|
||||
* @param space the space.
|
||||
* @param edge the location.
|
||||
*/
|
||||
public void ensureAtLeast(double space, RectangleEdge edge) {
|
||||
if (edge == RectangleEdge.TOP) {
|
||||
if (this.top < space) {
|
||||
this.top = space;
|
||||
}
|
||||
}
|
||||
else if (edge == RectangleEdge.BOTTOM) {
|
||||
if (this.bottom < space) {
|
||||
this.bottom = space;
|
||||
}
|
||||
}
|
||||
else if (edge == RectangleEdge.LEFT) {
|
||||
if (this.left < space) {
|
||||
this.left = space;
|
||||
}
|
||||
}
|
||||
else if (edge == RectangleEdge.RIGHT) {
|
||||
if (this.right < space) {
|
||||
this.right = space;
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException(
|
||||
"AxisSpace.ensureAtLeast(): unrecognised AxisLocation."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shrinks an area by the space attributes.
|
||||
*
|
||||
* @param area the area to shrink.
|
||||
* @param result an optional carrier for the result.
|
||||
*
|
||||
* @return The result.
|
||||
*/
|
||||
public Rectangle2D shrink(Rectangle2D area, Rectangle2D result) {
|
||||
if (result == null) {
|
||||
result = new Rectangle2D.Double();
|
||||
}
|
||||
result.setRect(
|
||||
area.getX() + this.left,
|
||||
area.getY() + this.top,
|
||||
area.getWidth() - this.left - this.right,
|
||||
area.getHeight() - this.top - this.bottom
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expands an area by the amount of space represented by this object.
|
||||
*
|
||||
* @param area the area to expand.
|
||||
* @param result an optional carrier for the result.
|
||||
*
|
||||
* @return The result.
|
||||
*/
|
||||
public Rectangle2D expand(Rectangle2D area, Rectangle2D result) {
|
||||
if (result == null) {
|
||||
result = new Rectangle2D.Double();
|
||||
}
|
||||
result.setRect(
|
||||
area.getX() - this.left,
|
||||
area.getY() - this.top,
|
||||
area.getWidth() + this.left + this.right,
|
||||
area.getHeight() + this.top + this.bottom
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the reserved area.
|
||||
*
|
||||
* @param area the area.
|
||||
* @param edge the edge.
|
||||
*
|
||||
* @return The reserved area.
|
||||
*/
|
||||
public Rectangle2D reserved(Rectangle2D area, RectangleEdge edge) {
|
||||
Rectangle2D result = null;
|
||||
if (edge == RectangleEdge.TOP) {
|
||||
result = new Rectangle2D.Double(
|
||||
area.getX(), area.getY(), area.getWidth(), this.top
|
||||
);
|
||||
}
|
||||
else if (edge == RectangleEdge.BOTTOM) {
|
||||
result = new Rectangle2D.Double(
|
||||
area.getX(), area.getMaxY() - this.top,
|
||||
area.getWidth(), this.bottom
|
||||
);
|
||||
}
|
||||
else if (edge == RectangleEdge.LEFT) {
|
||||
result = new Rectangle2D.Double(
|
||||
area.getX(), area.getY(), this.left, area.getHeight()
|
||||
);
|
||||
}
|
||||
else if (edge == RectangleEdge.RIGHT) {
|
||||
result = new Rectangle2D.Double(
|
||||
area.getMaxX() - this.right, area.getY(),
|
||||
this.right, area.getHeight()
|
||||
);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone of the object.
|
||||
*
|
||||
* @return A clone.
|
||||
*
|
||||
* @throws CloneNotSupportedException This class won't throw this exception,
|
||||
* but subclasses (if any) might.
|
||||
*/
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this object for equality with another object.
|
||||
*
|
||||
* @param obj the object to compare against.
|
||||
*
|
||||
* @return <code>true</code> or <code>false</code>.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof AxisSpace)) {
|
||||
return false;
|
||||
}
|
||||
AxisSpace that = (AxisSpace) obj;
|
||||
if (this.top != that.top) {
|
||||
return false;
|
||||
}
|
||||
if (this.bottom != that.bottom) {
|
||||
return false;
|
||||
}
|
||||
if (this.left != that.left) {
|
||||
return false;
|
||||
}
|
||||
if (this.right != that.right) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for this object.
|
||||
*
|
||||
* @return A hash code.
|
||||
*/
|
||||
public int hashCode() {
|
||||
int result = 23;
|
||||
long l = Double.doubleToLongBits(this.top);
|
||||
result = 37 * result + (int) (l ^ (l >>> 32));
|
||||
l = Double.doubleToLongBits(this.bottom);
|
||||
result = 37 * result + (int) (l ^ (l >>> 32));
|
||||
l = Double.doubleToLongBits(this.left);
|
||||
result = 37 * result + (int) (l ^ (l >>> 32));
|
||||
l = Double.doubleToLongBits(this.right);
|
||||
result = 37 * result + (int) (l ^ (l >>> 32));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representing the object (for debugging purposes).
|
||||
*
|
||||
* @return A string.
|
||||
*/
|
||||
public String toString() {
|
||||
return super.toString() + "[left=" + this.left + ",right=" + this.right
|
||||
+ ",top=" + this.top + ",bottom=" + this.bottom + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,193 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* --------------
|
||||
* AxisState.java
|
||||
* --------------
|
||||
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 03-Nov-2003 : Added standard header (DG);
|
||||
* 07-Nov-2003 : Added 'max' attribute (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.axis;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jfree.ui.RectangleEdge;
|
||||
|
||||
/**
|
||||
* Instances of this class are used to carry state information for an axis
|
||||
* during the drawing process. By retaining this information in a separate
|
||||
* object, it is possible for multiple threads to draw the same axis to
|
||||
* different output targets (each drawing will maintain separate state
|
||||
* information).
|
||||
*/
|
||||
public class AxisState {
|
||||
|
||||
/** The cursor position. */
|
||||
private double cursor;
|
||||
|
||||
/** The axis ticks. */
|
||||
private List ticks;
|
||||
|
||||
/** The maximum width/height. */
|
||||
private double max;
|
||||
|
||||
/**
|
||||
* Creates a new axis state.
|
||||
*/
|
||||
public AxisState() {
|
||||
this(0.0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new axis state.
|
||||
*
|
||||
* @param cursor the cursor.
|
||||
*/
|
||||
public AxisState(double cursor) {
|
||||
this.cursor = cursor;
|
||||
this.ticks = new java.util.ArrayList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cursor position.
|
||||
*
|
||||
* @return The cursor position.
|
||||
*/
|
||||
public double getCursor() {
|
||||
return this.cursor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cursor position.
|
||||
*
|
||||
* @param cursor the cursor position.
|
||||
*/
|
||||
public void setCursor(double cursor) {
|
||||
this.cursor = cursor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the cursor outwards by the specified number of units.
|
||||
*
|
||||
* @param units the units.
|
||||
* @param edge the edge.
|
||||
*/
|
||||
public void moveCursor(double units, RectangleEdge edge) {
|
||||
if (edge == RectangleEdge.TOP) {
|
||||
cursorUp(units);
|
||||
}
|
||||
else if (edge == RectangleEdge.BOTTOM) {
|
||||
cursorDown(units);
|
||||
}
|
||||
else if (edge == RectangleEdge.LEFT) {
|
||||
cursorLeft(units);
|
||||
}
|
||||
else if (edge == RectangleEdge.RIGHT) {
|
||||
cursorRight(units);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the cursor up by the specified number of Java 2D units.
|
||||
*
|
||||
* @param units the units.
|
||||
*/
|
||||
public void cursorUp(double units) {
|
||||
this.cursor = this.cursor - units;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the cursor down by the specified number of Java 2D units.
|
||||
*
|
||||
* @param units the units.
|
||||
*/
|
||||
public void cursorDown(double units) {
|
||||
this.cursor = this.cursor + units;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the cursor left by the specified number of Java 2D units.
|
||||
*
|
||||
* @param units the units.
|
||||
*/
|
||||
public void cursorLeft(double units) {
|
||||
this.cursor = this.cursor - units;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the cursor right by the specified number of Java 2D units.
|
||||
*
|
||||
* @param units the units.
|
||||
*/
|
||||
public void cursorRight(double units) {
|
||||
this.cursor = this.cursor + units;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of ticks.
|
||||
*
|
||||
* @return The list of ticks.
|
||||
*/
|
||||
public List getTicks() {
|
||||
return this.ticks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the list of ticks.
|
||||
*
|
||||
* @param ticks the ticks.
|
||||
*/
|
||||
public void setTicks(List ticks) {
|
||||
this.ticks = ticks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum width/height.
|
||||
*
|
||||
* @return The maximum width/height.
|
||||
*/
|
||||
public double getMax() {
|
||||
return this.max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum width/height.
|
||||
*
|
||||
* @param max the maximum width/height.
|
||||
*/
|
||||
public void setMax(double max) {
|
||||
this.max = max;
|
||||
}
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -------------------
|
||||
* CategoryAnchor.java
|
||||
* -------------------
|
||||
* (C) Copyright 2003-2008, by Object Refinery Limited.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes:
|
||||
* --------
|
||||
* 04-Jul-2003 : Version 1 (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.axis;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Used to indicate one of three positions within a category:
|
||||
* <code>START</code>, <code>MIDDLE</code> and <code>END</code>.
|
||||
*/
|
||||
public final class CategoryAnchor implements Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
private static final long serialVersionUID = -2604142742210173810L;
|
||||
|
||||
/** Start of period. */
|
||||
public static final CategoryAnchor START
|
||||
= new CategoryAnchor("CategoryAnchor.START");
|
||||
|
||||
/** Middle of period. */
|
||||
public static final CategoryAnchor MIDDLE
|
||||
= new CategoryAnchor("CategoryAnchor.MIDDLE");
|
||||
|
||||
/** End of period. */
|
||||
public static final CategoryAnchor END
|
||||
= new CategoryAnchor("CategoryAnchor.END");
|
||||
|
||||
/** The name. */
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* Private constructor.
|
||||
*
|
||||
* @param name the name.
|
||||
*/
|
||||
private CategoryAnchor(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representing the object.
|
||||
*
|
||||
* @return The string.
|
||||
*/
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if this object is equal to the specified
|
||||
* object, and <code>false</code> otherwise.
|
||||
*
|
||||
* @param obj the other object.
|
||||
*
|
||||
* @return A boolean.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof CategoryAnchor)) {
|
||||
return false;
|
||||
}
|
||||
CategoryAnchor position = (CategoryAnchor) obj;
|
||||
if (!this.name.equals(position.toString())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that serialization returns the unique instances.
|
||||
*
|
||||
* @return The object.
|
||||
*
|
||||
* @throws ObjectStreamException if there is a problem.
|
||||
*/
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
if (this.equals(CategoryAnchor.START)) {
|
||||
return CategoryAnchor.START;
|
||||
}
|
||||
else if (this.equals(CategoryAnchor.MIDDLE)) {
|
||||
return CategoryAnchor.MIDDLE;
|
||||
}
|
||||
else if (this.equals(CategoryAnchor.END)) {
|
||||
return CategoryAnchor.END;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,223 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -------------------
|
||||
* CategoryAxis3D.java
|
||||
* -------------------
|
||||
* (C) Copyright 2003-2008, by Klaus Rheinwald and Contributors.
|
||||
*
|
||||
* Original Author: Klaus Rheinwald;
|
||||
* Contributor(s): Tin Luu,
|
||||
* David Gilbert (for Object Refinery Limited);
|
||||
* Adriaan Joubert;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 19-Feb-2003 : File creation;
|
||||
* 21-Mar-2003 : Added to JFreeChart CVS, see bug id 685501 for code
|
||||
* contribution from KR (DG);
|
||||
* 26-Mar-2003 : Implemented Serializable (DG);
|
||||
* 13-May-2003 : Renamed HorizontalCategoryAxis3D --> CategoryAxis3D, and
|
||||
* modified to take into account the plot orientation (DG);
|
||||
* 14-Aug-2003 : Implemented Cloneable (DG);
|
||||
* 21-Aug-2003 : Fixed draw() method bugs (DG);
|
||||
* 22-Mar-2004 : Added workaround for bug 920959 (null pointer exception with
|
||||
* no renderer) (DG);
|
||||
* ------------- JFREECHART 1.0.x ---------------------------------------------
|
||||
* 18-Aug-2006 : Fix for bug drawing category labels, thanks to Adriaan
|
||||
* Joubert (1277726) (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.axis;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.jfree.chart.Effect3D;
|
||||
import org.jfree.chart.plot.CategoryPlot;
|
||||
import org.jfree.chart.plot.PlotRenderingInfo;
|
||||
import org.jfree.chart.renderer.category.CategoryItemRenderer;
|
||||
import org.jfree.ui.RectangleEdge;
|
||||
|
||||
/**
|
||||
* An axis that displays categories and has a 3D effect.
|
||||
* Used for bar charts and line charts.
|
||||
*/
|
||||
public class CategoryAxis3D extends CategoryAxis
|
||||
implements Cloneable, Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
private static final long serialVersionUID = 4114732251353700972L;
|
||||
|
||||
/**
|
||||
* Creates a new axis.
|
||||
*/
|
||||
public CategoryAxis3D() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new axis using default attribute values.
|
||||
*
|
||||
* @param label the axis label (<code>null</code> permitted).
|
||||
*/
|
||||
public CategoryAxis3D(String label) {
|
||||
super(label);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the axis on a Java 2D graphics device (such as the screen or a
|
||||
* printer).
|
||||
*
|
||||
* @param g2 the graphics device (<code>null</code> not permitted).
|
||||
* @param cursor the cursor location.
|
||||
* @param plotArea the area within which the axis should be drawn
|
||||
* (<code>null</code> not permitted).
|
||||
* @param dataArea the area within which the plot is being drawn
|
||||
* (<code>null</code> not permitted).
|
||||
* @param edge the location of the axis (<code>null</code> not permitted).
|
||||
* @param plotState collects information about the plot (<code>null</code>
|
||||
* permitted).
|
||||
*
|
||||
* @return The axis state (never <code>null</code>).
|
||||
*/
|
||||
public AxisState draw(Graphics2D g2,
|
||||
double cursor,
|
||||
Rectangle2D plotArea,
|
||||
Rectangle2D dataArea,
|
||||
RectangleEdge edge,
|
||||
PlotRenderingInfo plotState) {
|
||||
|
||||
// if the axis is not visible, don't draw it...
|
||||
if (!isVisible()) {
|
||||
return new AxisState(cursor);
|
||||
}
|
||||
|
||||
// calculate the adjusted data area taking into account the 3D effect...
|
||||
// this assumes that there is a 3D renderer, all this 3D effect is a
|
||||
// bit of an ugly hack...
|
||||
CategoryPlot plot = (CategoryPlot) getPlot();
|
||||
|
||||
Rectangle2D adjustedDataArea = new Rectangle2D.Double();
|
||||
if (plot.getRenderer() instanceof Effect3D) {
|
||||
Effect3D e3D = (Effect3D) plot.getRenderer();
|
||||
double adjustedX = dataArea.getMinX();
|
||||
double adjustedY = dataArea.getMinY();
|
||||
double adjustedW = dataArea.getWidth() - e3D.getXOffset();
|
||||
double adjustedH = dataArea.getHeight() - e3D.getYOffset();
|
||||
|
||||
if (edge == RectangleEdge.LEFT || edge == RectangleEdge.BOTTOM) {
|
||||
adjustedY += e3D.getYOffset();
|
||||
}
|
||||
else if (edge == RectangleEdge.RIGHT || edge == RectangleEdge.TOP) {
|
||||
adjustedX += e3D.getXOffset();
|
||||
}
|
||||
adjustedDataArea.setRect(adjustedX, adjustedY, adjustedW,
|
||||
adjustedH);
|
||||
}
|
||||
else {
|
||||
adjustedDataArea.setRect(dataArea);
|
||||
}
|
||||
|
||||
// draw the category labels and axis label
|
||||
AxisState state = new AxisState(cursor);
|
||||
state = drawCategoryLabels(g2, plotArea, adjustedDataArea, edge,
|
||||
state, plotState);
|
||||
state = drawLabel(getLabel(), g2, plotArea, dataArea, edge, state);
|
||||
|
||||
return state;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Java 2D coordinate for a category.
|
||||
*
|
||||
* @param anchor the anchor point.
|
||||
* @param category the category index.
|
||||
* @param categoryCount the category count.
|
||||
* @param area the data area.
|
||||
* @param edge the location of the axis.
|
||||
*
|
||||
* @return The coordinate.
|
||||
*/
|
||||
public double getCategoryJava2DCoordinate(CategoryAnchor anchor,
|
||||
int category,
|
||||
int categoryCount,
|
||||
Rectangle2D area,
|
||||
RectangleEdge edge) {
|
||||
|
||||
double result = 0.0;
|
||||
Rectangle2D adjustedArea = area;
|
||||
CategoryPlot plot = (CategoryPlot) getPlot();
|
||||
CategoryItemRenderer renderer = plot.getRenderer();
|
||||
if (renderer instanceof Effect3D) {
|
||||
Effect3D e3D = (Effect3D) renderer;
|
||||
double adjustedX = area.getMinX();
|
||||
double adjustedY = area.getMinY();
|
||||
double adjustedW = area.getWidth() - e3D.getXOffset();
|
||||
double adjustedH = area.getHeight() - e3D.getYOffset();
|
||||
|
||||
if (edge == RectangleEdge.LEFT || edge == RectangleEdge.BOTTOM) {
|
||||
adjustedY += e3D.getYOffset();
|
||||
}
|
||||
else if (edge == RectangleEdge.RIGHT || edge == RectangleEdge.TOP) {
|
||||
adjustedX += e3D.getXOffset();
|
||||
}
|
||||
adjustedArea = new Rectangle2D.Double(adjustedX, adjustedY,
|
||||
adjustedW, adjustedH);
|
||||
}
|
||||
|
||||
if (anchor == CategoryAnchor.START) {
|
||||
result = getCategoryStart(category, categoryCount, adjustedArea,
|
||||
edge);
|
||||
}
|
||||
else if (anchor == CategoryAnchor.MIDDLE) {
|
||||
result = getCategoryMiddle(category, categoryCount, adjustedArea,
|
||||
edge);
|
||||
}
|
||||
else if (anchor == CategoryAnchor.END) {
|
||||
result = getCategoryEnd(category, categoryCount, adjustedArea,
|
||||
edge);
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone of the axis.
|
||||
*
|
||||
* @return A clone.
|
||||
*
|
||||
* @throws CloneNotSupportedException If the axis is not cloneable for
|
||||
* some reason.
|
||||
*/
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,277 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* --------------------------
|
||||
* CategoryLabelPosition.java
|
||||
* --------------------------
|
||||
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 31-Oct-2003 : Version 1 (DG);
|
||||
* 17-Feb-2004 : Added new constructor (DG);
|
||||
* 23-Mar-2004 : Added width calculation parameters (DG);
|
||||
* 07-Jan-2005 : Fixed bug in equals() method (DG);
|
||||
* 11-Jan-2005 : Removed deprecated constructor in preparation for the 1.0.0
|
||||
* release (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.axis;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.jfree.text.TextBlockAnchor;
|
||||
import org.jfree.ui.RectangleAnchor;
|
||||
import org.jfree.ui.TextAnchor;
|
||||
|
||||
/**
|
||||
* The attributes that control the position of the labels for the categories on
|
||||
* a {@link CategoryAxis}. Instances of this class are immutable and other
|
||||
* JFreeChart classes rely upon this.
|
||||
*/
|
||||
public class CategoryLabelPosition implements Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
private static final long serialVersionUID = 5168681143844183864L;
|
||||
|
||||
/** The category anchor point. */
|
||||
private RectangleAnchor categoryAnchor;
|
||||
|
||||
/** The text block anchor. */
|
||||
private TextBlockAnchor labelAnchor;
|
||||
|
||||
/** The rotation anchor. */
|
||||
private TextAnchor rotationAnchor;
|
||||
|
||||
/** The rotation angle (in radians). */
|
||||
private double angle;
|
||||
|
||||
/** The width calculation type. */
|
||||
private CategoryLabelWidthType widthType;
|
||||
|
||||
/**
|
||||
* The maximum label width as a percentage of the category space or the
|
||||
* range space.
|
||||
*/
|
||||
private float widthRatio;
|
||||
|
||||
/**
|
||||
* Creates a new position record with default settings.
|
||||
*/
|
||||
public CategoryLabelPosition() {
|
||||
this(RectangleAnchor.CENTER, TextBlockAnchor.BOTTOM_CENTER,
|
||||
TextAnchor.CENTER, 0.0, CategoryLabelWidthType.CATEGORY, 0.95f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new category label position record.
|
||||
*
|
||||
* @param categoryAnchor the category anchor (<code>null</code> not
|
||||
* permitted).
|
||||
* @param labelAnchor the label anchor (<code>null</code> not permitted).
|
||||
*/
|
||||
public CategoryLabelPosition(RectangleAnchor categoryAnchor,
|
||||
TextBlockAnchor labelAnchor) {
|
||||
// argument checking delegated...
|
||||
this(categoryAnchor, labelAnchor, TextAnchor.CENTER, 0.0,
|
||||
CategoryLabelWidthType.CATEGORY, 0.95f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new category label position record.
|
||||
*
|
||||
* @param categoryAnchor the category anchor (<code>null</code> not
|
||||
* permitted).
|
||||
* @param labelAnchor the label anchor (<code>null</code> not permitted).
|
||||
* @param widthType the width type (<code>null</code> not permitted).
|
||||
* @param widthRatio the maximum label width as a percentage (of the
|
||||
* category space or the range space).
|
||||
*/
|
||||
public CategoryLabelPosition(RectangleAnchor categoryAnchor,
|
||||
TextBlockAnchor labelAnchor,
|
||||
CategoryLabelWidthType widthType,
|
||||
float widthRatio) {
|
||||
// argument checking delegated...
|
||||
this(categoryAnchor, labelAnchor, TextAnchor.CENTER, 0.0, widthType,
|
||||
widthRatio);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new position record. The item label anchor is a point
|
||||
* relative to the data item (dot, bar or other visual item) on a chart.
|
||||
* The item label is aligned by aligning the text anchor with the item
|
||||
* label anchor.
|
||||
*
|
||||
* @param categoryAnchor the category anchor (<code>null</code> not
|
||||
* permitted).
|
||||
* @param labelAnchor the label anchor (<code>null</code> not permitted).
|
||||
* @param rotationAnchor the rotation anchor (<code>null</code> not
|
||||
* permitted).
|
||||
* @param angle the rotation angle (<code>null</code> not permitted).
|
||||
* @param widthType the width type (<code>null</code> not permitted).
|
||||
* @param widthRatio the maximum label width as a percentage (of the
|
||||
* category space or the range space).
|
||||
*/
|
||||
public CategoryLabelPosition(RectangleAnchor categoryAnchor,
|
||||
TextBlockAnchor labelAnchor,
|
||||
TextAnchor rotationAnchor,
|
||||
double angle,
|
||||
CategoryLabelWidthType widthType,
|
||||
float widthRatio) {
|
||||
|
||||
if (categoryAnchor == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Null 'categoryAnchor' argument.");
|
||||
}
|
||||
if (labelAnchor == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Null 'labelAnchor' argument.");
|
||||
}
|
||||
if (rotationAnchor == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Null 'rotationAnchor' argument.");
|
||||
}
|
||||
if (widthType == null) {
|
||||
throw new IllegalArgumentException("Null 'widthType' argument.");
|
||||
}
|
||||
|
||||
this.categoryAnchor = categoryAnchor;
|
||||
this.labelAnchor = labelAnchor;
|
||||
this.rotationAnchor = rotationAnchor;
|
||||
this.angle = angle;
|
||||
this.widthType = widthType;
|
||||
this.widthRatio = widthRatio;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the item label anchor.
|
||||
*
|
||||
* @return The item label anchor (never <code>null</code>).
|
||||
*/
|
||||
public RectangleAnchor getCategoryAnchor() {
|
||||
return this.categoryAnchor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the text block anchor.
|
||||
*
|
||||
* @return The text block anchor (never <code>null</code>).
|
||||
*/
|
||||
public TextBlockAnchor getLabelAnchor() {
|
||||
return this.labelAnchor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rotation anchor point.
|
||||
*
|
||||
* @return The rotation anchor point (never <code>null</code>).
|
||||
*/
|
||||
public TextAnchor getRotationAnchor() {
|
||||
return this.rotationAnchor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the angle of rotation for the label.
|
||||
*
|
||||
* @return The angle (in radians).
|
||||
*/
|
||||
public double getAngle() {
|
||||
return this.angle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the width calculation type.
|
||||
*
|
||||
* @return The width calculation type (never <code>null</code>).
|
||||
*/
|
||||
public CategoryLabelWidthType getWidthType() {
|
||||
return this.widthType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ratio used to calculate the maximum category label width.
|
||||
*
|
||||
* @return The ratio.
|
||||
*/
|
||||
public float getWidthRatio() {
|
||||
return this.widthRatio;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this instance for equality with an arbitrary object.
|
||||
*
|
||||
* @param obj the object (<code>null</code> permitted).
|
||||
*
|
||||
* @return A boolean.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof CategoryLabelPosition)) {
|
||||
return false;
|
||||
}
|
||||
CategoryLabelPosition that = (CategoryLabelPosition) obj;
|
||||
if (!this.categoryAnchor.equals(that.categoryAnchor)) {
|
||||
return false;
|
||||
}
|
||||
if (!this.labelAnchor.equals(that.labelAnchor)) {
|
||||
return false;
|
||||
}
|
||||
if (!this.rotationAnchor.equals(that.rotationAnchor)) {
|
||||
return false;
|
||||
}
|
||||
if (this.angle != that.angle) {
|
||||
return false;
|
||||
}
|
||||
if (this.widthType != that.widthType) {
|
||||
return false;
|
||||
}
|
||||
if (this.widthRatio != that.widthRatio) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for this object.
|
||||
*
|
||||
* @return A hash code.
|
||||
*/
|
||||
public int hashCode() {
|
||||
int result = 19;
|
||||
result = 37 * result + this.categoryAnchor.hashCode();
|
||||
result = 37 * result + this.labelAnchor.hashCode();
|
||||
result = 37 * result + this.rotationAnchor.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,459 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* ---------------------------
|
||||
* CategoryLabelPositions.java
|
||||
* ---------------------------
|
||||
* (C) Copyright 2004-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 06-Jan-2004 : Version 1 (DG);
|
||||
* 17-Feb-2004 : Added equals() method (DG);
|
||||
* 05-Nov-2004 : Adjusted settings for UP_90 and DOWN_90 (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.axis;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.jfree.text.TextBlockAnchor;
|
||||
import org.jfree.ui.RectangleAnchor;
|
||||
import org.jfree.ui.RectangleEdge;
|
||||
import org.jfree.ui.TextAnchor;
|
||||
|
||||
/**
|
||||
* Records the label positions for a category axis. Instances of this class
|
||||
* are immutable.
|
||||
*/
|
||||
public class CategoryLabelPositions implements Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
private static final long serialVersionUID = -8999557901920364580L;
|
||||
|
||||
/** STANDARD category label positions. */
|
||||
public static final CategoryLabelPositions
|
||||
STANDARD = new CategoryLabelPositions(
|
||||
new CategoryLabelPosition(
|
||||
RectangleAnchor.BOTTOM, TextBlockAnchor.BOTTOM_CENTER
|
||||
), // TOP
|
||||
new CategoryLabelPosition(
|
||||
RectangleAnchor.TOP, TextBlockAnchor.TOP_CENTER
|
||||
), // BOTTOM
|
||||
new CategoryLabelPosition(
|
||||
RectangleAnchor.RIGHT, TextBlockAnchor.CENTER_RIGHT,
|
||||
CategoryLabelWidthType.RANGE, 0.30f
|
||||
), // LEFT
|
||||
new CategoryLabelPosition(
|
||||
RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT,
|
||||
CategoryLabelWidthType.RANGE, 0.30f
|
||||
) // RIGHT
|
||||
);
|
||||
|
||||
/** UP_90 category label positions. */
|
||||
public static final CategoryLabelPositions
|
||||
UP_90 = new CategoryLabelPositions(
|
||||
new CategoryLabelPosition(
|
||||
RectangleAnchor.BOTTOM, TextBlockAnchor.CENTER_LEFT,
|
||||
TextAnchor.CENTER_LEFT, -Math.PI / 2.0,
|
||||
CategoryLabelWidthType.RANGE, 0.30f
|
||||
), // TOP
|
||||
new CategoryLabelPosition(
|
||||
RectangleAnchor.TOP, TextBlockAnchor.CENTER_RIGHT,
|
||||
TextAnchor.CENTER_RIGHT, -Math.PI / 2.0,
|
||||
CategoryLabelWidthType.RANGE, 0.30f
|
||||
), // BOTTOM
|
||||
new CategoryLabelPosition(
|
||||
RectangleAnchor.RIGHT, TextBlockAnchor.BOTTOM_CENTER,
|
||||
TextAnchor.BOTTOM_CENTER, -Math.PI / 2.0,
|
||||
CategoryLabelWidthType.CATEGORY, 0.9f
|
||||
), // LEFT
|
||||
new CategoryLabelPosition(
|
||||
RectangleAnchor.LEFT, TextBlockAnchor.TOP_CENTER,
|
||||
TextAnchor.TOP_CENTER, -Math.PI / 2.0,
|
||||
CategoryLabelWidthType.CATEGORY, 0.90f
|
||||
) // RIGHT
|
||||
);
|
||||
|
||||
/** DOWN_90 category label positions. */
|
||||
public static final CategoryLabelPositions
|
||||
DOWN_90 = new CategoryLabelPositions(
|
||||
new CategoryLabelPosition(
|
||||
RectangleAnchor.BOTTOM, TextBlockAnchor.CENTER_RIGHT,
|
||||
TextAnchor.CENTER_RIGHT, Math.PI / 2.0,
|
||||
CategoryLabelWidthType.RANGE, 0.30f
|
||||
), // TOP
|
||||
new CategoryLabelPosition(
|
||||
RectangleAnchor.TOP, TextBlockAnchor.CENTER_LEFT,
|
||||
TextAnchor.CENTER_LEFT, Math.PI / 2.0,
|
||||
CategoryLabelWidthType.RANGE, 0.30f
|
||||
), // BOTTOM
|
||||
new CategoryLabelPosition(
|
||||
RectangleAnchor.RIGHT, TextBlockAnchor.TOP_CENTER,
|
||||
TextAnchor.TOP_CENTER, Math.PI / 2.0,
|
||||
CategoryLabelWidthType.CATEGORY, 0.90f
|
||||
), // LEFT
|
||||
new CategoryLabelPosition(
|
||||
RectangleAnchor.LEFT, TextBlockAnchor.BOTTOM_CENTER,
|
||||
TextAnchor.BOTTOM_CENTER, Math.PI / 2.0,
|
||||
CategoryLabelWidthType.CATEGORY, 0.90f
|
||||
) // RIGHT
|
||||
);
|
||||
|
||||
/** UP_45 category label positions. */
|
||||
public static final CategoryLabelPositions UP_45
|
||||
= createUpRotationLabelPositions(Math.PI / 4.0);
|
||||
|
||||
/** DOWN_45 category label positions. */
|
||||
public static final CategoryLabelPositions DOWN_45
|
||||
= createDownRotationLabelPositions(Math.PI / 4.0);
|
||||
|
||||
/**
|
||||
* Creates a new instance where the category labels angled upwards by the
|
||||
* specified amount.
|
||||
*
|
||||
* @param angle the rotation angle (should be < Math.PI / 2.0).
|
||||
*
|
||||
* @return A category label position specification.
|
||||
*/
|
||||
public static CategoryLabelPositions createUpRotationLabelPositions(
|
||||
double angle) {
|
||||
return new CategoryLabelPositions(
|
||||
new CategoryLabelPosition(
|
||||
RectangleAnchor.BOTTOM, TextBlockAnchor.BOTTOM_LEFT,
|
||||
TextAnchor.BOTTOM_LEFT, -angle,
|
||||
CategoryLabelWidthType.RANGE, 0.50f
|
||||
), // TOP
|
||||
new CategoryLabelPosition(
|
||||
RectangleAnchor.TOP, TextBlockAnchor.TOP_RIGHT,
|
||||
TextAnchor.TOP_RIGHT, -angle,
|
||||
CategoryLabelWidthType.RANGE, 0.50f
|
||||
), // BOTTOM
|
||||
new CategoryLabelPosition(
|
||||
RectangleAnchor.RIGHT, TextBlockAnchor.BOTTOM_RIGHT,
|
||||
TextAnchor.BOTTOM_RIGHT, -angle,
|
||||
CategoryLabelWidthType.RANGE, 0.50f
|
||||
), // LEFT
|
||||
new CategoryLabelPosition(
|
||||
RectangleAnchor.LEFT, TextBlockAnchor.TOP_LEFT,
|
||||
TextAnchor.TOP_LEFT, -angle,
|
||||
CategoryLabelWidthType.RANGE, 0.50f
|
||||
) // RIGHT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance where the category labels angled downwards by the
|
||||
* specified amount.
|
||||
*
|
||||
* @param angle the rotation angle (should be < Math.PI / 2.0).
|
||||
*
|
||||
* @return A category label position specification.
|
||||
*/
|
||||
public static CategoryLabelPositions createDownRotationLabelPositions(
|
||||
double angle) {
|
||||
return new CategoryLabelPositions(
|
||||
new CategoryLabelPosition(
|
||||
RectangleAnchor.BOTTOM, TextBlockAnchor.BOTTOM_RIGHT,
|
||||
TextAnchor.BOTTOM_RIGHT, angle,
|
||||
CategoryLabelWidthType.RANGE, 0.50f
|
||||
), // TOP
|
||||
new CategoryLabelPosition(
|
||||
RectangleAnchor.TOP, TextBlockAnchor.TOP_LEFT,
|
||||
TextAnchor.TOP_LEFT, angle,
|
||||
CategoryLabelWidthType.RANGE, 0.50f
|
||||
), // BOTTOM
|
||||
new CategoryLabelPosition(
|
||||
RectangleAnchor.RIGHT, TextBlockAnchor.TOP_RIGHT,
|
||||
TextAnchor.TOP_RIGHT, angle,
|
||||
CategoryLabelWidthType.RANGE, 0.50f
|
||||
), // LEFT
|
||||
new CategoryLabelPosition(
|
||||
RectangleAnchor.LEFT, TextBlockAnchor.BOTTOM_LEFT,
|
||||
TextAnchor.BOTTOM_LEFT, angle,
|
||||
CategoryLabelWidthType.RANGE, 0.50f
|
||||
) // RIGHT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The label positioning details used when an axis is at the top of a
|
||||
* chart.
|
||||
*/
|
||||
private CategoryLabelPosition positionForAxisAtTop;
|
||||
|
||||
/**
|
||||
* The label positioning details used when an axis is at the bottom of a
|
||||
* chart.
|
||||
*/
|
||||
private CategoryLabelPosition positionForAxisAtBottom;
|
||||
|
||||
/**
|
||||
* The label positioning details used when an axis is at the left of a
|
||||
* chart.
|
||||
*/
|
||||
private CategoryLabelPosition positionForAxisAtLeft;
|
||||
|
||||
/**
|
||||
* The label positioning details used when an axis is at the right of a
|
||||
* chart.
|
||||
*/
|
||||
private CategoryLabelPosition positionForAxisAtRight;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public CategoryLabelPositions() {
|
||||
this.positionForAxisAtTop = new CategoryLabelPosition();
|
||||
this.positionForAxisAtBottom = new CategoryLabelPosition();
|
||||
this.positionForAxisAtLeft = new CategoryLabelPosition();
|
||||
this.positionForAxisAtRight = new CategoryLabelPosition();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new position specification.
|
||||
*
|
||||
* @param top the label position info used when an axis is at the top
|
||||
* (<code>null</code> not permitted).
|
||||
* @param bottom the label position info used when an axis is at the
|
||||
* bottom (<code>null</code> not permitted).
|
||||
* @param left the label position info used when an axis is at the left
|
||||
* (<code>null</code> not permitted).
|
||||
* @param right the label position info used when an axis is at the right
|
||||
* (<code>null</code> not permitted).
|
||||
*/
|
||||
public CategoryLabelPositions(CategoryLabelPosition top,
|
||||
CategoryLabelPosition bottom,
|
||||
CategoryLabelPosition left,
|
||||
CategoryLabelPosition right) {
|
||||
|
||||
if (top == null) {
|
||||
throw new IllegalArgumentException("Null 'top' argument.");
|
||||
}
|
||||
if (bottom == null) {
|
||||
throw new IllegalArgumentException("Null 'bottom' argument.");
|
||||
}
|
||||
if (left == null) {
|
||||
throw new IllegalArgumentException("Null 'left' argument.");
|
||||
}
|
||||
if (right == null) {
|
||||
throw new IllegalArgumentException("Null 'right' argument.");
|
||||
}
|
||||
|
||||
this.positionForAxisAtTop = top;
|
||||
this.positionForAxisAtBottom = bottom;
|
||||
this.positionForAxisAtLeft = left;
|
||||
this.positionForAxisAtRight = right;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the category label position specification for an axis at the
|
||||
* given location.
|
||||
*
|
||||
* @param edge the axis location.
|
||||
*
|
||||
* @return The category label position specification.
|
||||
*/
|
||||
public CategoryLabelPosition getLabelPosition(RectangleEdge edge) {
|
||||
CategoryLabelPosition result = null;
|
||||
if (edge == RectangleEdge.TOP) {
|
||||
result = this.positionForAxisAtTop;
|
||||
}
|
||||
else if (edge == RectangleEdge.BOTTOM) {
|
||||
result = this.positionForAxisAtBottom;
|
||||
}
|
||||
else if (edge == RectangleEdge.LEFT) {
|
||||
result = this.positionForAxisAtLeft;
|
||||
}
|
||||
else if (edge == RectangleEdge.RIGHT) {
|
||||
result = this.positionForAxisAtRight;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new instance based on an existing instance but with the top
|
||||
* position changed.
|
||||
*
|
||||
* @param base the base (<code>null</code> not permitted).
|
||||
* @param top the top position (<code>null</code> not permitted).
|
||||
*
|
||||
* @return A new instance (never <code>null</code>).
|
||||
*/
|
||||
public static CategoryLabelPositions replaceTopPosition(
|
||||
CategoryLabelPositions base, CategoryLabelPosition top) {
|
||||
|
||||
if (base == null) {
|
||||
throw new IllegalArgumentException("Null 'base' argument.");
|
||||
}
|
||||
if (top == null) {
|
||||
throw new IllegalArgumentException("Null 'top' argument.");
|
||||
}
|
||||
|
||||
return new CategoryLabelPositions(
|
||||
top,
|
||||
base.getLabelPosition(RectangleEdge.BOTTOM),
|
||||
base.getLabelPosition(RectangleEdge.LEFT),
|
||||
base.getLabelPosition(RectangleEdge.RIGHT)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new instance based on an existing instance but with the bottom
|
||||
* position changed.
|
||||
*
|
||||
* @param base the base (<code>null</code> not permitted).
|
||||
* @param bottom the bottom position (<code>null</code> not permitted).
|
||||
*
|
||||
* @return A new instance (never <code>null</code>).
|
||||
*/
|
||||
public static CategoryLabelPositions replaceBottomPosition(
|
||||
CategoryLabelPositions base, CategoryLabelPosition bottom) {
|
||||
|
||||
if (base == null) {
|
||||
throw new IllegalArgumentException("Null 'base' argument.");
|
||||
}
|
||||
if (bottom == null) {
|
||||
throw new IllegalArgumentException("Null 'bottom' argument.");
|
||||
}
|
||||
|
||||
return new CategoryLabelPositions(
|
||||
base.getLabelPosition(RectangleEdge.TOP),
|
||||
bottom,
|
||||
base.getLabelPosition(RectangleEdge.LEFT),
|
||||
base.getLabelPosition(RectangleEdge.RIGHT)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new instance based on an existing instance but with the left
|
||||
* position changed.
|
||||
*
|
||||
* @param base the base (<code>null</code> not permitted).
|
||||
* @param left the left position (<code>null</code> not permitted).
|
||||
*
|
||||
* @return A new instance (never <code>null</code>).
|
||||
*/
|
||||
public static CategoryLabelPositions replaceLeftPosition(
|
||||
CategoryLabelPositions base, CategoryLabelPosition left) {
|
||||
|
||||
if (base == null) {
|
||||
throw new IllegalArgumentException("Null 'base' argument.");
|
||||
}
|
||||
if (left == null) {
|
||||
throw new IllegalArgumentException("Null 'left' argument.");
|
||||
}
|
||||
|
||||
return new CategoryLabelPositions(
|
||||
base.getLabelPosition(RectangleEdge.TOP),
|
||||
base.getLabelPosition(RectangleEdge.BOTTOM),
|
||||
left,
|
||||
base.getLabelPosition(RectangleEdge.RIGHT)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new instance based on an existing instance but with the right
|
||||
* position changed.
|
||||
*
|
||||
* @param base the base (<code>null</code> not permitted).
|
||||
* @param right the right position (<code>null</code> not permitted).
|
||||
*
|
||||
* @return A new instance (never <code>null</code>).
|
||||
*/
|
||||
public static CategoryLabelPositions replaceRightPosition(
|
||||
CategoryLabelPositions base, CategoryLabelPosition right) {
|
||||
|
||||
if (base == null) {
|
||||
throw new IllegalArgumentException("Null 'base' argument.");
|
||||
}
|
||||
if (right == null) {
|
||||
throw new IllegalArgumentException("Null 'right' argument.");
|
||||
}
|
||||
|
||||
return new CategoryLabelPositions(
|
||||
base.getLabelPosition(RectangleEdge.TOP),
|
||||
base.getLabelPosition(RectangleEdge.BOTTOM),
|
||||
base.getLabelPosition(RectangleEdge.LEFT),
|
||||
right
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if this object is equal to the specified
|
||||
* object, and <code>false</code> otherwise.
|
||||
*
|
||||
* @param obj the other object.
|
||||
*
|
||||
* @return A boolean.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof CategoryLabelPositions)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CategoryLabelPositions that = (CategoryLabelPositions) obj;
|
||||
if (!this.positionForAxisAtTop.equals(that.positionForAxisAtTop)) {
|
||||
return false;
|
||||
}
|
||||
if (!this.positionForAxisAtBottom.equals(
|
||||
that.positionForAxisAtBottom)) {
|
||||
return false;
|
||||
}
|
||||
if (!this.positionForAxisAtLeft.equals(that.positionForAxisAtLeft)) {
|
||||
return false;
|
||||
}
|
||||
if (!this.positionForAxisAtRight.equals(that.positionForAxisAtRight)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for this object.
|
||||
*
|
||||
* @return A hash code.
|
||||
*/
|
||||
public int hashCode() {
|
||||
int result = 19;
|
||||
result = 37 * result + this.positionForAxisAtTop.hashCode();
|
||||
result = 37 * result + this.positionForAxisAtBottom.hashCode();
|
||||
result = 37 * result + this.positionForAxisAtLeft.hashCode();
|
||||
result = 37 * result + this.positionForAxisAtRight.hashCode();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,129 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* ---------------------------
|
||||
* CategoryLabelWidthType.java
|
||||
* ---------------------------
|
||||
* (C) Copyright 2004-2008, by Object Refinery Limited.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes:
|
||||
* --------
|
||||
* 24-Mar-2004 : Version 1 (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.axis;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Represents the width types for a category label.
|
||||
*/
|
||||
public final class CategoryLabelWidthType implements Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
private static final long serialVersionUID = -6976024792582949656L;
|
||||
|
||||
/** Percentage of category. */
|
||||
public static final CategoryLabelWidthType
|
||||
CATEGORY = new CategoryLabelWidthType(
|
||||
"CategoryLabelWidthType.CATEGORY"
|
||||
);
|
||||
|
||||
/** Percentage of range. */
|
||||
public static final CategoryLabelWidthType
|
||||
RANGE = new CategoryLabelWidthType("CategoryLabelWidthType.RANGE");
|
||||
|
||||
/** The name. */
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* Private constructor.
|
||||
*
|
||||
* @param name the name (<code>null</code> not permitted).
|
||||
*/
|
||||
private CategoryLabelWidthType(String name) {
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException("Null 'name' argument.");
|
||||
}
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representing the object.
|
||||
*
|
||||
* @return The string (never </code>null</code>).
|
||||
*/
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if this object is equal to the specified
|
||||
* object, and <code>false</code> otherwise.
|
||||
*
|
||||
* @param obj the other object.
|
||||
*
|
||||
* @return A boolean.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof CategoryLabelWidthType)) {
|
||||
return false;
|
||||
}
|
||||
CategoryLabelWidthType t = (CategoryLabelWidthType) obj;
|
||||
if (!this.name.equals(t.toString())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that serialization returns the unique instances.
|
||||
*
|
||||
* @return The object.
|
||||
*
|
||||
* @throws ObjectStreamException if there is a problem.
|
||||
*/
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
if (this.equals(CategoryLabelWidthType.CATEGORY)) {
|
||||
return CategoryLabelWidthType.CATEGORY;
|
||||
}
|
||||
else if (this.equals(CategoryLabelWidthType.RANGE)) {
|
||||
return CategoryLabelWidthType.RANGE;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,151 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -----------------
|
||||
* CategoryTick.java
|
||||
* -----------------
|
||||
* (C) Copyright 2003-2008, by Object Refinery Limited.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 07-Nov-2003 : Version 1 (DG);
|
||||
* 13-May-2004 : Added equals() method (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.axis;
|
||||
|
||||
import org.jfree.text.TextBlock;
|
||||
import org.jfree.text.TextBlockAnchor;
|
||||
import org.jfree.ui.TextAnchor;
|
||||
import org.jfree.util.ObjectUtilities;
|
||||
|
||||
/**
|
||||
* A tick for a {@link CategoryAxis}.
|
||||
*/
|
||||
public class CategoryTick extends Tick {
|
||||
|
||||
/** The category. */
|
||||
private Comparable category;
|
||||
|
||||
/** The label. */
|
||||
private TextBlock label;
|
||||
|
||||
/** The label anchor. */
|
||||
private TextBlockAnchor labelAnchor;
|
||||
|
||||
/**
|
||||
* Creates a new tick.
|
||||
*
|
||||
* @param category the category.
|
||||
* @param label the label.
|
||||
* @param labelAnchor the label anchor.
|
||||
* @param rotationAnchor the rotation anchor.
|
||||
* @param angle the rotation angle (in radians).
|
||||
*/
|
||||
public CategoryTick(Comparable category,
|
||||
TextBlock label,
|
||||
TextBlockAnchor labelAnchor,
|
||||
TextAnchor rotationAnchor,
|
||||
double angle) {
|
||||
|
||||
super("", TextAnchor.CENTER, rotationAnchor, angle);
|
||||
this.category = category;
|
||||
this.label = label;
|
||||
this.labelAnchor = labelAnchor;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the category.
|
||||
*
|
||||
* @return The category.
|
||||
*/
|
||||
public Comparable getCategory() {
|
||||
return this.category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the label.
|
||||
*
|
||||
* @return The label.
|
||||
*/
|
||||
public TextBlock getLabel() {
|
||||
return this.label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the label anchor.
|
||||
*
|
||||
* @return The label anchor.
|
||||
*/
|
||||
public TextBlockAnchor getLabelAnchor() {
|
||||
return this.labelAnchor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this category tick for equality with an arbitrary object.
|
||||
*
|
||||
* @param obj the object (<code>null</code> permitted).
|
||||
*
|
||||
* @return A boolean.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof CategoryTick && super.equals(obj)) {
|
||||
CategoryTick that = (CategoryTick) obj;
|
||||
if (!ObjectUtilities.equal(this.category, that.category)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtilities.equal(this.label, that.label)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtilities.equal(this.labelAnchor, that.labelAnchor)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for this object.
|
||||
*
|
||||
* @return A hash code.
|
||||
*/
|
||||
public int hashCode() {
|
||||
int result = 41;
|
||||
result = 37 * result + this.category.hashCode();
|
||||
result = 37 * result + this.label.hashCode();
|
||||
result = 37 * result + this.labelAnchor.hashCode();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,471 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -------------
|
||||
* ColorBar.java
|
||||
* -------------
|
||||
* (C) Copyright 2002-2008, by David M. O'Donnell and Contributors.
|
||||
*
|
||||
* Original Author: David M. O'Donnell;
|
||||
* Contributor(s): David Gilbert (for Object Refinery Limited);
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 26-Nov-2002 : Version 1 contributed by David M. O'Donnell (DG);
|
||||
* 14-Jan-2003 : Changed autoRangeMinimumSize from Number --> double (DG);
|
||||
* 17-Jan-2003 : Moved plot classes to separate package (DG);
|
||||
* 20-Jan-2003 : Removed unnecessary constructors (DG);
|
||||
* 26-Mar-2003 : Implemented Serializable (DG);
|
||||
* 09-Jul-2003 : Changed ColorBar from extending axis classes to enclosing
|
||||
* them (DG);
|
||||
* 05-Aug-2003 : Applied changes in bug report 780298 (DG);
|
||||
* 14-Aug-2003 : Implemented Cloneable (DG);
|
||||
* 08-Sep-2003 : Changed ValueAxis API (DG);
|
||||
* 21-Jan-2004 : Update for renamed method in ValueAxis (DG);
|
||||
* ------------- JFREECHART 1.0.x ---------------------------------------------
|
||||
* 31-Jan-2007 : Deprecated (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.axis;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Paint;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.Stroke;
|
||||
import java.awt.geom.Line2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.jfree.chart.plot.ColorPalette;
|
||||
import org.jfree.chart.plot.ContourPlot;
|
||||
import org.jfree.chart.plot.Plot;
|
||||
import org.jfree.chart.plot.RainbowPalette;
|
||||
import org.jfree.chart.plot.XYPlot;
|
||||
import org.jfree.chart.renderer.xy.XYBlockRenderer;
|
||||
import org.jfree.ui.RectangleEdge;
|
||||
|
||||
/**
|
||||
* A color bar.
|
||||
*
|
||||
* @deprecated This class is no longer supported (as of version 1.0.4). If
|
||||
* you are creating contour plots, please try to use {@link XYPlot} and
|
||||
* {@link XYBlockRenderer}.
|
||||
*/
|
||||
public class ColorBar implements Cloneable, Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
private static final long serialVersionUID = -2101776212647268103L;
|
||||
|
||||
/** The default color bar thickness. */
|
||||
public static final int DEFAULT_COLORBAR_THICKNESS = 0;
|
||||
|
||||
/** The default color bar thickness percentage. */
|
||||
public static final double DEFAULT_COLORBAR_THICKNESS_PERCENT = 0.10;
|
||||
|
||||
/** The default outer gap. */
|
||||
public static final int DEFAULT_OUTERGAP = 2;
|
||||
|
||||
/** The axis. */
|
||||
private ValueAxis axis;
|
||||
|
||||
/** The color bar thickness. */
|
||||
private int colorBarThickness = DEFAULT_COLORBAR_THICKNESS;
|
||||
|
||||
/**
|
||||
* The color bar thickness as a percentage of the height of the data area.
|
||||
*/
|
||||
private double colorBarThicknessPercent
|
||||
= DEFAULT_COLORBAR_THICKNESS_PERCENT;
|
||||
|
||||
/** The color palette. */
|
||||
private ColorPalette colorPalette = null;
|
||||
|
||||
/** The color bar length. */
|
||||
private int colorBarLength = 0; // default make height of plotArea
|
||||
|
||||
/** The amount of blank space around the colorbar. */
|
||||
private int outerGap;
|
||||
|
||||
/**
|
||||
* Constructs a horizontal colorbar axis, using default values where
|
||||
* necessary.
|
||||
*
|
||||
* @param label the axis label.
|
||||
*/
|
||||
public ColorBar(String label) {
|
||||
|
||||
NumberAxis a = new NumberAxis(label);
|
||||
a.setAutoRangeIncludesZero(false);
|
||||
this.axis = a;
|
||||
this.axis.setLowerMargin(0.0);
|
||||
this.axis.setUpperMargin(0.0);
|
||||
|
||||
this.colorPalette = new RainbowPalette();
|
||||
this.colorBarThickness = DEFAULT_COLORBAR_THICKNESS;
|
||||
this.colorBarThicknessPercent = DEFAULT_COLORBAR_THICKNESS_PERCENT;
|
||||
this.outerGap = DEFAULT_OUTERGAP;
|
||||
this.colorPalette.setMinZ(this.axis.getRange().getLowerBound());
|
||||
this.colorPalette.setMaxZ(this.axis.getRange().getUpperBound());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the color bar.
|
||||
*
|
||||
* @param plot the plot.
|
||||
*/
|
||||
public void configure(ContourPlot plot) {
|
||||
double minZ = plot.getDataset().getMinZValue();
|
||||
double maxZ = plot.getDataset().getMaxZValue();
|
||||
setMinimumValue(minZ);
|
||||
setMaximumValue(maxZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the axis.
|
||||
*
|
||||
* @return The axis.
|
||||
*/
|
||||
public ValueAxis getAxis() {
|
||||
return this.axis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the axis.
|
||||
*
|
||||
* @param axis the axis.
|
||||
*/
|
||||
public void setAxis(ValueAxis axis) {
|
||||
this.axis = axis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rescales the axis to ensure that all data are visible.
|
||||
*/
|
||||
public void autoAdjustRange() {
|
||||
this.axis.autoAdjustRange();
|
||||
this.colorPalette.setMinZ(this.axis.getLowerBound());
|
||||
this.colorPalette.setMaxZ(this.axis.getUpperBound());
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the plot on a Java 2D graphics device (such as the screen or a
|
||||
* printer).
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
* @param cursor the cursor.
|
||||
* @param plotArea the area within which the chart should be drawn.
|
||||
* @param dataArea the area within which the plot should be drawn (a
|
||||
* subset of the drawArea).
|
||||
* @param reservedArea the reserved area.
|
||||
* @param edge the color bar location.
|
||||
*
|
||||
* @return The new cursor location.
|
||||
*/
|
||||
public double draw(Graphics2D g2, double cursor,
|
||||
Rectangle2D plotArea, Rectangle2D dataArea,
|
||||
Rectangle2D reservedArea, RectangleEdge edge) {
|
||||
|
||||
|
||||
Rectangle2D colorBarArea = null;
|
||||
|
||||
double thickness = calculateBarThickness(dataArea, edge);
|
||||
if (this.colorBarThickness > 0) {
|
||||
thickness = this.colorBarThickness; // allow fixed thickness
|
||||
}
|
||||
|
||||
double length = 0.0;
|
||||
if (RectangleEdge.isLeftOrRight(edge)) {
|
||||
length = dataArea.getHeight();
|
||||
}
|
||||
else {
|
||||
length = dataArea.getWidth();
|
||||
}
|
||||
|
||||
if (this.colorBarLength > 0) {
|
||||
length = this.colorBarLength;
|
||||
}
|
||||
|
||||
if (edge == RectangleEdge.BOTTOM) {
|
||||
colorBarArea = new Rectangle2D.Double(dataArea.getX(),
|
||||
plotArea.getMaxY() + this.outerGap, length, thickness);
|
||||
}
|
||||
else if (edge == RectangleEdge.TOP) {
|
||||
colorBarArea = new Rectangle2D.Double(dataArea.getX(),
|
||||
reservedArea.getMinY() + this.outerGap, length, thickness);
|
||||
}
|
||||
else if (edge == RectangleEdge.LEFT) {
|
||||
colorBarArea = new Rectangle2D.Double(plotArea.getX() - thickness
|
||||
- this.outerGap, dataArea.getMinY(), thickness, length);
|
||||
}
|
||||
else if (edge == RectangleEdge.RIGHT) {
|
||||
colorBarArea = new Rectangle2D.Double(plotArea.getMaxX()
|
||||
+ this.outerGap, dataArea.getMinY(), thickness, length);
|
||||
}
|
||||
|
||||
// update, but dont draw tick marks (needed for stepped colors)
|
||||
this.axis.refreshTicks(g2, new AxisState(), colorBarArea, edge);
|
||||
|
||||
drawColorBar(g2, colorBarArea, edge);
|
||||
|
||||
AxisState state = null;
|
||||
if (edge == RectangleEdge.TOP) {
|
||||
cursor = colorBarArea.getMinY();
|
||||
state = this.axis.draw(g2, cursor, reservedArea, colorBarArea,
|
||||
RectangleEdge.TOP, null);
|
||||
}
|
||||
else if (edge == RectangleEdge.BOTTOM) {
|
||||
cursor = colorBarArea.getMaxY();
|
||||
state = this.axis.draw(g2, cursor, reservedArea, colorBarArea,
|
||||
RectangleEdge.BOTTOM, null);
|
||||
}
|
||||
else if (edge == RectangleEdge.LEFT) {
|
||||
cursor = colorBarArea.getMinX();
|
||||
state = this.axis.draw(g2, cursor, reservedArea, colorBarArea,
|
||||
RectangleEdge.LEFT, null);
|
||||
}
|
||||
else if (edge == RectangleEdge.RIGHT) {
|
||||
cursor = colorBarArea.getMaxX();
|
||||
state = this.axis.draw(g2, cursor, reservedArea, colorBarArea,
|
||||
RectangleEdge.RIGHT, null);
|
||||
}
|
||||
return state.getCursor();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the plot on a Java 2D graphics device (such as the screen or a
|
||||
* printer).
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
* @param colorBarArea the area within which the axis should be drawn.
|
||||
* @param edge the location.
|
||||
*/
|
||||
public void drawColorBar(Graphics2D g2, Rectangle2D colorBarArea,
|
||||
RectangleEdge edge) {
|
||||
|
||||
Object antiAlias = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_OFF);
|
||||
|
||||
// setTickValues was missing from ColorPalette v. 0.96
|
||||
//colorPalette.setTickValues(this.axis.getTicks());
|
||||
|
||||
Stroke strokeSaved = g2.getStroke();
|
||||
g2.setStroke(new BasicStroke(1.0f));
|
||||
|
||||
if (RectangleEdge.isTopOrBottom(edge)) {
|
||||
double y1 = colorBarArea.getY();
|
||||
double y2 = colorBarArea.getMaxY();
|
||||
double xx = colorBarArea.getX();
|
||||
Line2D line = new Line2D.Double();
|
||||
while (xx <= colorBarArea.getMaxX()) {
|
||||
double value = this.axis.java2DToValue(xx, colorBarArea, edge);
|
||||
line.setLine(xx, y1, xx, y2);
|
||||
g2.setPaint(getPaint(value));
|
||||
g2.draw(line);
|
||||
xx += 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
double y1 = colorBarArea.getX();
|
||||
double y2 = colorBarArea.getMaxX();
|
||||
double xx = colorBarArea.getY();
|
||||
Line2D line = new Line2D.Double();
|
||||
while (xx <= colorBarArea.getMaxY()) {
|
||||
double value = this.axis.java2DToValue(xx, colorBarArea, edge);
|
||||
line.setLine(y1, xx, y2, xx);
|
||||
g2.setPaint(getPaint(value));
|
||||
g2.draw(line);
|
||||
xx += 1;
|
||||
}
|
||||
}
|
||||
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, antiAlias);
|
||||
g2.setStroke(strokeSaved);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the color palette.
|
||||
*
|
||||
* @return The color palette.
|
||||
*/
|
||||
public ColorPalette getColorPalette() {
|
||||
return this.colorPalette;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Paint associated with a value.
|
||||
*
|
||||
* @param value the value.
|
||||
*
|
||||
* @return The paint.
|
||||
*/
|
||||
public Paint getPaint(double value) {
|
||||
return this.colorPalette.getPaint(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the color palette.
|
||||
*
|
||||
* @param palette the new palette.
|
||||
*/
|
||||
public void setColorPalette(ColorPalette palette) {
|
||||
this.colorPalette = palette;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum value.
|
||||
*
|
||||
* @param value the maximum value.
|
||||
*/
|
||||
public void setMaximumValue(double value) {
|
||||
this.colorPalette.setMaxZ(value);
|
||||
this.axis.setUpperBound(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the minimum value.
|
||||
*
|
||||
* @param value the minimum value.
|
||||
*/
|
||||
public void setMinimumValue(double value) {
|
||||
this.colorPalette.setMinZ(value);
|
||||
this.axis.setLowerBound(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reserves the space required to draw the color bar.
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
* @param plot the plot that the axis belongs to.
|
||||
* @param plotArea the area within which the plot should be drawn.
|
||||
* @param dataArea the data area.
|
||||
* @param edge the axis location.
|
||||
* @param space the space already reserved.
|
||||
*
|
||||
* @return The space required to draw the axis in the specified plot area.
|
||||
*/
|
||||
public AxisSpace reserveSpace(Graphics2D g2, Plot plot,
|
||||
Rectangle2D plotArea,
|
||||
Rectangle2D dataArea, RectangleEdge edge,
|
||||
AxisSpace space) {
|
||||
|
||||
AxisSpace result = this.axis.reserveSpace(g2, plot, plotArea, edge,
|
||||
space);
|
||||
double thickness = calculateBarThickness(dataArea, edge);
|
||||
result.add(thickness + 2 * this.outerGap, edge);
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the bar thickness.
|
||||
*
|
||||
* @param plotArea the plot area.
|
||||
* @param edge the location.
|
||||
*
|
||||
* @return The thickness.
|
||||
*/
|
||||
private double calculateBarThickness(Rectangle2D plotArea,
|
||||
RectangleEdge edge) {
|
||||
double result = 0.0;
|
||||
if (RectangleEdge.isLeftOrRight(edge)) {
|
||||
result = plotArea.getWidth() * this.colorBarThicknessPercent;
|
||||
}
|
||||
else {
|
||||
result = plotArea.getHeight() * this.colorBarThicknessPercent;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone of the object.
|
||||
*
|
||||
* @return A clone.
|
||||
*
|
||||
* @throws CloneNotSupportedException if some component of the color bar
|
||||
* does not support cloning.
|
||||
*/
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
|
||||
ColorBar clone = (ColorBar) super.clone();
|
||||
clone.axis = (ValueAxis) this.axis.clone();
|
||||
return clone;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this object for equality with another.
|
||||
*
|
||||
* @param obj the object to test against.
|
||||
*
|
||||
* @return A boolean.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof ColorBar)) {
|
||||
return false;
|
||||
}
|
||||
ColorBar that = (ColorBar) obj;
|
||||
if (!this.axis.equals(that.axis)) {
|
||||
return false;
|
||||
}
|
||||
if (this.colorBarThickness != that.colorBarThickness) {
|
||||
return false;
|
||||
}
|
||||
if (this.colorBarThicknessPercent != that.colorBarThicknessPercent) {
|
||||
return false;
|
||||
}
|
||||
if (!this.colorPalette.equals(that.colorPalette)) {
|
||||
return false;
|
||||
}
|
||||
if (this.colorBarLength != that.colorBarLength) {
|
||||
return false;
|
||||
}
|
||||
if (this.outerGap != that.outerGap) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for this object.
|
||||
*
|
||||
* @return A hash code.
|
||||
*/
|
||||
public int hashCode() {
|
||||
return this.axis.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* ------------------
|
||||
* CompassFormat.java
|
||||
* ------------------
|
||||
* (C) Copyright 2003-2008, by Sylvain Vieujot and Contributors.
|
||||
*
|
||||
* Original Author: Sylvain Vieujot;
|
||||
* Contributor(s): David Gilbert (for Object Refinery Limited);
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 18-Feb-2004 : Version 1 contributed by Sylvain Vieujot (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.axis;
|
||||
|
||||
import java.text.FieldPosition;
|
||||
import java.text.NumberFormat;
|
||||
import java.text.ParsePosition;
|
||||
|
||||
/**
|
||||
* A formatter that displays numbers as directions.
|
||||
*/
|
||||
public class CompassFormat extends NumberFormat {
|
||||
|
||||
/** North. */
|
||||
private static final String N = "N";
|
||||
|
||||
/** East. */
|
||||
private static final String E = "E";
|
||||
|
||||
/** South. */
|
||||
private static final String S = "S";
|
||||
|
||||
/** West. */
|
||||
private static final String W = "W";
|
||||
|
||||
/** The directions. */
|
||||
public static final String[] DIRECTIONS = {
|
||||
N, N + N + E, N + E, E + N + E, E, E + S + E, S + E, S + S + E, S,
|
||||
S + S + W, S + W, W + S + W, W, W + N + W, N + W, N + N + W, N
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new formatter.
|
||||
*/
|
||||
public CompassFormat() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representing the direction.
|
||||
*
|
||||
* @param direction the direction.
|
||||
*
|
||||
* @return A string.
|
||||
*/
|
||||
public String getDirectionCode(double direction) {
|
||||
|
||||
direction = direction % 360;
|
||||
if (direction < 0.0) {
|
||||
direction = direction + 360.0;
|
||||
}
|
||||
int index = ((int) Math.floor(direction / 11.25) + 1) / 2;
|
||||
return DIRECTIONS[index];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a number into the specified string buffer.
|
||||
*
|
||||
* @param number the number to format.
|
||||
* @param toAppendTo the string buffer.
|
||||
* @param pos the field position (ignored here).
|
||||
*
|
||||
* @return The string buffer.
|
||||
*/
|
||||
public StringBuffer format(double number, StringBuffer toAppendTo,
|
||||
FieldPosition pos) {
|
||||
return toAppendTo.append(getDirectionCode(number));
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a number into the specified string buffer.
|
||||
*
|
||||
* @param number the number to format.
|
||||
* @param toAppendTo the string buffer.
|
||||
* @param pos the field position (ignored here).
|
||||
*
|
||||
* @return The string buffer.
|
||||
*/
|
||||
public StringBuffer format(long number, StringBuffer toAppendTo,
|
||||
FieldPosition pos) {
|
||||
return toAppendTo.append(getDirectionCode(number));
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns <code>null</code> for all inputs. This class cannot
|
||||
* be used for parsing.
|
||||
*
|
||||
* @param source the source string.
|
||||
* @param parsePosition the parse position.
|
||||
*
|
||||
* @return <code>null</code>.
|
||||
*/
|
||||
public Number parse(String source, ParsePosition parsePosition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,138 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -------------
|
||||
* DateTick.java
|
||||
* -------------
|
||||
* (C) Copyright 2003-2008, by Object Refinery Limited.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): Peter Kolb (patch 1934255);
|
||||
* Andrew Mickish (patch 1870189);
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 07-Nov-2003 : Version 1 (DG);
|
||||
* 13-May-2004 : Added equals() method (DG);
|
||||
* 25-Sep-2008 : Added minor tick support, see patch 1934255 by Peter Kolb (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.axis;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.jfree.ui.TextAnchor;
|
||||
import org.jfree.util.ObjectUtilities;
|
||||
|
||||
/**
|
||||
* A tick used by the {@link DateAxis} class.
|
||||
*/
|
||||
public class DateTick extends ValueTick {
|
||||
|
||||
/** The date. */
|
||||
private Date date;
|
||||
|
||||
/**
|
||||
* Creates a new date tick.
|
||||
*
|
||||
* @param date the date.
|
||||
* @param label the label.
|
||||
* @param textAnchor the part of the label that is aligned to the anchor
|
||||
* point.
|
||||
* @param rotationAnchor defines the rotation point relative to the text.
|
||||
* @param angle the rotation angle (in radians).
|
||||
*/
|
||||
public DateTick(Date date, String label,
|
||||
TextAnchor textAnchor, TextAnchor rotationAnchor,
|
||||
double angle) {
|
||||
|
||||
this(TickType.MAJOR, date, label, textAnchor, rotationAnchor, angle);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new date tick.
|
||||
*
|
||||
* @param tickType the tick type.
|
||||
* @param date the date.
|
||||
* @param label the label.
|
||||
* @param textAnchor the part of the label that is aligned to the anchor
|
||||
* point.
|
||||
* @param rotationAnchor defines the rotation point relative to the text.
|
||||
* @param angle the rotation angle (in radians).
|
||||
*
|
||||
* @since 1.0.12
|
||||
*/
|
||||
public DateTick(TickType tickType, Date date, String label,
|
||||
TextAnchor textAnchor, TextAnchor rotationAnchor,
|
||||
double angle) {
|
||||
|
||||
super(tickType, date.getTime(), label, textAnchor, rotationAnchor, angle);
|
||||
this.date = date;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the date.
|
||||
*
|
||||
* @return The date.
|
||||
*/
|
||||
public Date getDate() {
|
||||
return this.date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this tick for equality with an arbitrary object.
|
||||
*
|
||||
* @param obj the object to test (<code>null</code> permitted).
|
||||
*
|
||||
* @return A boolean.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof DateTick)) {
|
||||
return false;
|
||||
}
|
||||
DateTick that = (DateTick) obj;
|
||||
if (!ObjectUtilities.equal(this.date, that.date)) {
|
||||
return false;
|
||||
}
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for this object.
|
||||
*
|
||||
* @return A hash code.
|
||||
*/
|
||||
public int hashCode() {
|
||||
return this.date.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -------------------------
|
||||
* DateTickMarkPosition.java
|
||||
* -------------------------
|
||||
* (C) Copyright 2003-2008, by Object Refinery Limited.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes:
|
||||
* --------
|
||||
* 30-Apr-2003 : Version 1 (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.axis;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Used to indicate the required position of tick marks on a date axis relative
|
||||
* to the underlying time period.
|
||||
*/
|
||||
public final class DateTickMarkPosition implements Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
private static final long serialVersionUID = 2540750672764537240L;
|
||||
|
||||
/** Start of period. */
|
||||
public static final DateTickMarkPosition START
|
||||
= new DateTickMarkPosition("DateTickMarkPosition.START");
|
||||
|
||||
/** Middle of period. */
|
||||
public static final DateTickMarkPosition MIDDLE
|
||||
= new DateTickMarkPosition("DateTickMarkPosition.MIDDLE");
|
||||
|
||||
/** End of period. */
|
||||
public static final DateTickMarkPosition END
|
||||
= new DateTickMarkPosition("DateTickMarkPosition.END");
|
||||
|
||||
/** The name. */
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* Private constructor.
|
||||
*
|
||||
* @param name the name.
|
||||
*/
|
||||
private DateTickMarkPosition(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representing the object.
|
||||
*
|
||||
* @return The string.
|
||||
*/
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if this object is equal to the specified
|
||||
* object, and <code>false</code> otherwise.
|
||||
*
|
||||
* @param obj the other object.
|
||||
*
|
||||
* @return A boolean.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof DateTickMarkPosition)) {
|
||||
return false;
|
||||
}
|
||||
DateTickMarkPosition position = (DateTickMarkPosition) obj;
|
||||
if (!this.name.equals(position.toString())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that serialization returns the unique instances.
|
||||
*
|
||||
* @return The object.
|
||||
*
|
||||
* @throws ObjectStreamException if there is a problem.
|
||||
*/
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
if (this.equals(DateTickMarkPosition.START)) {
|
||||
return DateTickMarkPosition.START;
|
||||
}
|
||||
else if (this.equals(DateTickMarkPosition.MIDDLE)) {
|
||||
return DateTickMarkPosition.MIDDLE;
|
||||
}
|
||||
else if (this.equals(DateTickMarkPosition.END)) {
|
||||
return DateTickMarkPosition.END;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,441 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -----------------
|
||||
* DateTickUnit.java
|
||||
* -----------------
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): Chris Boek;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 08-Nov-2002 : Moved to new package com.jrefinery.chart.axis (DG);
|
||||
* 27-Nov-2002 : Added IllegalArgumentException to getMillisecondCount()
|
||||
* method (DG);
|
||||
* 26-Mar-2003 : Implemented Serializable (DG);
|
||||
* 12-Nov-2003 : Added roll fields that can improve the labelling on segmented
|
||||
* date axes (DG);
|
||||
* 03-Dec-2003 : DateFormat constructor argument is now filled with an default
|
||||
* if null (TM);
|
||||
* 07-Dec-2003 : Fixed bug (null pointer exception) in constructor (DG);
|
||||
* ------------- JFREECHART 1.0.x ---------------------------------------------
|
||||
* 21-Mar-2007 : Added toString() for debugging (DG);
|
||||
* 04-Apr-2007 : Added new methods addToDate(Date, TimeZone) and rollDate(Date,
|
||||
* TimeZone) (CB);
|
||||
* 09-Jun-2008 : Deprecated addToDate(Date) (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.axis;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.jfree.util.ObjectUtilities;
|
||||
|
||||
/**
|
||||
* A tick unit for use by subclasses of {@link DateAxis}. Instances of this
|
||||
* class are immutable.
|
||||
*/
|
||||
public class DateTickUnit extends TickUnit implements Serializable {
|
||||
|
||||
/** For serialization. */
|
||||
private static final long serialVersionUID = -7289292157229621901L;
|
||||
|
||||
/** A constant for years. */
|
||||
public static final int YEAR = 0;
|
||||
|
||||
/** A constant for months. */
|
||||
public static final int MONTH = 1;
|
||||
|
||||
/** A constant for days. */
|
||||
public static final int DAY = 2;
|
||||
|
||||
/** A constant for hours. */
|
||||
public static final int HOUR = 3;
|
||||
|
||||
/** A constant for minutes. */
|
||||
public static final int MINUTE = 4;
|
||||
|
||||
/** A constant for seconds. */
|
||||
public static final int SECOND = 5;
|
||||
|
||||
/** A constant for milliseconds. */
|
||||
public static final int MILLISECOND = 6;
|
||||
|
||||
/** The unit. */
|
||||
private int unit;
|
||||
|
||||
/** The unit count. */
|
||||
private int count;
|
||||
|
||||
/** The roll unit. */
|
||||
private int rollUnit;
|
||||
|
||||
/** The roll count. */
|
||||
private int rollCount;
|
||||
|
||||
/** The date formatter. */
|
||||
private DateFormat formatter;
|
||||
|
||||
/**
|
||||
* Creates a new date tick unit. The dates will be formatted using a
|
||||
* SHORT format for the default locale.
|
||||
*
|
||||
* @param unit the unit.
|
||||
* @param count the unit count.
|
||||
*/
|
||||
public DateTickUnit(int unit, int count) {
|
||||
this(unit, count, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new date tick unit. You can specify the units using one of
|
||||
* the constants YEAR, MONTH, DAY, HOUR, MINUTE, SECOND or MILLISECOND.
|
||||
* In addition, you can specify a unit count, and a date format.
|
||||
*
|
||||
* @param unit the unit.
|
||||
* @param count the unit count.
|
||||
* @param formatter the date formatter (defaults to DateFormat.SHORT).
|
||||
*/
|
||||
public DateTickUnit(int unit, int count, DateFormat formatter) {
|
||||
|
||||
this(unit, count, unit, count, formatter);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new unit.
|
||||
*
|
||||
* @param unit the unit.
|
||||
* @param count the count.
|
||||
* @param rollUnit the roll unit.
|
||||
* @param rollCount the roll count.
|
||||
* @param formatter the date formatter (defaults to DateFormat.SHORT).
|
||||
*/
|
||||
public DateTickUnit(int unit, int count, int rollUnit, int rollCount,
|
||||
DateFormat formatter) {
|
||||
super(DateTickUnit.getMillisecondCount(unit, count));
|
||||
this.unit = unit;
|
||||
this.count = count;
|
||||
this.rollUnit = rollUnit;
|
||||
this.rollCount = rollCount;
|
||||
this.formatter = formatter;
|
||||
if (formatter == null) {
|
||||
this.formatter = DateFormat.getDateInstance(DateFormat.SHORT);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the date unit. This will be one of the constants
|
||||
* <code>YEAR</code>, <code>MONTH</code>, <code>DAY</code>,
|
||||
* <code>HOUR</code>, <code>MINUTE</code>, <code>SECOND</code> or
|
||||
* <code>MILLISECOND</code>, defined by this class. Note that these
|
||||
* constants do NOT correspond to those defined in Java's
|
||||
* <code>Calendar</code> class.
|
||||
*
|
||||
* @return The date unit.
|
||||
*/
|
||||
public int getUnit() {
|
||||
return this.unit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unit count.
|
||||
*
|
||||
* @return The unit count.
|
||||
*/
|
||||
public int getCount() {
|
||||
return this.count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the roll unit. This is the amount by which the tick advances if
|
||||
* it is "hidden" when displayed on a segmented date axis. Typically the
|
||||
* roll will be smaller than the regular tick unit (for example, a 7 day
|
||||
* tick unit might use a 1 day roll).
|
||||
*
|
||||
* @return The roll unit.
|
||||
*/
|
||||
public int getRollUnit() {
|
||||
return this.rollUnit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the roll count.
|
||||
*
|
||||
* @return The roll count.
|
||||
*/
|
||||
public int getRollCount() {
|
||||
return this.rollCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a value.
|
||||
*
|
||||
* @param milliseconds date in milliseconds since 01-01-1970.
|
||||
*
|
||||
* @return The formatted date.
|
||||
*/
|
||||
public String valueToString(double milliseconds) {
|
||||
return this.formatter.format(new Date((long) milliseconds));
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a date using the tick unit's formatter.
|
||||
*
|
||||
* @param date the date.
|
||||
*
|
||||
* @return The formatted date.
|
||||
*/
|
||||
public String dateToString(Date date) {
|
||||
return this.formatter.format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates a new date by adding this unit to the base date, with
|
||||
* calculations performed in the default timezone and locale.
|
||||
*
|
||||
* @param base the base date.
|
||||
*
|
||||
* @return A new date one unit after the base date.
|
||||
*
|
||||
* @see #addToDate(Date, TimeZone)
|
||||
*
|
||||
* @deprecated As of JFreeChart 1.0.10, this method is deprecated - you
|
||||
* should use {@link #addToDate(Date, TimeZone)} instead.
|
||||
*/
|
||||
public Date addToDate(Date base) {
|
||||
return addToDate(base, TimeZone.getDefault());
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates a new date by adding this unit to the base date.
|
||||
*
|
||||
* @param base the base date.
|
||||
* @param zone the time zone for the date calculation.
|
||||
*
|
||||
* @return A new date one unit after the base date.
|
||||
*
|
||||
* @since 1.0.6
|
||||
*/
|
||||
public Date addToDate(Date base, TimeZone zone) {
|
||||
// as far as I know, the Locale for the calendar only affects week
|
||||
// number calculations, and since DateTickUnit doesn't do week
|
||||
// arithmetic, the default locale (whatever it is) should be fine
|
||||
// here...
|
||||
Calendar calendar = Calendar.getInstance(zone);
|
||||
calendar.setTime(base);
|
||||
calendar.add(getCalendarField(this.unit), this.count);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Rolls the date forward by the amount specified by the roll unit and
|
||||
* count.
|
||||
*
|
||||
* @param base the base date.
|
||||
|
||||
* @return The rolled date.
|
||||
*
|
||||
* @see #rollDate(Date, TimeZone)
|
||||
*/
|
||||
public Date rollDate(Date base) {
|
||||
return rollDate(base, TimeZone.getDefault());
|
||||
}
|
||||
|
||||
/**
|
||||
* Rolls the date forward by the amount specified by the roll unit and
|
||||
* count.
|
||||
*
|
||||
* @param base the base date.
|
||||
* @param zone the time zone.
|
||||
*
|
||||
* @return The rolled date.
|
||||
*
|
||||
* @since 1.0.6
|
||||
*/
|
||||
public Date rollDate(Date base, TimeZone zone) {
|
||||
// as far as I know, the Locale for the calendar only affects week
|
||||
// number calculations, and since DateTickUnit doesn't do week
|
||||
// arithmetic, the default locale (whatever it is) should be fine
|
||||
// here...
|
||||
Calendar calendar = Calendar.getInstance(zone);
|
||||
calendar.setTime(base);
|
||||
calendar.add(getCalendarField(this.rollUnit), this.rollCount);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a field code that can be used with the <code>Calendar</code>
|
||||
* class.
|
||||
*
|
||||
* @return The field code.
|
||||
*/
|
||||
public int getCalendarField() {
|
||||
return getCalendarField(this.unit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a field code (that can be used with the Calendar class) for a
|
||||
* given 'unit' code. The 'unit' is one of: {@link #YEAR}, {@link #MONTH},
|
||||
* {@link #DAY}, {@link #HOUR}, {@link #MINUTE}, {@link #SECOND} and
|
||||
* {@link #MILLISECOND}.
|
||||
*
|
||||
* @param tickUnit the unit.
|
||||
*
|
||||
* @return The field code.
|
||||
*/
|
||||
private int getCalendarField(int tickUnit) {
|
||||
|
||||
switch (tickUnit) {
|
||||
case (YEAR):
|
||||
return Calendar.YEAR;
|
||||
case (MONTH):
|
||||
return Calendar.MONTH;
|
||||
case (DAY):
|
||||
return Calendar.DATE;
|
||||
case (HOUR):
|
||||
return Calendar.HOUR_OF_DAY;
|
||||
case (MINUTE):
|
||||
return Calendar.MINUTE;
|
||||
case (SECOND):
|
||||
return Calendar.SECOND;
|
||||
case (MILLISECOND):
|
||||
return Calendar.MILLISECOND;
|
||||
default:
|
||||
return Calendar.MILLISECOND;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the (approximate) number of milliseconds for the given unit and
|
||||
* unit count.
|
||||
* <P>
|
||||
* This value is an approximation some of the time (e.g. months are
|
||||
* assumed to have 31 days) but this shouldn't matter.
|
||||
*
|
||||
* @param unit the unit.
|
||||
* @param count the unit count.
|
||||
*
|
||||
* @return The number of milliseconds.
|
||||
*/
|
||||
private static long getMillisecondCount(int unit, int count) {
|
||||
|
||||
switch (unit) {
|
||||
case (YEAR):
|
||||
return (365L * 24L * 60L * 60L * 1000L) * count;
|
||||
case (MONTH):
|
||||
return (31L * 24L * 60L * 60L * 1000L) * count;
|
||||
case (DAY):
|
||||
return (24L * 60L * 60L * 1000L) * count;
|
||||
case (HOUR):
|
||||
return (60L * 60L * 1000L) * count;
|
||||
case (MINUTE):
|
||||
return (60L * 1000L) * count;
|
||||
case (SECOND):
|
||||
return 1000L * count;
|
||||
case (MILLISECOND):
|
||||
return count;
|
||||
default:
|
||||
throw new IllegalArgumentException(
|
||||
"DateTickUnit.getMillisecondCount() : unit must "
|
||||
+ "be one of the constants YEAR, MONTH, DAY, HOUR, MINUTE, "
|
||||
+ "SECOND or MILLISECOND defined in the DateTickUnit "
|
||||
+ "class. Do *not* use the constants defined in "
|
||||
+ "java.util.Calendar."
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this unit for equality with another object.
|
||||
*
|
||||
* @param obj the object (<code>null</code> permitted).
|
||||
*
|
||||
* @return <code>true</code> or <code>false</code>.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof DateTickUnit)) {
|
||||
return false;
|
||||
}
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
DateTickUnit that = (DateTickUnit) obj;
|
||||
if (this.unit != that.unit) {
|
||||
return false;
|
||||
}
|
||||
if (this.count != that.count) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtilities.equal(this.formatter, that.formatter)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for this object.
|
||||
*
|
||||
* @return A hash code.
|
||||
*/
|
||||
public int hashCode() {
|
||||
int result = 19;
|
||||
result = 37 * result + this.unit;
|
||||
result = 37 * result + this.count;
|
||||
result = 37 * result + this.formatter.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Strings for use by the toString() method.
|
||||
*/
|
||||
private static final String[] units = {"YEAR", "MONTH", "DAY", "HOUR",
|
||||
"MINUTE", "SECOND", "MILLISECOND"};
|
||||
|
||||
/**
|
||||
* Returns a string representation of this instance, primarily used for
|
||||
* debugging purposes.
|
||||
*
|
||||
* @return A string representation of this instance.
|
||||
*/
|
||||
public String toString() {
|
||||
return "DateTickUnit[" + DateTickUnit.units[this.unit] + ", "
|
||||
+ this.count + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,258 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* -------------------------
|
||||
* ExtendedCategoryAxis.java
|
||||
* -------------------------
|
||||
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): -;
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 07-Nov-2003 : Version 1 (DG);
|
||||
* 07-Jan-2004 : Updated the createLabel() method (DG);
|
||||
* 29-Jan-2004 : Added paint attribute (DG);
|
||||
* ------------- JFREECHART 1.0.x ---------------------------------------------
|
||||
* 21-Mar-2007 : Implemented equals(), clone() and fixed serialization (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.axis;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Paint;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jfree.chart.event.AxisChangeEvent;
|
||||
import org.jfree.io.SerialUtilities;
|
||||
import org.jfree.text.TextBlock;
|
||||
import org.jfree.text.TextFragment;
|
||||
import org.jfree.text.TextLine;
|
||||
import org.jfree.ui.RectangleEdge;
|
||||
import org.jfree.util.PaintUtilities;
|
||||
|
||||
/**
|
||||
* An extended version of the {@link CategoryAxis} class that supports
|
||||
* sublabels on the axis.
|
||||
*/
|
||||
public class ExtendedCategoryAxis extends CategoryAxis {
|
||||
|
||||
/** For serialization. */
|
||||
static final long serialVersionUID = -3004429093959826567L;
|
||||
|
||||
/** Storage for the sublabels. */
|
||||
private Map sublabels;
|
||||
|
||||
/** The sublabel font. */
|
||||
private Font sublabelFont;
|
||||
|
||||
/** The sublabel paint. */
|
||||
private transient Paint sublabelPaint;
|
||||
|
||||
/**
|
||||
* Creates a new axis.
|
||||
*
|
||||
* @param label the axis label.
|
||||
*/
|
||||
public ExtendedCategoryAxis(String label) {
|
||||
super(label);
|
||||
this.sublabels = new HashMap();
|
||||
this.sublabelFont = new Font("SansSerif", Font.PLAIN, 10);
|
||||
this.sublabelPaint = Color.black;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the font for the sublabels.
|
||||
*
|
||||
* @return The font (never <code>null</code>).
|
||||
*
|
||||
* @see #setSubLabelFont(Font)
|
||||
*/
|
||||
public Font getSubLabelFont() {
|
||||
return this.sublabelFont;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the font for the sublabels and sends an {@link AxisChangeEvent} to
|
||||
* all registered listeners.
|
||||
*
|
||||
* @param font the font (<code>null</code> not permitted).
|
||||
*
|
||||
* @see #getSubLabelFont()
|
||||
*/
|
||||
public void setSubLabelFont(Font font) {
|
||||
if (font == null) {
|
||||
throw new IllegalArgumentException("Null 'font' argument.");
|
||||
}
|
||||
this.sublabelFont = font;
|
||||
notifyListeners(new AxisChangeEvent(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the paint for the sublabels.
|
||||
*
|
||||
* @return The paint (never <code>null</code>).
|
||||
*
|
||||
* @see #setSubLabelPaint(Paint)
|
||||
*/
|
||||
public Paint getSubLabelPaint() {
|
||||
return this.sublabelPaint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the paint for the sublabels and sends an {@link AxisChangeEvent}
|
||||
* to all registered listeners.
|
||||
*
|
||||
* @param paint the paint (<code>null</code> not permitted).
|
||||
*
|
||||
* @see #getSubLabelPaint()
|
||||
*/
|
||||
public void setSubLabelPaint(Paint paint) {
|
||||
if (paint == null) {
|
||||
throw new IllegalArgumentException("Null 'paint' argument.");
|
||||
}
|
||||
this.sublabelPaint = paint;
|
||||
notifyListeners(new AxisChangeEvent(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a sublabel for a category.
|
||||
*
|
||||
* @param category the category.
|
||||
* @param label the label.
|
||||
*/
|
||||
public void addSubLabel(Comparable category, String label) {
|
||||
this.sublabels.put(category, label);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the default behaviour by adding the sublabel to the text
|
||||
* block that is used for the category label.
|
||||
*
|
||||
* @param category the category.
|
||||
* @param width the width (not used yet).
|
||||
* @param edge the location of the axis.
|
||||
* @param g2 the graphics device.
|
||||
*
|
||||
* @return A label.
|
||||
*/
|
||||
protected TextBlock createLabel(Comparable category, float width,
|
||||
RectangleEdge edge, Graphics2D g2) {
|
||||
TextBlock label = super.createLabel(category, width, edge, g2);
|
||||
String s = (String) this.sublabels.get(category);
|
||||
if (s != null) {
|
||||
if (edge == RectangleEdge.TOP || edge == RectangleEdge.BOTTOM) {
|
||||
TextLine line = new TextLine(s, this.sublabelFont,
|
||||
this.sublabelPaint);
|
||||
label.addLine(line);
|
||||
}
|
||||
else if (edge == RectangleEdge.LEFT
|
||||
|| edge == RectangleEdge.RIGHT) {
|
||||
TextLine line = label.getLastLine();
|
||||
if (line != null) {
|
||||
line.addFragment(new TextFragment(" " + s,
|
||||
this.sublabelFont, this.sublabelPaint));
|
||||
}
|
||||
}
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this axis for equality with an arbitrary object.
|
||||
*
|
||||
* @param obj the object (<code>null</code> permitted).
|
||||
*
|
||||
* @return A boolean.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof ExtendedCategoryAxis)) {
|
||||
return false;
|
||||
}
|
||||
ExtendedCategoryAxis that = (ExtendedCategoryAxis) obj;
|
||||
if (!this.sublabelFont.equals(that.sublabelFont)) {
|
||||
return false;
|
||||
}
|
||||
if (!PaintUtilities.equal(this.sublabelPaint, that.sublabelPaint)) {
|
||||
return false;
|
||||
}
|
||||
if (!this.sublabels.equals(that.sublabels)) {
|
||||
return false;
|
||||
}
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone of this axis.
|
||||
*
|
||||
* @return A clone.
|
||||
*
|
||||
* @throws CloneNotSupportedException if there is a problem cloning.
|
||||
*/
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
ExtendedCategoryAxis clone = (ExtendedCategoryAxis) super.clone();
|
||||
clone.sublabels = new HashMap(this.sublabels);
|
||||
return clone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the output stream.
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
*/
|
||||
private void writeObject(ObjectOutputStream stream) throws IOException {
|
||||
stream.defaultWriteObject();
|
||||
SerialUtilities.writePaint(this.sublabelPaint, stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides serialization support.
|
||||
*
|
||||
* @param stream the input stream.
|
||||
*
|
||||
* @throws IOException if there is an I/O error.
|
||||
* @throws ClassNotFoundException if there is a classpath problem.
|
||||
*/
|
||||
private void readObject(ObjectInputStream stream)
|
||||
throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
this.sublabelPaint = SerialUtilities.readPaint(stream);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,920 +0,0 @@
|
||||
/* ===========================================================
|
||||
* JFreeChart : a free chart library for the Java(tm) platform
|
||||
* ===========================================================
|
||||
*
|
||||
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Project Info: http://www.jfree.org/jfreechart/index.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* ------------
|
||||
* LogAxis.java
|
||||
* ------------
|
||||
* (C) Copyright 2006-2015, by Object Refinery Limited and Contributors.
|
||||
*
|
||||
* Original Author: David Gilbert (for Object Refinery Limited);
|
||||
* Contributor(s): Andrew Mickish (patch 1868745);
|
||||
* Peter Kolb (patch 1934255);
|
||||
*
|
||||
* Changes
|
||||
* -------
|
||||
* 24-Aug-2006 : Version 1 (DG);
|
||||
* 22-Mar-2007 : Use defaultAutoArrange attribute (DG);
|
||||
* 02-Aug-2007 : Fixed zooming bug, added support for margins (DG);
|
||||
* 14-Feb-2008 : Changed default minorTickCount to 9 - see bug report
|
||||
* 1892419 (DG);
|
||||
* 15-Feb-2008 : Applied a variation of patch 1868745 by Andrew Mickish to
|
||||
* fix a labelling bug when the axis appears at the top or
|
||||
* right of the chart (DG);
|
||||
* 19-Mar-2008 : Applied patch 1902418 by Andrew Mickish to fix bug in tick
|
||||
* labels for vertical axis (DG);
|
||||
* 26-Mar-2008 : Changed createTickLabel() method from private to protected -
|
||||
* see patch 1918209 by Andrew Mickish (DG);
|
||||
* 25-Sep-2008 : Moved minor tick fields up to superclass, see patch 1934255
|
||||
* by Peter Kolb (DG);
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jfree.chart.axis;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.font.FontRenderContext;
|
||||
import java.awt.font.LineMetrics;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.jfree.chart.event.AxisChangeEvent;
|
||||
import org.jfree.chart.plot.Plot;
|
||||
import org.jfree.chart.plot.PlotRenderingInfo;
|
||||
import org.jfree.chart.plot.ValueAxisPlot;
|
||||
import org.jfree.data.Range;
|
||||
import org.jfree.ui.RectangleEdge;
|
||||
import org.jfree.ui.RectangleInsets;
|
||||
import org.jfree.ui.TextAnchor;
|
||||
|
||||
/**
|
||||
* A numerical axis that uses a logarithmic scale. The class is an
|
||||
* alternative to the {@link LogarithmicAxis} class.
|
||||
*
|
||||
* @since 1.0.7
|
||||
*/
|
||||
public class LogAxis extends ValueAxis {
|
||||
|
||||
/** The logarithm base. */
|
||||
private double base = 10.0;
|
||||
|
||||
/** The logarithm of the base value - cached for performance. */
|
||||
private double baseLog = Math.log(10.0);
|
||||
|
||||
/** The smallest value permitted on the axis. */
|
||||
private double smallestValue = 1E-100;
|
||||
|
||||
/** The current tick unit. */
|
||||
private NumberTickUnit tickUnit;
|
||||
|
||||
/** The override number format. */
|
||||
private NumberFormat numberFormatOverride;
|
||||
|
||||
/**
|
||||
* Creates a new <code>LogAxis</code> with no label.
|
||||
*/
|
||||
public LogAxis() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new <code>LogAxis</code> with the given label.
|
||||
*
|
||||
* @param label the axis label (<code>null</code> permitted).
|
||||
*/
|
||||
public LogAxis(String label) {
|
||||
super(label, createLogTickUnits(Locale.getDefault()));
|
||||
setDefaultAutoRange(new Range(0.01, 1.0));
|
||||
this.tickUnit = new NumberTickUnit(1.0, new DecimalFormat("0.#"));
|
||||
setMinorTickCount(9);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the base for the logarithm calculation.
|
||||
*
|
||||
* @return The base for the logarithm calculation.
|
||||
*
|
||||
* @see #setBase(double)
|
||||
*/
|
||||
public double getBase() {
|
||||
return this.base;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the base for the logarithm calculation and sends an
|
||||
* {@link AxisChangeEvent} to all registered listeners.
|
||||
*
|
||||
* @param base the base value (must be > 1.0).
|
||||
*
|
||||
* @see #getBase()
|
||||
*/
|
||||
public void setBase(double base) {
|
||||
if (base <= 1.0) {
|
||||
throw new IllegalArgumentException("Requires 'base' > 1.0.");
|
||||
}
|
||||
this.base = base;
|
||||
this.baseLog = Math.log(base);
|
||||
notifyListeners(new AxisChangeEvent(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smallest value represented by the axis.
|
||||
*
|
||||
* @return The smallest value represented by the axis.
|
||||
*
|
||||
* @see #setSmallestValue(double)
|
||||
*/
|
||||
public double getSmallestValue() {
|
||||
return this.smallestValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the smallest value represented by the axis and sends an
|
||||
* {@link AxisChangeEvent} to all registered listeners.
|
||||
*
|
||||
* @param value the value.
|
||||
*
|
||||
* @see #getSmallestValue()
|
||||
*/
|
||||
public void setSmallestValue(double value) {
|
||||
if (value <= 0.0) {
|
||||
throw new IllegalArgumentException("Requires 'value' > 0.0.");
|
||||
}
|
||||
this.smallestValue = value;
|
||||
notifyListeners(new AxisChangeEvent(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current tick unit.
|
||||
*
|
||||
* @return The current tick unit.
|
||||
*
|
||||
* @see #setTickUnit(NumberTickUnit)
|
||||
*/
|
||||
public NumberTickUnit getTickUnit() {
|
||||
return this.tickUnit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the tick unit for the axis and sends an {@link AxisChangeEvent} to
|
||||
* all registered listeners. A side effect of calling this method is that
|
||||
* the "auto-select" feature for tick units is switched off (you can
|
||||
* restore it using the {@link ValueAxis#setAutoTickUnitSelection(boolean)}
|
||||
* method).
|
||||
*
|
||||
* @param unit the new tick unit (<code>null</code> not permitted).
|
||||
*
|
||||
* @see #getTickUnit()
|
||||
*/
|
||||
public void setTickUnit(NumberTickUnit unit) {
|
||||
// defer argument checking...
|
||||
setTickUnit(unit, true, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the tick unit for the axis and, if requested, sends an
|
||||
* {@link AxisChangeEvent} to all registered listeners. In addition, an
|
||||
* option is provided to turn off the "auto-select" feature for tick units
|
||||
* (you can restore it using the
|
||||
* {@link ValueAxis#setAutoTickUnitSelection(boolean)} method).
|
||||
*
|
||||
* @param unit the new tick unit (<code>null</code> not permitted).
|
||||
* @param notify notify listeners?
|
||||
* @param turnOffAutoSelect turn off the auto-tick selection?
|
||||
*
|
||||
* @see #getTickUnit()
|
||||
*/
|
||||
public void setTickUnit(NumberTickUnit unit, boolean notify,
|
||||
boolean turnOffAutoSelect) {
|
||||
|
||||
if (unit == null) {
|
||||
throw new IllegalArgumentException("Null 'unit' argument.");
|
||||
}
|
||||
this.tickUnit = unit;
|
||||
if (turnOffAutoSelect) {
|
||||
setAutoTickUnitSelection(false, false);
|
||||
}
|
||||
if (notify) {
|
||||
notifyListeners(new AxisChangeEvent(this));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number format override. If this is non-null, then it will
|
||||
* be used to format the numbers on the axis.
|
||||
*
|
||||
* @return The number formatter (possibly <code>null</code>).
|
||||
*
|
||||
* @see #setNumberFormatOverride(NumberFormat)
|
||||
*/
|
||||
public NumberFormat getNumberFormatOverride() {
|
||||
return this.numberFormatOverride;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the number format override. If this is non-null, then it will be
|
||||
* used to format the numbers on the axis.
|
||||
*
|
||||
* @param formatter the number formatter (<code>null</code> permitted).
|
||||
*
|
||||
* @see #getNumberFormatOverride()
|
||||
*/
|
||||
public void setNumberFormatOverride(NumberFormat formatter) {
|
||||
this.numberFormatOverride = formatter;
|
||||
notifyListeners(new AxisChangeEvent(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the log of the given value, using the current base.
|
||||
*
|
||||
* @param value the value.
|
||||
*
|
||||
* @return The log of the given value.
|
||||
*
|
||||
* @see #calculateValue(double)
|
||||
* @see #getBase()
|
||||
*/
|
||||
public double calculateLog(double value) {
|
||||
return Math.log(value) / this.baseLog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the value from a given log.
|
||||
*
|
||||
* @param log the log value (must be > 0.0).
|
||||
*
|
||||
* @return The value with the given log.
|
||||
*
|
||||
* @see #calculateLog(double)
|
||||
* @see #getBase()
|
||||
*/
|
||||
public double calculateValue(double log) {
|
||||
return Math.pow(this.base, log);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a Java2D coordinate to an axis value, assuming that the
|
||||
* axis covers the specified <code>edge</code> of the <code>area</code>.
|
||||
*
|
||||
* @param java2DValue the Java2D coordinate.
|
||||
* @param area the area.
|
||||
* @param edge the edge that the axis belongs to.
|
||||
*
|
||||
* @return A value along the axis scale.
|
||||
*/
|
||||
public double java2DToValue(double java2DValue, Rectangle2D area,
|
||||
RectangleEdge edge) {
|
||||
|
||||
Range range = getRange();
|
||||
double axisMin = calculateLog(range.getLowerBound());
|
||||
double axisMax = calculateLog(range.getUpperBound());
|
||||
|
||||
double min = 0.0;
|
||||
double max = 0.0;
|
||||
if (RectangleEdge.isTopOrBottom(edge)) {
|
||||
min = area.getX();
|
||||
max = area.getMaxX();
|
||||
}
|
||||
else if (RectangleEdge.isLeftOrRight(edge)) {
|
||||
min = area.getMaxY();
|
||||
max = area.getY();
|
||||
}
|
||||
double log = 0.0;
|
||||
if (isInverted()) {
|
||||
log = axisMax - (java2DValue - min) / (max - min)
|
||||
* (axisMax - axisMin);
|
||||
}
|
||||
else {
|
||||
log = axisMin + (java2DValue - min) / (max - min)
|
||||
* (axisMax - axisMin);
|
||||
}
|
||||
return calculateValue(log);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a value on the axis scale to a Java2D coordinate relative to
|
||||
* the given <code>area</code>, based on the axis running along the
|
||||
* specified <code>edge</code>.
|
||||
*
|
||||
* @param value the data value.
|
||||
* @param area the area.
|
||||
* @param edge the edge.
|
||||
*
|
||||
* @return The Java2D coordinate corresponding to <code>value</code>.
|
||||
*/
|
||||
public double valueToJava2D(double value, Rectangle2D area,
|
||||
RectangleEdge edge) {
|
||||
|
||||
Range range = getRange();
|
||||
double axisMin = calculateLog(range.getLowerBound());
|
||||
double axisMax = calculateLog(range.getUpperBound());
|
||||
value = calculateLog(value);
|
||||
|
||||
double min = 0.0;
|
||||
double max = 0.0;
|
||||
if (RectangleEdge.isTopOrBottom(edge)) {
|
||||
min = area.getX();
|
||||
max = area.getMaxX();
|
||||
}
|
||||
else if (RectangleEdge.isLeftOrRight(edge)) {
|
||||
max = area.getMinY();
|
||||
min = area.getMaxY();
|
||||
}
|
||||
if (isInverted()) {
|
||||
return max
|
||||
- ((value - axisMin) / (axisMax - axisMin)) * (max - min);
|
||||
}
|
||||
else {
|
||||
return min
|
||||
+ ((value - axisMin) / (axisMax - axisMin)) * (max - min);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the axis. This method is typically called when an axis
|
||||
* is assigned to a new plot.
|
||||
*/
|
||||
public void configure() {
|
||||
if (isAutoRange()) {
|
||||
autoAdjustRange();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts the axis range to match the data range that the axis is
|
||||
* required to display.
|
||||
*/
|
||||
protected void autoAdjustRange() {
|
||||
Plot plot = getPlot();
|
||||
if (plot == null) {
|
||||
return; // no plot, no data
|
||||
}
|
||||
|
||||
if (plot instanceof ValueAxisPlot) {
|
||||
ValueAxisPlot vap = (ValueAxisPlot) plot;
|
||||
|
||||
Range r = vap.getDataRange(this);
|
||||
if (r == null) {
|
||||
r = getDefaultAutoRange();
|
||||
}
|
||||
|
||||
double upper = r.getUpperBound();
|
||||
double lower = Math.max(r.getLowerBound(), this.smallestValue);
|
||||
double range = upper - lower;
|
||||
|
||||
// if fixed auto range, then derive lower bound...
|
||||
double fixedAutoRange = getFixedAutoRange();
|
||||
if (fixedAutoRange > 0.0) {
|
||||
lower = Math.max(upper - fixedAutoRange, this.smallestValue);
|
||||
}
|
||||
else {
|
||||
// ensure the autorange is at least <minRange> in size...
|
||||
double minRange = getAutoRangeMinimumSize();
|
||||
if (range < minRange) {
|
||||
double expand = (minRange - range) / 2;
|
||||
upper = upper + expand;
|
||||
lower = lower - expand;
|
||||
}
|
||||
|
||||
// apply the margins - these should apply to the exponent range
|
||||
double logUpper = calculateLog(upper);
|
||||
double logLower = calculateLog(lower);
|
||||
double logRange = logUpper - logLower;
|
||||
logUpper = logUpper + getUpperMargin() * logRange;
|
||||
logLower = logLower - getLowerMargin() * logRange;
|
||||
upper = calculateValue(logUpper);
|
||||
lower = calculateValue(logLower);
|
||||
}
|
||||
|
||||
setRange(new Range(lower, upper), false, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the axis on a Java 2D graphics device (such as the screen or a
|
||||
* printer).
|
||||
*
|
||||
* @param g2 the graphics device (<code>null</code> not permitted).
|
||||
* @param cursor the cursor location (determines where to draw the axis).
|
||||
* @param plotArea the area within which the axes and plot should be drawn.
|
||||
* @param dataArea the area within which the data should be drawn.
|
||||
* @param edge the axis location (<code>null</code> not permitted).
|
||||
* @param plotState collects information about the plot
|
||||
* (<code>null</code> permitted).
|
||||
*
|
||||
* @return The axis state (never <code>null</code>).
|
||||
*/
|
||||
public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea,
|
||||
Rectangle2D dataArea, RectangleEdge edge,
|
||||
PlotRenderingInfo plotState) {
|
||||
|
||||
AxisState state = null;
|
||||
// if the axis is not visible, don't draw it...
|
||||
if (!isVisible()) {
|
||||
state = new AxisState(cursor);
|
||||
// even though the axis is not visible, we need ticks for the
|
||||
// gridlines...
|
||||
List ticks = refreshTicks(g2, state, dataArea, edge);
|
||||
state.setTicks(ticks);
|
||||
return state;
|
||||
}
|
||||
state = drawTickMarksAndLabels(g2, cursor, plotArea, dataArea, edge);
|
||||
state = drawLabel(getLabel(), g2, plotArea, dataArea, edge, state);
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the positions of the tick labels for the axis, storing the
|
||||
* results in the tick label list (ready for drawing).
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
* @param state the axis state.
|
||||
* @param dataArea the area in which the plot should be drawn.
|
||||
* @param edge the location of the axis.
|
||||
*
|
||||
* @return A list of ticks.
|
||||
*
|
||||
*/
|
||||
public List refreshTicks(Graphics2D g2, AxisState state,
|
||||
Rectangle2D dataArea, RectangleEdge edge) {
|
||||
|
||||
List result = new java.util.ArrayList();
|
||||
if (RectangleEdge.isTopOrBottom(edge)) {
|
||||
result = refreshTicksHorizontal(g2, dataArea, edge);
|
||||
}
|
||||
else if (RectangleEdge.isLeftOrRight(edge)) {
|
||||
result = refreshTicksVertical(g2, dataArea, edge);
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of ticks for an axis at the top or bottom of the chart.
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
* @param dataArea the data area.
|
||||
* @param edge the edge.
|
||||
*
|
||||
* @return A list of ticks.
|
||||
*/
|
||||
protected List refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea,
|
||||
RectangleEdge edge) {
|
||||
|
||||
Range range = getRange();
|
||||
List ticks = new ArrayList();
|
||||
Font tickLabelFont = getTickLabelFont();
|
||||
g2.setFont(tickLabelFont);
|
||||
TextAnchor textAnchor;
|
||||
if (edge == RectangleEdge.TOP) {
|
||||
textAnchor = TextAnchor.BOTTOM_CENTER;
|
||||
}
|
||||
else {
|
||||
textAnchor = TextAnchor.TOP_CENTER;
|
||||
}
|
||||
|
||||
if (isAutoTickUnitSelection()) {
|
||||
selectAutoTickUnit(g2, dataArea, edge);
|
||||
}
|
||||
double start = Math.floor(calculateLog(getLowerBound()));
|
||||
double end = Math.ceil(calculateLog(getUpperBound()));
|
||||
double current = start;
|
||||
while (current <= end) {
|
||||
double v = calculateValue(current);
|
||||
if (range.contains(v)) {
|
||||
ticks.add(new NumberTick(TickType.MAJOR, v, createTickLabel(v),
|
||||
textAnchor, TextAnchor.CENTER, 0.0));
|
||||
}
|
||||
// add minor ticks (for gridlines)
|
||||
double next = Math.pow(this.base, current
|
||||
+ this.tickUnit.getSize());
|
||||
for (int i = 1; i < getMinorTickCount(); i++) {
|
||||
double minorV = v + i * ((next - v) / getMinorTickCount());
|
||||
if (range.contains(minorV)) {
|
||||
ticks.add(new NumberTick(TickType.MINOR, minorV, "",
|
||||
textAnchor, TextAnchor.CENTER, 0.0));
|
||||
}
|
||||
}
|
||||
current = current + this.tickUnit.getSize();
|
||||
}
|
||||
return ticks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of ticks for an axis at the left or right of the chart.
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
* @param dataArea the data area.
|
||||
* @param edge the edge.
|
||||
*
|
||||
* @return A list of ticks.
|
||||
*/
|
||||
protected List refreshTicksVertical(Graphics2D g2, Rectangle2D dataArea,
|
||||
RectangleEdge edge) {
|
||||
|
||||
Range range = getRange();
|
||||
List ticks = new ArrayList();
|
||||
Font tickLabelFont = getTickLabelFont();
|
||||
g2.setFont(tickLabelFont);
|
||||
TextAnchor textAnchor;
|
||||
if (edge == RectangleEdge.RIGHT) {
|
||||
textAnchor = TextAnchor.CENTER_LEFT;
|
||||
}
|
||||
else {
|
||||
textAnchor = TextAnchor.CENTER_RIGHT;
|
||||
}
|
||||
|
||||
if (isAutoTickUnitSelection()) {
|
||||
selectAutoTickUnit(g2, dataArea, edge);
|
||||
}
|
||||
double start = Math.floor(calculateLog(getLowerBound()));
|
||||
double end = Math.ceil(calculateLog(getUpperBound()));
|
||||
double current = start;
|
||||
while (current <= end) {
|
||||
double v = calculateValue(current);
|
||||
if (range.contains(v)) {
|
||||
ticks.add(new NumberTick(TickType.MAJOR, v, createTickLabel(v),
|
||||
textAnchor, TextAnchor.CENTER, 0.0));
|
||||
}
|
||||
// add minor ticks (for gridlines)
|
||||
double next = Math.pow(this.base, current
|
||||
+ this.tickUnit.getSize());
|
||||
for (int i = 1; i < getMinorTickCount(); i++) {
|
||||
double minorV = v + i * ((next - v) / getMinorTickCount());
|
||||
if (range.contains(minorV)) {
|
||||
ticks.add(new NumberTick(TickType.MINOR, minorV, "",
|
||||
textAnchor, TextAnchor.CENTER, 0.0));
|
||||
}
|
||||
}
|
||||
current = current + this.tickUnit.getSize();
|
||||
}
|
||||
return ticks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects an appropriate tick value for the axis. The strategy is to
|
||||
* display as many ticks as possible (selected from an array of 'standard'
|
||||
* tick units) without the labels overlapping.
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
* @param dataArea the area defined by the axes.
|
||||
* @param edge the axis location.
|
||||
*
|
||||
* @since 1.0.7
|
||||
*/
|
||||
protected void selectAutoTickUnit(Graphics2D g2, Rectangle2D dataArea,
|
||||
RectangleEdge edge) {
|
||||
|
||||
if (RectangleEdge.isTopOrBottom(edge)) {
|
||||
selectHorizontalAutoTickUnit(g2, dataArea, edge);
|
||||
}
|
||||
else if (RectangleEdge.isLeftOrRight(edge)) {
|
||||
selectVerticalAutoTickUnit(g2, dataArea, edge);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects an appropriate tick value for the axis. The strategy is to
|
||||
* display as many ticks as possible (selected from an array of 'standard'
|
||||
* tick units) without the labels overlapping.
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
* @param dataArea the area defined by the axes.
|
||||
* @param edge the axis location.
|
||||
*
|
||||
* @since 1.0.7
|
||||
*/
|
||||
protected void selectHorizontalAutoTickUnit(Graphics2D g2,
|
||||
Rectangle2D dataArea, RectangleEdge edge) {
|
||||
|
||||
double tickLabelWidth = estimateMaximumTickLabelWidth(g2,
|
||||
getTickUnit());
|
||||
|
||||
// start with the current tick unit...
|
||||
TickUnitSource tickUnits = getStandardTickUnits();
|
||||
TickUnit unit1 = tickUnits.getCeilingTickUnit(getTickUnit());
|
||||
double unit1Width = exponentLengthToJava2D(unit1.getSize(), dataArea,
|
||||
edge);
|
||||
|
||||
// then extrapolate...
|
||||
double guess = (tickLabelWidth / unit1Width) * unit1.getSize();
|
||||
|
||||
NumberTickUnit unit2 = (NumberTickUnit)
|
||||
tickUnits.getCeilingTickUnit(guess);
|
||||
double unit2Width = exponentLengthToJava2D(unit2.getSize(), dataArea,
|
||||
edge);
|
||||
|
||||
tickLabelWidth = estimateMaximumTickLabelWidth(g2, unit2);
|
||||
if (tickLabelWidth > unit2Width) {
|
||||
unit2 = (NumberTickUnit) tickUnits.getLargerTickUnit(unit2);
|
||||
}
|
||||
|
||||
setTickUnit(unit2, false, false);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a length in data coordinates into the corresponding length in
|
||||
* Java2D coordinates.
|
||||
*
|
||||
* @param length the length.
|
||||
* @param area the plot area.
|
||||
* @param edge the edge along which the axis lies.
|
||||
*
|
||||
* @return The length in Java2D coordinates.
|
||||
*
|
||||
* @since 1.0.7
|
||||
*/
|
||||
public double exponentLengthToJava2D(double length, Rectangle2D area,
|
||||
RectangleEdge edge) {
|
||||
double one = valueToJava2D(calculateValue(1.0), area, edge);
|
||||
double l = valueToJava2D(calculateValue(length + 1.0), area, edge);
|
||||
return Math.abs(l - one);
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects an appropriate tick value for the axis. The strategy is to
|
||||
* display as many ticks as possible (selected from an array of 'standard'
|
||||
* tick units) without the labels overlapping.
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
* @param dataArea the area in which the plot should be drawn.
|
||||
* @param edge the axis location.
|
||||
*
|
||||
* @since 1.0.7
|
||||
*/
|
||||
protected void selectVerticalAutoTickUnit(Graphics2D g2,
|
||||
Rectangle2D dataArea,
|
||||
RectangleEdge edge) {
|
||||
|
||||
double tickLabelHeight = estimateMaximumTickLabelHeight(g2);
|
||||
|
||||
// start with the current tick unit...
|
||||
TickUnitSource tickUnits = getStandardTickUnits();
|
||||
TickUnit unit1 = tickUnits.getCeilingTickUnit(getTickUnit());
|
||||
double unitHeight = exponentLengthToJava2D(unit1.getSize(), dataArea,
|
||||
edge);
|
||||
|
||||
// then extrapolate...
|
||||
double guess = (tickLabelHeight / unitHeight) * unit1.getSize();
|
||||
|
||||
NumberTickUnit unit2 = (NumberTickUnit)
|
||||
tickUnits.getCeilingTickUnit(guess);
|
||||
double unit2Height = exponentLengthToJava2D(unit2.getSize(), dataArea,
|
||||
edge);
|
||||
|
||||
tickLabelHeight = estimateMaximumTickLabelHeight(g2);
|
||||
if (tickLabelHeight > unit2Height) {
|
||||
unit2 = (NumberTickUnit) tickUnits.getLargerTickUnit(unit2);
|
||||
}
|
||||
|
||||
setTickUnit(unit2, false, false);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Estimates the maximum tick label height.
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
*
|
||||
* @return The maximum height.
|
||||
*
|
||||
* @since 1.0.7
|
||||
*/
|
||||
protected double estimateMaximumTickLabelHeight(Graphics2D g2) {
|
||||
|
||||
RectangleInsets tickLabelInsets = getTickLabelInsets();
|
||||
double result = tickLabelInsets.getTop() + tickLabelInsets.getBottom();
|
||||
|
||||
Font tickLabelFont = getTickLabelFont();
|
||||
FontRenderContext frc = g2.getFontRenderContext();
|
||||
result += tickLabelFont.getLineMetrics("123", frc).getHeight();
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Estimates the maximum width of the tick labels, assuming the specified
|
||||
* tick unit is used.
|
||||
* <P>
|
||||
* Rather than computing the string bounds of every tick on the axis, we
|
||||
* just look at two values: the lower bound and the upper bound for the
|
||||
* axis. These two values will usually be representative.
|
||||
*
|
||||
* @param g2 the graphics device.
|
||||
* @param unit the tick unit to use for calculation.
|
||||
*
|
||||
* @return The estimated maximum width of the tick labels.
|
||||
*
|
||||
* @since 1.0.7
|
||||
*/
|
||||
protected double estimateMaximumTickLabelWidth(Graphics2D g2,
|
||||
TickUnit unit) {
|
||||
|
||||
RectangleInsets tickLabelInsets = getTickLabelInsets();
|
||||
double result = tickLabelInsets.getLeft() + tickLabelInsets.getRight();
|
||||
|
||||
if (isVerticalTickLabels()) {
|
||||
// all tick labels have the same width (equal to the height of the
|
||||
// font)...
|
||||
FontRenderContext frc = g2.getFontRenderContext();
|
||||
LineMetrics lm = getTickLabelFont().getLineMetrics("0", frc);
|
||||
result += lm.getHeight();
|
||||
}
|
||||
else {
|
||||
// look at lower and upper bounds...
|
||||
FontMetrics fm = g2.getFontMetrics(getTickLabelFont());
|
||||
Range range = getRange();
|
||||
double lower = range.getLowerBound();
|
||||
double upper = range.getUpperBound();
|
||||
String lowerStr = "";
|
||||
String upperStr = "";
|
||||
NumberFormat formatter = getNumberFormatOverride();
|
||||
if (formatter != null) {
|
||||
lowerStr = formatter.format(lower);
|
||||
upperStr = formatter.format(upper);
|
||||
}
|
||||
else {
|
||||
lowerStr = unit.valueToString(lower);
|
||||
upperStr = unit.valueToString(upper);
|
||||
}
|
||||
double w1 = fm.stringWidth(lowerStr);
|
||||
double w2 = fm.stringWidth(upperStr);
|
||||
result += Math.max(w1, w2);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Zooms in on the current range.
|
||||
*
|
||||
* @param lowerPercent the new lower bound.
|
||||
* @param upperPercent the new upper bound.
|
||||
*/
|
||||
public void zoomRange(double lowerPercent, double upperPercent) {
|
||||
Range range = getRange();
|
||||
double start = range.getLowerBound();
|
||||
double end = range.getUpperBound();
|
||||
double log1 = calculateLog(start);
|
||||
double log2 = calculateLog(end);
|
||||
double length = log2 - log1;
|
||||
Range adjusted = null;
|
||||
if (isInverted()) {
|
||||
double logA = log1 + length * (1 - upperPercent);
|
||||
double logB = log1 + length * (1 - lowerPercent);
|
||||
adjusted = new Range(calculateValue(logA), calculateValue(logB));
|
||||
}
|
||||
else {
|
||||
double logA = log1 + length * lowerPercent;
|
||||
double logB = log1 + length * upperPercent;
|
||||
adjusted = new Range(calculateValue(logA), calculateValue(logB));
|
||||
}
|
||||
setRange(adjusted);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a tick label for the specified value. Note that this method
|
||||
* was 'private' prior to version 1.0.10.
|
||||
*
|
||||
* @param value the value.
|
||||
*
|
||||
* @return The label.
|
||||
*
|
||||
* @since 1.0.10
|
||||
*/
|
||||
protected String createTickLabel(double value) {
|
||||
if (this.numberFormatOverride != null) {
|
||||
return this.numberFormatOverride.format(value);
|
||||
}
|
||||
else {
|
||||
return this.tickUnit.valueToString(value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this axis for equality with an arbitrary object.
|
||||
*
|
||||
* @param obj the object (<code>null</code> permitted).
|
||||
*
|
||||
* @return A boolean.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof LogAxis)) {
|
||||
return false;
|
||||
}
|
||||
LogAxis that = (LogAxis) obj;
|
||||
if (this.base != that.base) {
|
||||
return false;
|
||||
}
|
||||
if (this.smallestValue != that.smallestValue) {
|
||||
return false;
|
||||
}
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for this instance.
|
||||
*
|
||||
* @return A hash code.
|
||||
*/
|
||||
public int hashCode() {
|
||||
int result = 193;
|
||||
long temp = Double.doubleToLongBits(this.base);
|
||||
result = 37 * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(this.smallestValue);
|
||||
result = 37 * result + (int) (temp ^ (temp >>> 32));
|
||||
if (this.numberFormatOverride != null) {
|
||||
result = 37 * result + this.numberFormatOverride.hashCode();
|
||||
}
|
||||
result = 37 * result + this.tickUnit.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a collection of tick units for log (base 10) values.
|
||||
* Uses a given Locale to create the DecimalFormats.
|
||||
*
|
||||
* @param locale the locale to use to represent Numbers.
|
||||
*
|
||||
* @return A collection of tick units for integer values.
|
||||
*
|
||||
* @since 1.0.7
|
||||
*/
|
||||
public static TickUnitSource createLogTickUnits(Locale locale) {
|
||||
|
||||
TickUnits units = new TickUnits();
|
||||
|
||||
NumberFormat numberFormat = NumberFormat.getNumberInstance(locale);
|
||||
|
||||
units.add(new NumberTickUnit(1, numberFormat));
|
||||
units.add(new NumberTickUnit(2, numberFormat));
|
||||
units.add(new NumberTickUnit(5, numberFormat));
|
||||
units.add(new NumberTickUnit(10, numberFormat));
|
||||
units.add(new NumberTickUnit(20, numberFormat));
|
||||
units.add(new NumberTickUnit(50, numberFormat));
|
||||
units.add(new NumberTickUnit(100, numberFormat));
|
||||
units.add(new NumberTickUnit(200, numberFormat));
|
||||
units.add(new NumberTickUnit(500, numberFormat));
|
||||
units.add(new NumberTickUnit(1000, numberFormat));
|
||||
units.add(new NumberTickUnit(2000, numberFormat));
|
||||
units.add(new NumberTickUnit(5000, numberFormat));
|
||||
units.add(new NumberTickUnit(10000, numberFormat));
|
||||
units.add(new NumberTickUnit(20000, numberFormat));
|
||||
units.add(new NumberTickUnit(50000, numberFormat));
|
||||
units.add(new NumberTickUnit(100000, numberFormat));
|
||||
units.add(new NumberTickUnit(200000, numberFormat));
|
||||
units.add(new NumberTickUnit(500000, numberFormat));
|
||||
units.add(new NumberTickUnit(1000000, numberFormat));
|
||||
units.add(new NumberTickUnit(2000000, numberFormat));
|
||||
units.add(new NumberTickUnit(5000000, numberFormat));
|
||||
units.add(new NumberTickUnit(10000000, numberFormat));
|
||||
units.add(new NumberTickUnit(20000000, numberFormat));
|
||||
units.add(new NumberTickUnit(50000000, numberFormat));
|
||||
units.add(new NumberTickUnit(100000000, numberFormat));
|
||||
units.add(new NumberTickUnit(200000000, numberFormat));
|
||||
units.add(new NumberTickUnit(500000000, numberFormat));
|
||||
units.add(new NumberTickUnit(1000000000, numberFormat));
|
||||
units.add(new NumberTickUnit(2000000000, numberFormat));
|
||||
units.add(new NumberTickUnit(5000000000.0, numberFormat));
|
||||
units.add(new NumberTickUnit(10000000000.0, numberFormat));
|
||||
|
||||
return units;
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user